SubSurface.sel
#!./Selene
Selene.UseDirectFB("--dfb:quiet,no-vt")
DirectFB.init( DirectFB.CooperativeConst('FULLSCREEN') );
srf = SelSurface.create { caps=SelSurface.CapabilityConst('PRIMARY') } w,h = srf:GetSize()
math.randomseed( os.time() )
for i=1,math.random(20,50) do
local c = math.random(10)
if c == 1 then
srf:SetColor( math.random(0,255), math.random(0,255), math.random(0,255), math.random(0,255))
elseif c == 2 then
if math.random(10000) == 1 then srf:Clear( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
end
elseif c == 3 then
srf:DrawLine( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 4 then
srf:DrawRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 5 then
srf:FillRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 6 then
srf:FillTriangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
end
end
print "Hit 'enter' key to continue"
io.stdin:read'*l'
ssrf,err = srf:SubSurface( 40,40, w-80, h-80 ) if not ssrf then
print('erreur :', err)
return
end
ssrf:Clear(0,0,0,0)
ssrf:SetColor( 128,0,0,0 )
ssrf:FillRectangle( 0,10,w,15 )
print "Hit 'enter' key to quit"
io.stdin:read'*l'
ssrf:destroy()
srf:destroy()