Method: Legend#draw_title
- Defined in:
- lib/legend.rb
#draw_title(x_pos, y_pos, value, r, g, b, x_pos2 = -1,, y_pos2 = -1,, shadow = false) ⇒ Object
This function is used to write the graph title. Used with default parameters you must specify the bottom left position of the text. if you are specifying x2 and y2 the text will be centered horizontaly and verticaly in the box of coordinates (x1,y1)-(x2,y2). value correspond to the text that will be written on the graph. r, g and b are used to set the text color. Setting shadow to true will makes a shadow behind the text.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/legend.rb', line 109 def draw_title(x_pos,y_pos,value,r,g,b,x_pos2=-1,y_pos2=-1,shadow=false) c_text_color = allocate_color(@picture, r, g, b) if ( x_pos2 != -1 ) position = image_ftb_box(@font_size,0,@font_name,value) text_width = position[2]-position[0] x_pos =(( x_pos2 - x_pos -text_width ) / 2 ).floor + x_pos end if ( y_pos2 != -1 ) position = image_ftb_box(@font_size,0,@font_name,value) text_height = position[5]-position[3] y_pos =(( y_pos2 - y_pos - text_height ) / 2 ).floor + y_pos end if ( shadow ) c_shadow_color = allocate_color(@picture,@shadow_r_color,@shadow_g_color,@shadow_b_color) image_ttf_text(@picture,@font_size,0,x_pos+@shadow_x_distance,y_pos+@shadow_y_distance, c_shadow_color ,@font_name,value) end image_ttf_text(@picture,@font_size,0,x_pos,y_pos,c_text_color,@font_name,value) end |