mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-17 13:59:30 -07:00
Replaced dithering logic with compositing a pre-rendered dithered gradient.
This commit is contained in:
BIN
playdate/matrix_lua/images/fade-gradient.png
Normal file
BIN
playdate/matrix_lua/images/fade-gradient.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -10,16 +10,30 @@ local numRows <const> = floor(screenHeight / glyphWidth)
|
|||||||
local numCells <const> = numColumns * numRows
|
local numCells <const> = numColumns * numRows
|
||||||
|
|
||||||
local numGlyphs <const> = 133
|
local numGlyphs <const> = 133
|
||||||
local numFades <const> = 16
|
local numFades <const> = 32
|
||||||
local blackImage = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
|
|
||||||
local glyphTable = gfx.imagetable.new('images/matrix')
|
|
||||||
local ditherType = gfx.image.kDitherTypeAtkinson
|
|
||||||
local glyphs = {}
|
local glyphs = {}
|
||||||
for i = 1, numGlyphs do
|
|
||||||
glyphs[i] = {}
|
do
|
||||||
local glyph = glyphTable[i]
|
local glyphSpritesheet = gfx.image.new('images/matrix-glyphs')
|
||||||
for j = 1, numFades do
|
local spritesheetColumns = floor(glyphSpritesheet.width / glyphWidth)
|
||||||
glyphs[i][j] = glyph:blendWithImage(blackImage, 1 - j / numFades, ditherType)
|
local fadeGradient = gfx.image.new('images/fade-gradient')
|
||||||
|
local glyph = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
|
||||||
|
|
||||||
|
for i = 1, numGlyphs do
|
||||||
|
local column = (i - 1) % spritesheetColumns
|
||||||
|
local row = floor((i - 1) / spritesheetColumns)
|
||||||
|
gfx.lockFocus(glyph)
|
||||||
|
glyphSpritesheet:draw(-column * glyphWidth, -row * glyphWidth)
|
||||||
|
gfx.unlockFocus()
|
||||||
|
glyphs[i] = {}
|
||||||
|
for j = 1, numFades do
|
||||||
|
local fade = (j - 1) / (numFades - 1)
|
||||||
|
local variant = glyph:copy()
|
||||||
|
glyphs[i][j] = variant
|
||||||
|
gfx.lockFocus(variant)
|
||||||
|
fadeGradient:draw(fade * (glyphWidth - fadeGradient.width), 0)
|
||||||
|
gfx.unlockFocus()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -66,7 +80,7 @@ for x = 1, numColumns do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
playdate.display.setRefreshRate(24)
|
playdate.display.setRefreshRate(0)
|
||||||
playdate.resetElapsedTime()
|
playdate.resetElapsedTime()
|
||||||
|
|
||||||
function playdate.update()
|
function playdate.update()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name=The Playtrix
|
name=The Playtrix
|
||||||
author=Rezmason
|
author=Rezmason
|
||||||
description=A familiar
|
description=A familiar animation of mysterious raining symbols.
|
||||||
bundleID=net.rezmason.theplaytrix
|
bundleID=net.rezmason.theplaytrix
|
||||||
version=1.0
|
version=1.0
|
||||||
buildNumber=1
|
buildNumber=1
|
||||||
|
|||||||
Reference in New Issue
Block a user