Circle.sel

#!./Selene
--- Draw a circle in the middle of the screen

Selene.UseDRMCairo()

	-- Open default card.
	-- As no argument is passed it's the default one
	-- /dev/dri/card0
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()	-- Retrieve its size
srf:Clear( 0,0,0 )	-- 100% green and no transparency

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

local r = w/3
if h < w then
	r = h/3
end

math.randomseed( os.time() )

srf:SetColor( 1, 0.5, 0.5 )
srf:DrawArc( w/2, h/2, r, 0, 2*math.pi )	-- Full circle

	-- Quarter
srf:SetColor( 0, 0, 1 )
srf:DrawArc( w/2, h/2, r+05, 0, math.pi/2 )			-- Q1
srf:SetColor( 0, 1, 0 )
srf:DrawArc( w/2, h/2, r+10, math.pi/2, math.pi )	-- Q2
srf:SetColor( 0, 1, 1 )
srf:DrawArc( w/2, h/2, r+15, math.pi, 3*math.pi/2 )	-- Q3
srf:SetColor( 1, 0, 0 )
srf:DrawArc( w/2, h/2, r+20, 3*math.pi/2, 2*math.pi )	-- Q4

	-- Filled Quarter
srf:FillArc( w/2, h/2, r-15, 0, math.pi/2 )

srf:SetColor( 1, 1, 0, 0.5 )
srf:FillArc( w/2, h/2, r-15, math.random()*2*math.pi, math.random()*2*math.pi )

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

fch,err,msg = srf:Dump("/tmp","Gfx")
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