Hi All - just posting a little routine I built whilst exploring a way of building up an image like painting. This is a simple project to test an approach. The idea is you sprite an image to the centre of the screen, cover it with a full screen white image (paper) and then use finger/touch pen to gradually reveal the image. The image effect is better in black and white. Thought this may amuse the grand kids as you gradually reveal the image below. Not using masks just making pixels transparent with image:set(). Plenty of scope to improve - library of images, brush size response on touch etc.
Latest Version here
-- Scribble3 by Bri_G
function setup()
--
cx,cy = WIDTH/2, HEIGHT/2
parameter.integer("size",2,6,4)
parameter.boolean("reveal",false)
paper = image(WIDTH,HEIGHT)
parameter.integer("model",1,#piccies,1,
function()
pic = readImage(piccies[model])
prepare(pic)
end)
end
function draw()
-- show the image as it emerges
background(255, 255, 255, 255)
spriteMode(CENTER)
sprite(pic,cx,cy)
if not reveal then
sprite(paper,cx,cy)
end
end
function touched(t)
-- use the brush
if t.state == BEGAN or t.state == MOVING then
setContext(paper)
tx,ty = math.floor(t.x),math.floor(t.y)
for x = -size-1,size+1,1 do
for y = -size-1,size+1,1 do
paper:set(tx+x,ty+y,0,0,0,0)
end
end
setContext()
end
end
function prepare(p)
--
bw, bh = spriteSize(p)
setContext(paper)
fill(255, 255, 255, 255)
rectMode(CENTER)
rect(cx,cy,WIDTH,HEIGHT)
setContext()
end
piccies = {
"Documents:pic01",
"Documents:pic02",
"Documents:pic03",
"Documents:pic04"
}
Let me know if you think of any improvements, will be adding my own and will post.
Image produced from B&W old man image - partially revealed attached.
p.s. the image in the attached picture is not fully developed as the idea is to give an impression of a painted image being built up. Just slowly revealing the complete image would be a little boring. You could use a large image with overlaid grid and small images underneath as a find the treasure game.