The 3D flip effect simulates the flipping of a playing card

Download the source code.
Play the video
Back








10









20









30







#!/usr/bin/env lua5.1

require[[fp]]
require[[fptheme]]
require[[fpeffects]]
require[[fpwidgets]]

-- The flip effect simulates the flipping of a playing card.
-- The flip effect uses two images to flip between.
-- As the front image is flipped, the back image becomes visible.

-- Create the background.
bg = fp.image{style="background"}

-- Use two images for the flip effect, a back image and a front image.
filenames = { "candy.jpg", "spices.jpg"}

-- We create the images at 1x1 size as the images have to render but they do
-- not need to be seen.  We could set their stacking to below the backround
-- too if we wanted.
images = {}
for i = 1, #filenames do
   images[i] = fp.image{ file = "data/"..filenames[i], x = 100*(i-1), y = 0, w = 1, h = 1 }
end

-- We wait until the images have been rendered and then create the flip.
-- frontimage and backimage specify the images to use on the front and
-- back, angle specifies the final angle of the flip.  The angle
-- can be set at creation and later as well.  The dir argument specifies
-- which direction the flip should go when setting the angle initially.
fp.timer(0.5, function()
		 flip = fp.flip{ frontimage = images[1],
				 backimage = images[2],
				 angle = 0, dir = 1,
				 x = 100, y = 100, w = 200, h = 200, focus = true }
	      end)

fp.begin()