noble engine migration
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("CrossDissolve", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.CrossDissolve
|
||||
transition.name = "Cross Dissolve"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.MIX
|
||||
|
||||
--- A simple cross-fade.
|
||||
-- @table Noble.Transition.CrossDissolve.defaultProperties
|
||||
-- @tparam[opt=Ease.outCubic] Ease ease
|
||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
||||
transition.defaultProperties = {
|
||||
ease = Ease.outCubic,
|
||||
dither = Graphics.image.kDitherTypeBayer4x4
|
||||
}
|
||||
|
||||
function transition:setProperties(__properties)
|
||||
self.dither = __properties.dither or self.defaultProperties.dither
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
self.oldSceneScreenshot:drawFaded(0, 0, 1 - self.sequence:get(), self.dither)
|
||||
end
|
13
source/libraries/noble/modules/Noble.Transition/Cut.lua
Normal file
13
source/libraries/noble/modules/Noble.Transition/Cut.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("Cut", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.Cut
|
||||
transition.name = "Cut"
|
||||
|
||||
-- Properties
|
||||
transition._type = Noble.Transition.Type.CUT
|
||||
|
||||
--- An all-time classic.
|
||||
-- This transition has no properties.
|
||||
-- @table Noble.Transition.Cut.defaultProperties
|
37
source/libraries/noble/modules/Noble.Transition/Dip.lua
Normal file
37
source/libraries/noble/modules/Noble.Transition/Dip.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("Dip", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.Dip
|
||||
transition.name = "Dip"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.COVER
|
||||
|
||||
--- Fade to an image, then to the next scene.
|
||||
-- @table Noble.Transition.Dip.defaultProperties
|
||||
-- @number[opt=0.25] holdTime
|
||||
-- @tparam Graphics.image panelImage
|
||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
||||
-- @number[opt=0] x
|
||||
-- @number[opt=0] y
|
||||
transition.defaultProperties = {
|
||||
holdTime = 0.25,
|
||||
ease = Ease.outInQuad,
|
||||
dither = Graphics.image.kDitherTypeBayer4x4,
|
||||
panelImage = nil,
|
||||
x = 0,
|
||||
y = 0
|
||||
}
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
self.dither = __arguments.dither or self.defaultProperties.dither
|
||||
self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage
|
||||
self.x = __arguments.x or self.defaultProperties.x
|
||||
self.y = __arguments.y or self.defaultProperties.y
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
self.panelImage:drawFaded(self.x, self.y, self.sequence:get(), self.dither)
|
||||
end
|
@@ -0,0 +1,19 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("DipToBlack", nil, Noble.Transition).extends(Noble.Transition.Dip)
|
||||
local transition = Noble.Transition.DipToBlack
|
||||
transition.name = "Dip to Black"
|
||||
|
||||
--- Fade to black, then to the next scene.
|
||||
-- NOTE: The `panelImage` property is locked.
|
||||
-- @see Noble.Transition.Dip.defaultProperties
|
||||
-- @table Noble.Transition.DipToBlack.defaultProperties
|
||||
|
||||
transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
||||
|
||||
function transition:setCustomArguments(__arguments)
|
||||
transition.super.setCustomArguments(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
end
|
@@ -0,0 +1,19 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("DipToWhite", nil, Noble.Transition).extends(Noble.Transition.Dip)
|
||||
local transition = Noble.Transition.DipToWhite
|
||||
transition.name = "Dip to White"
|
||||
|
||||
--- Fade to white, then to the next scene.
|
||||
-- NOTE: The `panelImage` property is locked.
|
||||
-- @see Noble.Transition.Dip.defaultProperties
|
||||
-- @table Noble.Transition.DipToWhite.defaultProperties
|
||||
|
||||
transition.panelImage = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
||||
|
||||
function transition:setCustomArguments(__arguments)
|
||||
transition.super.setCustomArguments(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
end
|
131
source/libraries/noble/modules/Noble.Transition/Imagetable.lua
Normal file
131
source/libraries/noble/modules/Noble.Transition/Imagetable.lua
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("Imagetable", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.Imagetable
|
||||
transition.name = "Imagetable"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.COVER
|
||||
|
||||
-- Overrides
|
||||
transition.easeEnter = Ease.linear
|
||||
transition.easeExit = Ease.linear
|
||||
|
||||
--- A dip-style transition using one or two imagetables.
|
||||
-- @see Noble.Transition.ImagetableMask.defaultProperties
|
||||
-- @table Noble.Transition.Imagetable.defaultProperties
|
||||
-- @number[opt=0] holdTime
|
||||
-- @tparam Graphics.imagetable imagetable
|
||||
-- @bool[opt=false] reverse
|
||||
-- @bool[opt=false] flipX
|
||||
-- @bool[opt=false] flipY
|
||||
-- @bool[opt=false] rotate
|
||||
-- @tparam Graphics.imagetable imagetableEnter
|
||||
-- @bool[opt=nil] reverseEnter
|
||||
-- @bool[opt=nil] flipXEnter
|
||||
-- @bool[opt=nil] flipYEnter
|
||||
-- @bool[opt=nil] rotateEnter
|
||||
-- @tparam Graphics.imagetable imagetableExit
|
||||
-- @bool[opt=nil] reverseExit
|
||||
-- @bool[opt=nil] flipXExit
|
||||
-- @bool[opt=nil] flipYExit
|
||||
-- @bool[opt=nil] rotateExit
|
||||
transition.defaultProperties = {
|
||||
holdTime = 0,
|
||||
imagetable = nil,
|
||||
imagetableEnter = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
|
||||
imagetableExit = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionExit"),
|
||||
reverse = false,
|
||||
reverseEnter = nil,
|
||||
reverseExit = nil,
|
||||
flipX = false,
|
||||
flipY = false,
|
||||
flipXEnter = nil,
|
||||
flipYEnter = nil,
|
||||
flipXExit = nil,
|
||||
flipYExit = nil,
|
||||
rotate = false,
|
||||
rotateEnter = nil,
|
||||
rotateExit = nil,
|
||||
}
|
||||
|
||||
function transition:setProperties(__properties)
|
||||
|
||||
self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
|
||||
self.imagetableEnter = __properties.imagetableEnter or self.defaultProperties.imagetableEnter or self.imagetable
|
||||
self.imagetableExit = __properties.imagetableExit or self.defaultProperties.imagetableExit or self.imagetable
|
||||
|
||||
self.reverse = __properties.reverse or self.defaultProperties.reverse
|
||||
self.reverseEnter = __properties.reverseEnter or self.defaultProperties.reverseEnter or self.reverse
|
||||
self.reverseExit = __properties.reverseExit or self.defaultProperties.reverseExit or self.reverse
|
||||
|
||||
self.flipX = __properties.flipX or self.defaultProperties.flipX
|
||||
self.flipY = __properties.flipY or self.defaultProperties.flipY
|
||||
self.flipXEnter = __properties.flipXEnter or self.defaultProperties.flipXEnter or self.flipX
|
||||
self.flipYEnter = __properties.flipYEnter or self.defaultProperties.flipYEnter or self.flipY
|
||||
self.flipXExit = __properties.flipXExit or self.defaultProperties.flipXExit or self.flipX
|
||||
self.flipYExit = __properties.flipYExit or self.defaultProperties.flipYExit or self.flipY
|
||||
|
||||
self.rotate = __properties.rotate or self.defaultProperties.rotate
|
||||
self.rotateEnter = __properties.rotateEnter or self.defaultProperties.rotateEnter or self.rotate
|
||||
self.rotateExit = __properties.rotateExit or self.defaultProperties.rotateExit or self.rotate
|
||||
|
||||
-- "Private" variables
|
||||
self._frameCountEnter = self.imagetableEnter and #self.imagetableEnter or 0
|
||||
self._frameCountExit = self.imagetableExit and #self.imagetableExit or 0
|
||||
|
||||
self._flipValueEnter = Noble.Transition.Imagetable.getFlipValue(self.rotateEnter, self.flipXEnter, self.flipYEnter)
|
||||
self._flipValueExit = Noble.Transition.Imagetable.getFlipValue(self.rotateExit, self.flipXExit, self.flipYExit)
|
||||
|
||||
local sequence0 = (not self.reverseEnter) and 0 or 1
|
||||
local sequence1 = (not self.reverseEnter) and 1 or 0
|
||||
local sequenceExit0 = (not self.reverseExit) and 0 or 1
|
||||
local sequenceExit1 = (not self.reverseExit) and 1 or 0
|
||||
|
||||
if (self.imagetableEnter == self.imagetableExit) then
|
||||
self._sequenceStartValue = sequence0
|
||||
self._sequenceMidpointValue = sequence1
|
||||
self._sequenceResumeValue = sequence1
|
||||
self._sequenceCompleteValue = sequence0
|
||||
else
|
||||
self._sequenceStartValue = sequence0
|
||||
self._sequenceMidpointValue = sequence1
|
||||
self._sequenceResumeValue = sequenceExit0
|
||||
self._sequenceCompleteValue = sequenceExit1
|
||||
end
|
||||
|
||||
-- Warnings
|
||||
if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
|
||||
warn("BONK: You've specified an ease value for an Noble.Transition.Imagetable transition. This will have no effect.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
local imagetable
|
||||
local frameCount
|
||||
local flipValue
|
||||
if not self.holdTimeElapsed then
|
||||
imagetable = self.imagetableEnter
|
||||
frameCount = self._frameCountEnter
|
||||
flipValue = self._flipValueEnter
|
||||
else
|
||||
imagetable = self.imagetableExit
|
||||
frameCount = self._frameCountExit
|
||||
flipValue = self._flipValueExit
|
||||
end
|
||||
local index = math.clamp((progress * frameCount) // 1, 1, frameCount)
|
||||
imagetable[index]:draw(0, 0, flipValue)
|
||||
end
|
||||
|
||||
function Noble.Transition.Imagetable.getFlipValue(__rotate, __flipX, __flipY)
|
||||
if(__rotate or (__flipX and __flipY)) then
|
||||
return Graphics.kImageFlippedXY
|
||||
else
|
||||
if(__flipX) then return Graphics.kImageFlippedX
|
||||
elseif(__flipY) then return Graphics.kImageFlippedY end
|
||||
end
|
||||
return Graphics.kImageUnflipped
|
||||
end
|
@@ -0,0 +1,83 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("ImagetableMask", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.ImagetableMask
|
||||
transition.name = "Imagetable Mask"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.MIX
|
||||
|
||||
-- Overrides
|
||||
transition.ease = Ease.linear
|
||||
|
||||
--- A wipe transition using an animated mask in the form of an imagetable.
|
||||
-- @see Noble.Transition.Imagetable.defaultProperties
|
||||
-- @table Noble.Transition.ImagetableMask.defaultProperties
|
||||
-- @tparam Graphics.imagetable imagetable
|
||||
-- @bool[opt=false] reverse Set `true` to play the imagetable's frames in reverse order.
|
||||
-- @bool[opt=false] flipX
|
||||
-- @bool[opt=false] flipY
|
||||
-- @bool[opt=false] rotate Set as `true` to rotate the image 180-degrees
|
||||
-- @bool[opt=true] hasTransparency Set as `true` if the imagetable asset has transparent pixels. Set as `false` if the image uses white pixels for transparency.
|
||||
-- @bool[opt=false] invert Set as `true` to invert the image mask.
|
||||
transition.defaultProperties = {
|
||||
imagetable = Graphics.imagetable.new("libraries/noble/assets/images/BoltTransitionEnter"),
|
||||
reverse = false,
|
||||
flipX = false,
|
||||
flipY = false,
|
||||
rotate = false,
|
||||
hasTransparency = true,
|
||||
invert = false
|
||||
}
|
||||
|
||||
function transition:setProperties(__properties)
|
||||
|
||||
self.imagetable = __properties.imagetable or self.defaultProperties.imagetable
|
||||
self.reverse = __properties.reverse or self.defaultProperties.reverse
|
||||
self.flipX = __properties.flipX or self.defaultProperties.flipX
|
||||
self.flipY = __properties.flipY or self.defaultProperties.flipY
|
||||
self.rotate = __properties.rotate or self.defaultProperties.rotate
|
||||
self.hasTransparency = __properties.hasTransparency or self.defaultProperties.hasTransparency
|
||||
self.invert = __properties.invert or self.defaultProperties.invert
|
||||
|
||||
-- "Private" variables
|
||||
self._flipValue = Noble.Transition.Imagetable.getFlipValue(self.rotate, self.flipX, self.flipY)
|
||||
self._imagetableLength = self.imagetable and #self.imagetable or 0
|
||||
self._maskBackground = nil
|
||||
self._maskForegroundDrawMode = nil
|
||||
if (self.invert ~= true) then
|
||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
|
||||
else
|
||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
|
||||
end
|
||||
|
||||
-- Warnings
|
||||
if (__properties.imagetableExit ~= nil) then
|
||||
warn("BONK: You've specified an 'imagetableExit' for an Noble.Transition.ImagetableMask transition. This will have no effect. ")
|
||||
end
|
||||
if ((__properties.ease or __properties.easeEnter or __properties.easeExit) ~= nil) then
|
||||
warn("BONK: You've specified an ease value for an Noble.Transition.ImagetableMask transition. This will have no effect.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
local length = self._imagetableLength
|
||||
local index = math.clamp((progress * length) // 1, 1, length)
|
||||
local mask = Graphics.image.new(400, 240)
|
||||
|
||||
Graphics.pushContext(mask)
|
||||
Graphics.setImageDrawMode(Graphics.kDrawModeCopy)
|
||||
self._maskBackground:draw(0,0)
|
||||
if (self.hasTransparency) then Graphics.setImageDrawMode(self._maskForegroundDrawMode) end
|
||||
self.imagetable[index]:draw(0,0, self._flipValue)
|
||||
Graphics.popContext()
|
||||
|
||||
self.oldSceneScreenshot:setMaskImage(mask)
|
||||
self.oldSceneScreenshot:draw(0,0)
|
||||
|
||||
end
|
@@ -0,0 +1,58 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("MetroNexus", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.MetroNexus
|
||||
transition.name = "Metro Nexus"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.COVER
|
||||
|
||||
-- Overrides
|
||||
transition._sequenceResumeValue = 0
|
||||
transition._sequenceCompleteValue = 1
|
||||
transition.easeEnter = Ease.linear
|
||||
transition.easeExit = Ease.linear
|
||||
|
||||
--- A "cascade" wipe transition, taken from "Metro Nexus" by Noble Robot.
|
||||
-- This transition has no properties.
|
||||
-- @table Noble.Transition.MetroNexus.defaultProperties
|
||||
|
||||
-- "Static" variables
|
||||
local panels
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
|
||||
if (panels == nil) then
|
||||
panels = {
|
||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
||||
Graphics.image.new(80,240, Graphics.kColorWhite),
|
||||
Graphics.image.new(80,240, Graphics.kColorWhite)
|
||||
}
|
||||
end
|
||||
|
||||
-- Warnings
|
||||
if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
|
||||
warn("BONK: 'Noble.Transition.MetroNexus' does not support custom ease values.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
if (not self.holdTimeElapsed) then
|
||||
panels[1]:draw(000, (-1 + Ease.outQuint(progress, 0, 1, 1)) * 240)
|
||||
panels[2]:draw(080, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
|
||||
panels[3]:draw(160, (-1 + Ease.outQuart(progress, 0, 1, 1)) * 240)
|
||||
panels[4]:draw(240, (-1 + Ease.outCubic(progress, 0, 1, 1)) * 240)
|
||||
panels[5]:draw(320, (-1 + Ease.outSine (progress, 0, 1, 1)) * 240)
|
||||
else
|
||||
panels[1]:draw(000, (1 - Ease.inQuint(progress, 0, 1, 1)) * -240 + 240)
|
||||
panels[2]:draw(080, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
|
||||
panels[3]:draw(160, (1 - Ease.inQuart(progress, 0, 1, 1)) * -240 + 240)
|
||||
panels[4]:draw(240, (1 - Ease.inCubic(progress, 0, 1, 1)) * -240 + 240)
|
||||
panels[5]:draw(320, (1 - Ease.inSine (progress, 0, 1, 1)) * -240 + 240)
|
||||
end
|
||||
end
|
38
source/libraries/noble/modules/Noble.Transition/SlideOff.lua
Normal file
38
source/libraries/noble/modules/Noble.Transition/SlideOff.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOff", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.SlideOff
|
||||
transition.name = "Slide Off"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.MIX
|
||||
|
||||
--- The previous scene slides off the screen, revealing the next scene.
|
||||
-- @table Noble.Transition.SlideOff.defaultProperties
|
||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
||||
-- @number[opt=0] x
|
||||
-- @number[opt=0] y
|
||||
-- @number[opt=0] rotation
|
||||
transition.defaultProperties = {
|
||||
ease = Ease.inQuart,
|
||||
x = 0,
|
||||
y = 0,
|
||||
rotation = 0
|
||||
}
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
self.x = __arguments.x or self.defaultProperties.x
|
||||
self.y = __arguments.y or self.defaultProperties.y
|
||||
self.rotation = __arguments.rotation or self.defaultProperties.rotation
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
transition.super.draw(self)
|
||||
local progress = self.sequence:get()
|
||||
self.oldSceneScreenshot:drawRotated(
|
||||
self.x * progress + 200,
|
||||
self.y * progress + 120,
|
||||
self.rotation * progress
|
||||
)
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOffDown", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
||||
local transition = Noble.Transition.SlideOffDown
|
||||
transition.name = "Slide Off (Down)"
|
||||
|
||||
--- The previous scene slides off the bottom of the screen, revealing the next scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
||||
-- @table Noble.Transition.SlideOffDown.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = 240
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOffLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
||||
local transition = Noble.Transition.SlideOffLeft
|
||||
transition.name = "Slide Off (Left)"
|
||||
|
||||
--- The previous scene slides off the left side of the screen, revealing the next scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
||||
-- @table Noble.Transition.SlideOffLeft.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = -400
|
||||
self.y = 0
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOffRight", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
||||
local transition = Noble.Transition.SlideOffRight
|
||||
transition.name = "Slide Off (Right)"
|
||||
|
||||
--- The previous scene slides off the right side of the screen, revealing the next scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
||||
-- @table Noble.Transition.SlideOffRight.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 400
|
||||
self.y = 0
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOffUp", nil, Noble.Transition).extends(Noble.Transition.SlideOff)
|
||||
local transition = Noble.Transition.SlideOffUp
|
||||
transition.name = "Slide Off (Up)"
|
||||
|
||||
--- The previous scene slides off the top of the screen, revealing the next scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOff.defaultProperties
|
||||
-- @table Noble.Transition.SlideOffUp.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = -240
|
||||
self.rotation = 0
|
||||
end
|
44
source/libraries/noble/modules/Noble.Transition/SlideOn.lua
Normal file
44
source/libraries/noble/modules/Noble.Transition/SlideOn.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOn", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.SlideOn
|
||||
transition.name = "Slide On"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.MIX
|
||||
|
||||
-- Overrides
|
||||
transition._sequenceStartValue = 1
|
||||
transition._sequenceCompleteValue = 0
|
||||
transition._captureScreenshotsDuringTransition = true
|
||||
|
||||
--- The next scene slides on the screen, covering up the previous scene.
|
||||
-- @table Noble.Transition.SlideOn.defaultProperties
|
||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
||||
-- @number[opt=0] x
|
||||
-- @number[opt=0] y
|
||||
-- @number[opt=0] rotation
|
||||
transition.defaultProperties = {
|
||||
ease = Ease.outQuart,
|
||||
x = 0,
|
||||
y = 0,
|
||||
rotation = 0
|
||||
}
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
self.x = __arguments.x or self.defaultProperties.x
|
||||
self.y = __arguments.y or self.defaultProperties.y
|
||||
self.rotation = __arguments.rotation or self.defaultProperties.rotation
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
transition.super.draw(self)
|
||||
local progress = self.sequence:get()
|
||||
self.oldSceneScreenshot:draw(0,0)
|
||||
self.newSceneScreenshot:drawRotated(
|
||||
self.x * progress + 200,
|
||||
self.y * progress + 120,
|
||||
self.rotation * progress
|
||||
)
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOnDown", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
||||
local transition = Noble.Transition.SlideOnDown
|
||||
transition.name = "Slide On (Down)"
|
||||
|
||||
--- The next scene slides onto the screen from the top, covering up the previous scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
||||
-- @table Noble.Transition.SlideOnDown.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = -240
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOnLeft", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
||||
local transition = Noble.Transition.SlideOnLeft
|
||||
transition.name = "Slide On (Left)"
|
||||
|
||||
--- The next scene slides onto the screen right-to-left, covering up the previous scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
||||
-- @table Noble.Transition.SlideOnLeft.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 400
|
||||
self.y = 0
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOnRight", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
||||
local transition = Noble.Transition.SlideOnRight
|
||||
transition.name = "Slide On (Right)"
|
||||
|
||||
--- The next scene slides onto the screen left-to-right, covering up the previous scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
||||
-- @table Noble.Transition.SlideOnRight.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = -400
|
||||
self.y = 0
|
||||
self.rotation = 0
|
||||
end
|
@@ -0,0 +1,18 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SlideOnUp", nil, Noble.Transition).extends(Noble.Transition.SlideOn)
|
||||
local transition = Noble.Transition.SlideOnUp
|
||||
transition.name = "Slide On (Up)"
|
||||
|
||||
--- The next scene slides onto the screen from the bottom, covering up the previous scene.
|
||||
-- NOTE: The `x`, `y`, and `rotation` properties are locked.
|
||||
-- @see Noble.Transition.SlideOn.defaultProperties
|
||||
-- @table Noble.Transition.SlideOnUp.defaultProperties
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
transition.super.setProperties(self, __arguments)
|
||||
self.x = 0
|
||||
self.y = 240
|
||||
self.rotation = 0
|
||||
end
|
100
source/libraries/noble/modules/Noble.Transition/Spotlight.lua
Normal file
100
source/libraries/noble/modules/Noble.Transition/Spotlight.lua
Normal file
@@ -0,0 +1,100 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("Spotlight", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.Spotlight
|
||||
transition.name = "Spotlight"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.COVER
|
||||
|
||||
--- A spotlight in-out transition.
|
||||
-- @see Noble.Transition.SpotlightMask.defaultProperties
|
||||
-- @table Noble.Transition.Spotlight.defaultProperties
|
||||
-- @number[opt=0.25] holdTime
|
||||
-- @tparam Graphics.image panelImage
|
||||
-- @tparam[opt=Graphics.image.kDitherTypeBayer4x4] Graphics.image.kDither dither
|
||||
-- @tparam[opt=Ease.outInQuad] Ease ease
|
||||
-- @number[opt=200] x
|
||||
-- @number[opt=120] y
|
||||
-- @tparam[opt=nil] Ease easeEnter
|
||||
-- @number[opt=nil] xEnter
|
||||
-- @number[opt=nil] yEnter
|
||||
-- @number[opt=nil] xEnterStart
|
||||
-- @number[opt=nil] yEnterStart
|
||||
-- @number[opt=nil] xEnterEnd
|
||||
-- @number[opt=nil] yEnterEnd
|
||||
-- @tparam[opt=nil] Ease easeEnter
|
||||
-- @number[opt=nil] xExit
|
||||
-- @number[opt=nil] yExit
|
||||
-- @number[opt=nil] xExitStart
|
||||
-- @number[opt=nil] yExitStart
|
||||
-- @number[opt=nil] xExitEnd
|
||||
-- @number[opt=nil] yExitEnd
|
||||
transition.defaultProperties = {
|
||||
holdTime = 0.25,
|
||||
panelImage = nil,
|
||||
dither = Graphics.image.kDitherTypeBayer4x4,
|
||||
ease = Ease.outInQuad,
|
||||
x = 200,
|
||||
y = 120,
|
||||
easeEnter = nil,
|
||||
xEnter = nil,
|
||||
yEnter = nil,
|
||||
xEnterStart = nil,
|
||||
yEnterStart = nil,
|
||||
xEnterEnd = nil,
|
||||
yEnterEnd = nil,
|
||||
easeExit = nil,
|
||||
xExit = nil,
|
||||
yExit = nil,
|
||||
xExitStart = nil,
|
||||
yExitStart = nil,
|
||||
xExitEnd = nil,
|
||||
yExitEnd = nil
|
||||
}
|
||||
|
||||
-- "Static" variables
|
||||
local defaultPanelImage
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
if (defaultPanelImage == nil) then defaultPanelImage = Graphics.image.new(400,240, Graphics.kColorBlack) end
|
||||
self.panelImage = __arguments.panelImage or self.defaultProperties.panelImage or defaultPanelImage
|
||||
self.dither = __arguments.dither or self.defaultProperties.dither
|
||||
self.x = __arguments.x or self.defaultProperties.x
|
||||
self.y = __arguments.y or self.defaultProperties.y
|
||||
|
||||
self.xEnter = __arguments.xEnter or self.defaultProperties.xEnter or self.x
|
||||
self.yEnter = __arguments.yEnter or self.defaultProperties.yEnter or self.y
|
||||
self.xEnterStart = __arguments.xEnterStart or self.defaultProperties.xEnterStart or self.xEnter
|
||||
self.yEnterStart = __arguments.yEnterStart or self.defaultProperties.yEnterStart or self.yEnter
|
||||
self.xEnterEnd = __arguments.xEnterEnd or self.defaultProperties.xEnterEnd or self.xEnter
|
||||
self.yEnterEnd = __arguments.yEnterEnd or self.defaultProperties.yEnterEnd or self.yEnter
|
||||
|
||||
self.xExit = __arguments.xExit or self.defaultProperties.xExit or self.x
|
||||
self.yExit = __arguments.yExit or self.defaultProperties.yExit or self.y
|
||||
self.xExitStart = __arguments.xExitStart or self.defaultProperties.xExitStart or self.xExit
|
||||
self.yExitStart = __arguments.yExitStart or self.defaultProperties.yExitStart or self.yExit
|
||||
self.xExitEnd = __arguments.xExitEnd or self.defaultProperties.xExitEnd or self.xExit
|
||||
self.yExitEnd = __arguments.yExitEnd or self.defaultProperties.yExitEnd or self.yExit
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
self.panelImage:drawFaded(0, 0, progress, self.dither)
|
||||
Graphics.setColor(Graphics.kColorClear)
|
||||
if (not self.midpointReached) then
|
||||
Graphics.fillCircleAtPoint(
|
||||
math.lerp(self.xEnterStart, self.xEnterEnd, progress),
|
||||
math.lerp(self.yEnterStart, self.yEnterEnd, progress),
|
||||
(1 - progress) * 233
|
||||
)
|
||||
else
|
||||
Graphics.fillCircleAtPoint(
|
||||
math.lerp(self.xExitStart, self.xExitEnd, progress),
|
||||
math.lerp(self.yExitStart, self.yExitEnd, progress),
|
||||
(1 - progress) * 233
|
||||
)
|
||||
end
|
||||
Graphics.setColor(Graphics.kColorBlack)
|
||||
end
|
@@ -0,0 +1,99 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("SpotlightMask", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.SpotlightMask
|
||||
transition.name = "Spotlight Mask"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.MIX
|
||||
|
||||
--- A circle wipe transition.
|
||||
-- @see Noble.Transition.Spotlight.defaultProperties
|
||||
-- @table Noble.Transition.SpotlightMask.defaultProperties
|
||||
-- @tparam[opt=Ease.outQuad] Ease ease
|
||||
-- @number[opt=200] x
|
||||
-- @number[opt=120] y
|
||||
-- @number[opt=nil] xStart
|
||||
-- @number[opt=nil] yStart
|
||||
-- @number[opt=nil] xEnd
|
||||
-- @number[opt=nil] yEnd
|
||||
-- @bool[opt=false] invert
|
||||
transition.defaultProperties = {
|
||||
ease = Ease.outQuad,
|
||||
x = 200,
|
||||
y = 120,
|
||||
xStart = nil,
|
||||
yStart = nil,
|
||||
xEnd = nil,
|
||||
yEnd = nil,
|
||||
invert = false
|
||||
}
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
self.x = __arguments.x or self.defaultProperties.x
|
||||
self.y = __arguments.y or self.defaultProperties.y
|
||||
self.xStart = __arguments.xStart or self.defaultProperties.xStart or self.x
|
||||
self.yStart = __arguments.yStart or self.defaultProperties.yStart or self.y
|
||||
self.xEnd = __arguments.xEnd or self.defaultProperties.xEnd or self.x
|
||||
self.yEnd = __arguments.yEnd or self.defaultProperties.yEnd or self.y
|
||||
|
||||
self.invert = __arguments.invert or self.defaultProperties.invert
|
||||
|
||||
if (self.invert) then
|
||||
self.ease = Ease.reverse(self.ease)
|
||||
end
|
||||
|
||||
-- "Private" variables
|
||||
self._maskBackground = nil
|
||||
self._maskForegroundDrawMode = nil
|
||||
if (self.invert ~= true) then
|
||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorWhite)
|
||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillBlack
|
||||
else
|
||||
self._maskBackground = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
||||
self._maskForegroundDrawMode = Graphics.kDrawModeFillWhite
|
||||
end
|
||||
|
||||
self._startRadius = math.max(
|
||||
Geometry.distanceToPoint(self.xStart, self.yStart, 0, 0),
|
||||
Geometry.distanceToPoint(self.xStart, self.yStart, 400, 0),
|
||||
Geometry.distanceToPoint(self.xStart, self.yStart, 400, 240),
|
||||
Geometry.distanceToPoint(self.xStart, self.yStart, 0, 240)
|
||||
)
|
||||
self._endRadius = math.max(
|
||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 0),
|
||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 0),
|
||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 400, 240),
|
||||
Geometry.distanceToPoint(self.xEnd, self.yEnd, 0, 240)
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
|
||||
if (not self.invert) then
|
||||
self.oldSceneScreenshot:draw(0, 0)
|
||||
Graphics.setColor(Graphics.kColorClear)
|
||||
Graphics.fillCircleAtPoint(
|
||||
math.lerp(self.xStart, self.xEnd, progress),
|
||||
math.lerp(self.yStart, self.yEnd, progress),
|
||||
progress * self._endRadius
|
||||
)
|
||||
Graphics.setColor(Graphics.kColorBlack)
|
||||
else
|
||||
local mask = Graphics.image.new(400, 240, Graphics.kColorBlack)
|
||||
Graphics.pushContext(mask)
|
||||
Graphics.setColor(Graphics.kColorWhite)
|
||||
Graphics.fillCircleAtPoint(
|
||||
math.lerp(self.xStart, self.xEnd, progress),
|
||||
math.lerp(self.yStart, self.yEnd, progress),
|
||||
(1 - progress) * self._startRadius
|
||||
)
|
||||
Graphics.popContext()
|
||||
self.oldSceneScreenshot:setMaskImage(mask)
|
||||
self.oldSceneScreenshot:draw(0, 0)
|
||||
end
|
||||
|
||||
end
|
@@ -0,0 +1,73 @@
|
||||
---
|
||||
-- @submodule Noble.Transition
|
||||
|
||||
class("WidgetSatchel", nil, Noble.Transition).extends(Noble.Transition)
|
||||
local transition = Noble.Transition.WidgetSatchel
|
||||
transition.name = "Widget Satchel"
|
||||
|
||||
-- Type
|
||||
transition._type = Noble.Transition.Type.COVER
|
||||
|
||||
-- Overrides
|
||||
transition._sequenceCompleteValue = 2
|
||||
transition.easeEnter = Ease.outCubic
|
||||
transition.easeExit = Ease.inCubic
|
||||
|
||||
--- An "accordion" transition, taken from "Widget Satchel" by Noble Robot.
|
||||
-- This transition has no properties.
|
||||
-- @table Noble.Transition.MetroNexus.defaultProperties
|
||||
|
||||
-- "Static" variables
|
||||
local panels
|
||||
|
||||
function transition:setProperties(__arguments)
|
||||
|
||||
if (panels == nil) then
|
||||
panels = {
|
||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
||||
Graphics.image.new(400,48, Graphics.kColorWhite),
|
||||
Graphics.image.new(400,48, Graphics.kColorWhite)
|
||||
}
|
||||
Graphics.lockFocus(panels[1])
|
||||
Graphics.setDitherPattern(0.4, Graphics.image.kDitherTypeScreen)
|
||||
Graphics.fillRect(0,0,400,48)
|
||||
Graphics.lockFocus(panels[2])
|
||||
Graphics.setDitherPattern(0.7, Graphics.image.kDitherTypeScreen)
|
||||
Graphics.fillRect(0,0,400,48)
|
||||
Graphics.lockFocus(panels[3])
|
||||
Graphics.setDitherPattern(0.25, Graphics.image.kDitherTypeBayer8x8)
|
||||
Graphics.fillRect(0,0,400,48)
|
||||
Graphics.lockFocus(panels[4])
|
||||
Graphics.setDitherPattern(0.5, Graphics.image.kDitherTypeDiagonalLine)
|
||||
Graphics.fillRect(0,0,400,48)
|
||||
Graphics.lockFocus(panels[5])
|
||||
Graphics.setDitherPattern(0.8, Graphics.image.kDitherTypeHorizontalLine)
|
||||
Graphics.fillRect(0,0,400,48)
|
||||
Graphics.unlockFocus()
|
||||
end
|
||||
|
||||
-- Warnings
|
||||
if (__arguments.easeEnter or __arguments.easeEnter or __arguments.ease) then
|
||||
warn("BONK: 'Noble.Transition.WidgetSatchel' does not support custom ease values.")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function transition:draw()
|
||||
local progress = self.sequence:get()
|
||||
if (not self.midpointReached ) then
|
||||
panels[1]:draw(0, -48 + (progress * (48*1)) )
|
||||
panels[2]:draw(0, -48 + (progress * (48*2)) )
|
||||
panels[3]:draw(0, -48 + (progress * (48*3)) )
|
||||
panels[4]:draw(0, -48 + (progress * (48*4)) )
|
||||
panels[5]:draw(0, -48 + (progress * (48*5)) )
|
||||
else
|
||||
panels[1]:draw(0, 48*0 + (progress - 1) * 48*5)
|
||||
panels[2]:draw(0, 48*1 + (progress - 1) * 48*4)
|
||||
panels[3]:draw(0, 48*2 + (progress - 1) * 48*3)
|
||||
panels[4]:draw(0, 48*3 + (progress - 1) * 48*2)
|
||||
panels[5]:draw(0, 48*4 + (progress - 1) * 48*1)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user