@@ -16,28 +16,6 @@ def initialize
1616 @draw = Magick ::Draw . new
1717 end
1818
19- # Returns the height of the capital letter 'X' for the current font and
20- # size.
21- #
22- # Not scaled since it deals with dimensions that the regular scaling will
23- # handle.
24- def caps_height ( font , font_size )
25- @draw . pointsize = font_size
26- @draw . font = font if font
27- @draw . get_type_metrics ( @base_image , 'X' ) . height
28- end
29-
30- # Returns the width of a string at this pointsize.
31- #
32- # Not scaled since it deals with dimensions that the regular
33- # scaling will handle.
34- # FIXME: duplicate with get_text_width_height
35- def string_width ( font , font_size , text )
36- @draw . pointsize = font_size
37- @draw . font = font if font
38- @draw . get_type_metrics ( @base_image , text . to_s ) . height
39- end
40-
4119 # Height in pixels of particular text.
4220 # @param text [String] Text to be measured.
4321 def text_height ( text , font , font_size )
@@ -73,41 +51,43 @@ def get_text_width_height(text)
7351 # Unused method argument - stroke
7452 def draw_text ( text , font_color :, font : nil , pointsize :,
7553 font_weight : Magick ::NormalWeight , gravity : nil ,
76- x_pos : , y_pos :, rotation : nil )
54+ x : , y :, rotation : nil , stroke : 'transparent' )
7755 @draw . fill = font_color
7856 @draw . font = font if font
7957 @draw . pointsize = pointsize
8058 @draw . font_weight = font_weight
8159 @draw . gravity = GRAVITY_MEASURE [ gravity ] || Magick ::ForgetGravity
60+ @draw . stroke stroke
61+ @draw . stroke_antialias true
8262 @draw . rotation = rotation if rotation
83- @draw . annotate ( @base_image , 0 , 0 , x_pos . to_i , y_pos . to_i , text . gsub ( '%' , '%%' ) )
63+ @draw . annotate ( @base_image , 0 , 0 , x . to_i , y . to_i , text . gsub ( '%' , '%%' ) )
8464 @draw . rotation = 90.0 if rotation
8565 end
8666
8767 # Draw a rectangle.
88- def draw_rectangle ( x01 : , y01 : , x02 : , y02 :, border_color : '#000000' , stroke : 'transparent' ,
68+ def draw_rectangle ( x1 : , y1 : , x2 : , y2 :, border_color : '#000000' , stroke : 'transparent' ,
8969 fill_color : nil , stroke_width : 1.0 )
9070 if fill_color # solid rectangle
9171 @draw . stroke stroke
9272 @draw . fill fill_color
9373 @draw . stroke_width stroke_width
94- @draw . rectangle x01 , y01 , x02 , y02
74+ @draw . rectangle x1 , y1 , x2 , y2
9575 else # just edges
9676 @draw . stroke_width stroke_width
9777 @draw . fill border_color
98- @draw . line x01 , y01 , x01 + ( x02 - x01 ) , y01 # top line
99- @draw . line x01 + ( x02 - x01 ) , y01 , x02 , y02 # right line
100- @draw . line x02 , y02 , x01 , y01 + ( y02 - y01 ) # bottom line
101- @draw . line x01 , y01 , x01 , y01 + ( y02 - y01 ) # left line
78+ @draw . line x1 , y1 , x1 + ( x2 - x1 ) , y1 # top line
79+ @draw . line x1 + ( x2 - x1 ) , y1 , x2 , y2 # right line
80+ @draw . line x2 , y2 , x1 , y1 + ( y2 - y1 ) # bottom line
81+ @draw . line x1 , y1 , x1 , y1 + ( y2 - y1 ) # left line
10282 end
10383 end
10484
105- def draw_line ( x01 : , y01 : , x02 : , y02 :, color : '#000000' , stroke : 'transparent' ,
85+ def draw_line ( x1 : , y1 : , x2 : , y2 :, color : '#000000' , stroke : 'transparent' ,
10686 stroke_opacity : 0.0 , stroke_width : 2.0 )
10787 @draw . stroke_opacity stroke_opacity
10888 @draw . stroke_width stroke_width
10989 @draw . fill color
110- @draw . line x01 , y01 , x02 , y02
90+ @draw . line x1 , y1 , x2 , y2
11191 end
11292
11393 def draw_circle ( x_pos :, y_pos :, radius :, stroke_opacity :, stroke_width :, color :)
0 commit comments