SubSurface.sel
#!./Selene
Selene.UseDRMCairo()
card,err,msg = SelDCCard.Open()
if not card then
print("*E*", err,msg)
os.exit()
end
local srf = card:GetPrimarySurface()
local w,h = srf:GetSize() srf:Clear( 0,0,0 )
math.randomseed( os.time() )
for i=1,math.random(50,70) do
local c = math.random(5)
if c == 1 then
srf:SetColor( math.random()+.2, math.random()+.2, math.random()+.2, math.random()+.5)
elseif c == 2 then
srf:DrawLine( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 3 then
srf:DrawRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 4 then
srf:FillRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
end
end
print "Mother surface only"
print "Hit 'enter' key to continue"
io.stdin:read'*l'
w = w-80 h = h-80
ssrf,err = srf:SubSurface( 40,40, w, h) if not ssrf then
print('erreur :', err)
return
end
ssrf:Clear(0,0,0)
print "Subsurface footprint"
print "Hit 'enter' key to continue"
io.stdin:read'*l'
for i=1,math.random(20,50) do
local c = math.random(5)
if c == 1 then
ssrf:SetColor( math.random()+.2, math.random()+.2, math.random()+.2, math.random()+.5)
elseif c == 2 then
ssrf:DrawLine( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 3 then
ssrf:DrawRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
elseif c == 4 then
ssrf:FillRectangle( math.random(0,w), math.random(0,h), math.random(0,w), math.random(0,h) )
end
end
fch,err,msg = srf:Dump("/tmp","SubSurface")
if not fch then print("Can't dump", err,msg);
else
print("Dumped to", fch);
end
print "Hit 'enter' key to exit"
io.stdin:read'*l'
ssrf:Release()
srf:Release()
card:Release()