Où sommes nous ?



Séléné implements very simple kind of gradients : they took a whole surface and you can only corners colors. Very basic isn't it, but combined with transparency and other drawing tools, the result shall be very fancy.


As said above, it's the geometry of the surface that determines the size of the gradient. Let's create a surface that takes as usual the whole screen :

srf = SelSurface.create { caps=SelSurface.CapabilityConst('PRIMARY') }
w,h = srf:GetSize()

Now, we can draw on it our gradient

srf:FillGrandient { 
TopLeft={255,255,255,255}, -- white
TopRight={255,0,0,255}, -- Red
BottomLeft={0,255,0,255}, -- Green
BottomRight={0,0,255,255} --Blue

for the following result

Specifying only 2 corners will create simple horizontal or vertical gradients.

srf:FillGrandient { TopLeft={255,255,255,255}, TopRight={255,0,0,255} }

Notez-bien : there is stricly no difference to specify top or bottom corners.

The same for vertical one :

srf:FillGrandient { TopLeft={255,255,255,255}, BottomLeft={255,0,0,255} }

As of Séléné 3.10.0, it's not possible to create diagonal gradients only by specifying 2 points (because underlying algorithm is not efficient) : then the solution is to create the 2 missing points with your background color, black in my example.

srf:FillGrandient { TopLeft={255,0,0,255}, TopRight={0,0,0,0}, BottomLeft={0,0,0,0}, BottomRight={0,255,0,255} }

Caution : as you can see in the screenshot above, the image is a bit darker. The result will be better if the surface handles transparency.

Visitez :
La liste de nos voyages
Nos sorties Ski et rando
Copyright Laurent Faillie 2001-2018
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 Nombre de visites au total.

Vous pouvez laissez un commentaire sur cette page.