I am planning on rotating a fairly large image (half width of the screen). I'm looking for recommendations.
Is there a recommended piece of software that makes saving the images easy? Should I do it in code?
How many images should I save? Is 360 too many?
Should I import all the images as an graphics.imagetable? That many images seems... heavy.
Anyone have any code snippets for any of this? Especially saving out the rotated images, but updating the image along with the (absolute) crank position would also be appreciated.
I just watched your Tiny Yellow Machine interview, and it sounds like maybe your "sprite studio" would help me with this task! (If it doesn't do the rotation piece, maybe it should, but even if it didn't, I'm also planning to move stuff around the screen while the rotation is happening, so it would help with that.)
Just for context, here's a mockup of what I'm planning:
import 'CoreLibs/graphics'
local gfx = playdate.graphics
gfx.setColor(gfx.kColorBlack)
local single_image = gfx.image.new("test_image")
local rotation_resolution = 72
function playdate.update()
if rotation_images then
--gfx.clear()
local select_image = nil
if playdate.isCrankDocked() then
select_image = 1
else
local crank_angle = playdate.getCrankPosition()
local segment_angle = 360 / rotation_resolution
select_image = math.floor((crank_angle + (segment_angle / 2)) / segment_angle) + 1
end
rotation_images:getImage(select_image):drawCentered(200, 120)
else
rotation_images = makeRotationImageTable(single_image, rotation_resolution)
end
end
function makeRotationImageTable(image, segments)
local w, h = image:getSize()
local max_wh = math.floor(math.sqrt(w * w + h * h)) + 1
local image_table = gfx.imagetable.new(segments + 1, max_wh, max_wh)
local image_index = 0
for angle = 0 , 360, 360/segments do
image_index += 1
local rotated_image = gfx.image.new(max_wh, max_wh)
gfx.lockFocus(rotated_image)
image:drawRotated(max_wh/2, max_wh/2, angle)
gfx.unlockFocus()
image_table:setImage(image_index, rotated_image)
end
return image_table
end