Replaced dithering logic with compositing a pre-rendered dithered gradient.

This commit is contained in:
Rezmason
2022-06-05 11:36:20 -07:00
parent 551ce132c4
commit 5bebf6ad71
4 changed files with 25 additions and 11 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -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()

View File

@@ -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