PatternSurface.sel
#!./Selene
Selene.UseDRMCairo()
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
card,err,msg = SelDCCard.Open()
if not card then
print("*E* DRM :", err,msg)
if SELPLUG_DRMCairo_FBEXTENSION then
local fb_fch = "/dev/fb1"
if not file_exists(fb_fch) then
fb_fch = "/dev/fb0"
end
card,err,msg = SelDCCard.OpenFB(fb_fch)
if not card then
print("*E* ".. fb_fch .." :", err,msg)
os.exit()
else
print("*I* ok with Framebuffer")
end
else
os.exit()
end
end
local srf = card:GetPrimarySurface()
local w,h = srf:GetSize() srf:Clear( 0,0,0 )
local pat = SelDCPattern.createLinear(0,0, 0,h)
pat:addFixPoint( 0, 1.0, 0, 0 )
pat:addFixPoint( 0.5, 1.0, 1.0, 0 )
pat:addFixPoint( 1.0, 0, 1.0, 0 )
srf:SetSourcePattern(pat)
srf:FillRectangle(0,0, w,h)
pat:Release()
pat = SelDCPattern.createLinear(0,0, w,0)
pat:addFixPoint( 0, .2, .2, .2, 1 )
pat:addFixPoint( 1, .2, .2, .2, .2 )
local spat = SelDCSurface.create(w,h)
spat:SetSourcePattern(pat)
spat:FillRectangle(0,0, w,h)
pat:Release()
srf:SetSourceSurface(spat)
srf:Paint()
spat:Release()
print "Hit 'enter' key to exit"
io.stdin:read'*l'
srf:Release()
card:Release()