Thursday, October 14, 2010

Final Fantsy VII

I am a big final fantasy 7 fan, so when rabidofx posted a FF7 themed conky, I immediately thought of the potential to turn the FF7 bottom combat panel into a conky display.

And this is what I eventually came up with!



I have tried to be as faithful as I can to the FF7 panel while still allowing the conky to function as a source of information.

It still needs some work and the script needs a good cleanup and improvements to make it more user friendly. You can get the code here at conky-pitstop! Or here on the crunchbanglinux forum. While your on the forum check out rabidfox's post directly above. He has modified ADcomps Adeskbar to look like materia slots (very nice!).

So why does it take 2200 lines of lua code to produce my FF7 panel conky?
Well 3 reasons... first because it's just a little messy. A lot of copying and pasting went on and I'm sure that I could comb through it an eliminate a large number of supurflouous lines :)

Second drawing in lua with the cairo library takes a lot of lines. To draw the blue shaded rectangles required this:
sa=5
sd=5
rh=120
rw=280
red=1
green=1
blue=1
alpha=1
pat = cairo_pattern_create_linear (sa, sd, rh, rw)
cairo_pattern_add_color_stop_rgba (pat, 0, red-1, green-1, blue, alpha)
cairo_pattern_add_color_stop_rgba (pat, 1, red-1, green-1, blue-1, alpha)
cairo_set_source (cr, pat)
cairo_rectangle (cr, sa, sd, rw, rh)
cairo_fill (cr)
I could have used less lines and specified the positions and colors etc in the actual pattern and drawing lines, but this way is just so much easier for fine tuning. I set the colors up like this becasue I kept forgetting which number represented what in the cairo_set_pattern lines! :)

The grey border around the blue was also line intensive.

Reason 3, and perhaps the main reason for the length of the script is the way you have to use cairo to display text. And if you look closely you will see that every piece of text has a black "shadow" ...which is simply the same piece of text, colored black and printed behind and offset a little.

font="Acknowledge TT (BRK)"
text=topl1
fsize=20
red=0
green=0
blue=0
alpha=1
across=32
down=22
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fsize);
cairo_set_source_rgba (cr, red, green, blue, alpha);
cairo_move_to (cr, across, down);
cairo_show_text (cr, text)
red=0.8
green=0.8
blue=0.8
alpha=1
across=across-2
down=down-2
cairo_set_source_rgba (cr, red, green, blue, alpha);
cairo_move_to (cr, across, down);
cairo_show_text (cr, text)
So I had to set the font, set the font size, set the red, green, blue and alpha, set the position, write the font, fontsize and color setup lines, move cairo to the coordinates and then tell it to diaplay the text. That gave me the shadow, then I had to change the color and position, set up the text drawing variables and draw the main text.

I kept this format throughout the script, so i could easily change colors and positions without wading through a sea of setup lines.

No comments:

Post a Comment