Some of my scripts for daily use on a linux desktop

Saturday, June 26, 2010

Text widget, Part 2

I finnaly add some effects to the text widget.
The reflection and the "skew".

All these effects are based upon the cairo.Matrix transform


Let start with a simple text displaying hour with a 3-colours and linear gradient:

text_settings={
{
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
},
}

The output :



Now, I add some reflection :
  {
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
reflection_alpha=1,
},

The reflection start with an opacity of 1 (reflection_alpha=1) and ends with a opacity of 0.


But the reflection can start with an opacity less than 1 (reflection_alpha=0.5 here) :

{
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
reflection_alpha=0.5,
},




With the abvoe parameters, reflection ends at the end of the text size, but it can end before with reflection_length=0.5, it means 50% of the full height of the text

{
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
reflection_alpha=0.5,
reflection_length=0.5,
},




The reflection length can be scaled, a scale of 1 (default value) means the same size of the text, a scale bigger than one means that the reflection is higher of the text:

{
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
reflection_alpha=0.5,
reflection_scale=2,
},




The skew parameter around x axis (I'm not sure of the units for that !):
  {
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
skew_x=20,
},


The skew parameter around y axis
  {
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
skew_y=20,
},



We can combine both
  {
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=50,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
skew_y=-20,
skew_x=-50
,
},


Unfortunately, we can't have a real perspective with cairo .


Finally, we can combine reflection and skew:
  {
text=conky_parse("${time %H:%M:%S}"),
font_name="Rasheeq",
x=50,
y=900,
font_size=50,
colour={{0,0xFF0000,1},{0.5,0xFFFF00,1},{1,0x00FF00,1}},
orientation="nn",
skew_y=-20,
skew_x=-10,
reflection_alpha=0.5
,
},




Links to the updated script :
In English on ubuntu forums : here
French link (copy/paste) : here

And, an example of real life use combined with the piechart widget:

4 comments:

  1. Nice work you've done here! I use your lua widget on my desktop and simply love it! Will link to your blog from now on when mentioning about your scripts.

    Keep up the good work!

    sheers!

    ReplyDelete
  2. Thanks ! I hope to see your own set-up soon !

    ReplyDelete
  3. That is awesome, I am a little bummed that I cannot get it to run on my machine... But you sir have tallent

    ReplyDelete
  4. thanks! If you can't run it, run it in a console and post this output of the console on the ubuntu forums : here

    ReplyDelete