This is the implementation of the classical "Draw a line" tutorial using Séléné framework.
Classical shebang to use Séléné as script interpretor. Obviously, the path has to be changed as per your own installation.
#!./Selene
Tell to Séléné we want to use DirectFB and pass some option to it :
Selene.UseDirectFB("--dfb:quiet,no-vt")
We want whole screen and then we get its primary surface. Unlike other kinds of surface, the primary one is directly linked to the framebuffer memory meaning that drawing and refreshing windows will impact our.
Finally, get its size.
DirectFB.init( DirectFB.CooperativeConst('FULLSCREEN') ) srf = SelSurface.create { caps=SelSurface.CapabilityConst('PRIMARY') } w,h = srf:GetSize()
Clear the surface with black color.
Unlike other drawing methods, Clear() doesn't take in account, drawing/blitting flags or clipping and its color is independent of actual drawing one.
Colors are defined by 3 components : ref, green, blue a usual plus an alpha channel ; 0 for totally transparent and 255 for solid color ... but the surface needs to support it.
srf:Clear(0,0,0,0)
Draw a horizontal gray line and a vertical orange one.
srf:SetColor( 0x80, 0x80, 0x80, 0x80) -- gray srf:DrawLine( 0, h/2, w, h/2 ) srf:SetColor( 0xff, 0x80, 0x80, 0x80) -- Orange srf:DrawLine( w/2, 0, w/2, h )
Wait for user input before closing.
print "Hit 'enter' key to exit" io.stdin:read'*l'
Finaly, clean everything.
srf:destroy()
And the result is :
The full script is part of Séléné distribution or directly in its GIT : https://github.com/destroyedlolo/Selene/blob/master/SelenitesDFB/Lines.sel
Visitez : Nos sorties Ski et rando |
Copyright Laurent Faillie
2001-2024
N'oubliez pas d'entrer le mot de passe pour voir aussi les photos perso. |
Contactez moi si vous souhaitez réutiliser ces photos et pour les obtenir avec une plus grande résolution. |
Visites durant les 7 derniers jours au total. |
Vous pouvez
laissez un commentaire
sur cette page.