Lines.sel

#!./Selene
--- The famous "horizontal line test"

Selene.UseDRMCairo()

	-- Open default card.
	-- As no argument is passed it's the default one
	-- /dev/dri/card0
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()	-- Retrieve its size

----------------------------

srf:Clear(0,.25,0)	-- 100% green and no transparency

print( srf:SetColor(0.5,0.5,0.5,1) )	-- grey
print( srf:DrawLine( 0, h/2, w, h/2 ) )

srf:SetColor(1,0.5,0.5,0.8)	-- Orange
srf:DrawLine( w/2, 0, w/2, h )


srf:SetColor(1,0,0,1)	-- Red
srf:DrawRectangle( w/4, h/4, w/2, h/2, 5);

----------------------------

fch,err,msg = srf:Dump("/tmp","Line")
if not fch then	-- An error happened
	print("Can't dump", err, msg);
else
	print("Dumped to", fch);
end

print "Hit 'enter' key to exit"
io.stdin:read'*l'	-- wait for enter
	---
	-- cleanup
	---

srf:Release()
card:Release()
generated by LDoc 1.4.6 Last updated 2022-09-05 22:24:51