mirror of
https://github.com/Rezmason/matrix.git
synced 2026-04-14 12:29: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 numGlyphs <const> = 133
|
||||
local numFades <const> = 16
|
||||
local blackImage = gfx.image.new(glyphWidth, glyphWidth, gfx.kColorBlack)
|
||||
local glyphTable = gfx.imagetable.new('images/matrix')
|
||||
local ditherType = gfx.image.kDitherTypeAtkinson
|
||||
local numFades <const> = 32
|
||||
local glyphs = {}
|
||||
for i = 1, numGlyphs do
|
||||
glyphs[i] = {}
|
||||
local glyph = glyphTable[i]
|
||||
for j = 1, numFades do
|
||||
glyphs[i][j] = glyph:blendWithImage(blackImage, 1 - j / numFades, ditherType)
|
||||
|
||||
do
|
||||
local glyphSpritesheet = gfx.image.new('images/matrix-glyphs')
|
||||
local spritesheetColumns = floor(glyphSpritesheet.width / glyphWidth)
|
||||
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
|
||||
|
||||
@@ -66,7 +80,7 @@ for x = 1, numColumns do
|
||||
end
|
||||
end
|
||||
|
||||
playdate.display.setRefreshRate(24)
|
||||
playdate.display.setRefreshRate(0)
|
||||
playdate.resetElapsedTime()
|
||||
|
||||
function playdate.update()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
name=The Playtrix
|
||||
author=Rezmason
|
||||
description=A familiar
|
||||
description=A familiar animation of mysterious raining symbols.
|
||||
bundleID=net.rezmason.theplaytrix
|
||||
version=1.0
|
||||
buildNumber=1
|
||||
|
||||
Reference in New Issue
Block a user