Code:
--[[ the post: http://crunchbanglinux.org/forums/post/55927/#p55927
this one was easy (or i thought it was going to be)
http://omploader.org/tM2x0bg
Going to be a work in progress until i set up all the variables properly... and get my titles right smile
UPDATE- now you can change line thickness without messing it up. Getting the lines right has made things alot less easy smile
also you can set font, font size and title position
-- end the post
isometric bars by mrpeachy (2012)
updated by mrpeachy 15 Oct 2012
--]]
require 'cairo'
function bar3d(conkyobject, linethick, width, barheight, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
--line 1 settings end
local a_num1=tonumber(conkyobject) or 0
local a_num=(height/100)*a_num1
--indicator
if direction==nil then direction="r" end
if direction=="r" then
isoadjust=width*-0.5
elseif direction=="l" then
isoadjust=width*0.5
end
--point 1 - bottom left
x1,y1=0,0
--point 2 - bottom right
x2,y2=x1+width,y1
--point 3 - middle left
x3,y3=x1,-a_num
--point 4 - middle right
x4,y4=x2,y3
--point 5 - iso left
x5,y5=x1+isoadjust,y1+(width*-0.5)
--point 6 - iso right
x6,y6=x5+width,y5
--point 7 - top left
x7,y7=x5,y5-a_num
--point 8 - top right
x8,y8=x7+width,y7
--##################################
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_width (cr,linethick)
if framelines == 1 then
--back lines
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_save(cr)
cairo_translate (cr, across, down)
cairo_move_to (cr,x5,y5)
cairo_line_to (cr,x5,y5-height)
cairo_line_to (cr,x6,y6-height)
cairo_line_to (cr,x6,y6)
cairo_close_path (cr)
cairo_stroke (cr)
cairo_restore (cr)
end
cairo_save (cr)
cairo_translate (cr, across, down)
--bottom
cairo_move_to (cr,x1,y1)
cairo_line_to (cr,x2,y2)
cairo_line_to (cr,x6,y6)
cairo_line_to (cr,x5,y5)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
--back
cairo_move_to (cr,x7,y7)
cairo_line_to (cr,x5,y5)
cairo_line_to (cr,x6,y6)
cairo_line_to (cr,x8,y8)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
--iso side left
cairo_move_to (cr,x7,y7)
cairo_line_to (cr,x3,y3)
cairo_line_to (cr,x1,y1)
cairo_line_to (cr,x5,y5)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
--iso side right
cairo_move_to (cr,x8,y8)
cairo_line_to (cr,x4,y4)
cairo_line_to (cr,x2,y2)
cairo_line_to (cr,x6,y6)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
--top
cairo_move_to (cr,x3,y3)
cairo_line_to (cr,x7,y7)
cairo_line_to (cr,x8,y8)
cairo_line_to (cr,x4,y4)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
--front
cairo_move_to (cr,x1,y1)
cairo_line_to (cr,x2,y2)
cairo_line_to (cr,x4,y4)
cairo_line_to (cr,x3,y3)
cairo_close_path (cr)
cairo_set_source_rgba (cr, facered, facegreen, faceblue, facealpha);
cairo_fill_preserve (cr)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
cairo_stroke (cr)
cairo_restore (cr)
if framelines == 1 then
--frame lines
cairo_save (cr)
cairo_translate (cr, across, down)
cairo_set_source_rgba (cr, linered, linegreen, lineblue, linealpha);
--front
cairo_move_to (cr,x1,y1)
cairo_line_to (cr,x1,y1-height)
cairo_line_to (cr,x2,y2-height)
cairo_line_to (cr,x2,y2)
cairo_close_path (cr)
cairo_stroke (cr)
--top
cairo_move_to (cr,x1,y1-height)
cairo_line_to (cr,x5,y5-height)
cairo_line_to (cr,x6,y6-height)
cairo_line_to (cr,x2,y2-height)
cairo_close_path (cr)
cairo_stroke (cr)
cairo_restore (cr)
end--if framelines
--title
cairo_select_font_face (cr, font, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_set_font_size (cr, fontsize);
cairo_set_source_rgba (cr, (txtred or linered),(txtgreen or linegreen),(txtblue or lineblue),(txtalpha or linealpha));
cairo_move_to (cr, txtacross, txtdown)
cairo_show_text (cr, title)
cairo_stroke (cr)
end--isometric drawing function
function conky_draw_shape ()
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num > 5 then
if conky_window==nil then return end
local w=conky_window.width
local h=conky_window.height
local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
cr=cairo_create(cs)
-- ROOT
--conkyobject=conky_parse('${fs_used_perc /}')
--linethick=0.5 --1.25 --1.5
--width=20
--height=140
--linered=1.0
--linegreen=0.0
--lineblue=0.0
--linealpha=1.0
--facered=0.0
--facegreen=0.0
--faceblue=1.0
--facealpha=0.3
--across=50
--down=200
--text formatting
--title="Root"
--font="White Rabbit"
--fontsize=14
--txtred=0.5
--txtgreen=1.0
--txtblue=0.0
--txtalpha=1.0
--txtacross=50
--txtdown=220
--1 for framelines, 0 for none
--framelines=1
--face direction "r" or "l"
--direction="r"
--bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, --fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- HOME
conkyobject=conky_parse('${fs_used_perc /home}')
linethick=0.5 --1.25 --1.5
width=20
height=140
linered=1.0
linegreen=0.0
lineblue=0.0
linealpha=1.0
facered=0.0
facegreen=0.0
faceblue=1.0
facealpha=0.3
across=50
down=200
--text formatting
title="Home"
font="Kimberley"
fontsize=14
fontsize=14
txtred=1
txtgreen=1
txtblue=0
txtalpha=1
txtacross=50
txtdown=220
--1 for framelines, 0 for none
framelines=1
--face direction "r" or "l"
direction="l"
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- MEDIA/5
--conkyobject=conky_parse('${fs_used_perc /home}')
--linethick=0.25
--width=40
--height=150
--linered=1.0
--linegreen=1.0
--lineblue=1.0
--linealpha=0.5
--facered=0.5
--facegreen=0.5
--faceblue=0.5
--facealpha=1.0
--across=190
--down=200
--text formatting
--title="HOME"
--font="White Rabbit"
--fontsize=14
--txtred=1
--txtgreen=1
--txtblue=0
--txtalpha=1
--txtacross=190
--txtdown=220
--1 for framelines, 0 for none
--framelines=1
--face direction "r" or "l"
--direction="l"
--bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, --fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- MEMORY
conkyobject=conky_parse('${memperc}')
linethick=0.5 --1.25 --1.5
width=20
height=140
linered=0.1
linegreen=1.0
lineblue=0.1
linealpha=1.0
facered=0.9
facegreen=0.5
faceblue=0.0
facealpha=0.3
across=400
down=200
--text formatting
title="Ram"
font="Kimberley"
fontsize=12
txtred=1
txtgreen=1
txtblue=0
txtalpha=1
txtacross=400
txtdown=220
--1 for framelines, 0 for none
framelines=1
--face direction "r" or "l"
direction="l"
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- CPU O (Average of all)
conkyobject=conky_parse('${cpu cpu0}')
linethick=0.5
width=20
height=140
linered=0.0
linegreen=0.0
lineblue=1.0
linealpha=1
facered=0.7
facegreen=0.2
faceblue=0.6
facealpha=1.0
across=345
down=200
--text formatting
title="CPU 1 + 2"
font="Kimberley"
fontsize=10
txtred=1
txtgreen=1
txtblue=0
txtalpha=1
txtacross=345
txtdown=220
--1 for framelines, 0 for none
framelines=1
--face direction "r" or "l"
direction="l"
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- CPU 1
conkyobject=conky_parse('${cpu cpu1}')
linethick=0.5 --1.25 --1.5
width=20
height=140
linered=0.1
linegreen=1.0
lineblue=0.1
linealpha=1
facered=1.0
facegreen=0.0
faceblue=0.0
facealpha=0.3
across=120
down=200
--text formatting
title="CPU1"
font="Kimberley"
fontsize=12
txtred=1
txtgreen=1
txtblue=0
txtalpha=1
txtacross=120
txtdown=220
--1 for framelines, 0 for none
framelines=1
--face direction "r" or "l"
direction="l"
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- CPU 2
conkyobject=conky_parse('${cpu cpu2}')
linethick=0.5 --1.25 --1.5
width=20
height=140
linered=0.1
linegreen=1.0
lineblue=0.1
linealpha=1
facered=1.0
facegreen=0.0
faceblue=0.0
facealpha=0.3
across=290
down=200
--text formatting
title="CPU2"
font="Kimberley"
fontsize=12
txtred=1
txtgreen=1
txtblue=0
txtalpha=1
txtacross=290
txtdown=220
--1 for framelines, 0 for none
framelines=1
--face direction "r" or "l"
direction="l"
bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
-- CPU 3
--conkyobject=conky_parse('${cpu cpu3}')
--linethick=0.5 --1.25 --1.5
--width=40
--height=150
--linered=0.1
--linegreen=0.1
--lineblue=0.1
--linealpha=1.0
--facered=1.0
--facegreen=0.0
--faceblue=0.0
--facealpha=1.0
--across=260
--down=400
--text formatting
--title="CPU3"
--font="White Rabbit"
--fontsize=14
--txtred=1
--txtgreen=1
--txtblue=0
--txtalpha=1
--txtacross=260
--txtdown=420
--1 for framelines, 0 for none
--framelines=1
--face direction "r" or "l"
--direction="l"
--bar3d(conkyobject, linethick, width, height, linered, linegreen, lineblue, linealpha, facered, facegreen, faceblue, facealpha, across, down, title, framelines, font, --fontsize, txtacross, txtdown, txtred, txtblue, txtgreen, txtalpha, direction)
end
cairo_surface_destroy(cs)
cairo_destroy(display)
end
Have a good conky
Bookmarks