lib/rubyplot/backend/gr_wrapper.rb
def draw_text(text, color:, font: nil, size:,
        font_weight: nil, gravity: nil, abs_x:,abs_y:, rotation: nil,
        halign: nil, valign: nil, font_precision: :high, direction: :left_right,
        abs: true)
        within_window(abs) do |ndc_min_x, ndc_max_x, ndc_min_y, ndc_max_y| 
          if abs
            x = transform_x_ndc abs_x
            y = transform_y_ndc abs_y
          end

          GR.setcharup(*to_gr_rotation_vector(rotation))
          GR.setcharheight(to_gr_font_size(size, ndc_min_y, ndc_max_y))
          GR.settextpath(TEXT_DIRECTION_MAP[direction])
          GR.settextcolorind(to_gr_color(color))
          GR.settextfontprec(TEXT_FONT_MAP[font], TEXT_PRECISION_MAP[font_precision])
          GR.settextalign(TEXT_HALIGNMENT_MAP[halign], TEXT_VALIGNMENT_MAP[valign])
          GR.text(x, y, text)
        end
      end
# Draw text on the canvas.
# TODO: support text with special characters and latex symbols.
Draw text on the canvas.
TODO: support text with special characters and latex symbols.
Draw text on the canvas . TODO : support text with special characters and latex symbols .
def draw_text(text, color:, font: nil, size:,
        font_weight: nil, gravity: nil, abs_x:,abs_y:, rotation: nil,
        halign: nil, valign: nil, font_precision: :high, direction: :left_right,
        abs: true)
        within_window(abs) do |ndc_min_x, ndc_max_x, ndc_min_y, ndc_max_y| 
          if abs
            x = transform_x_ndc abs_x
            y = transform_y_ndc abs_y
          end
          GR.setcharup(*to_gr_rotation_vector(rotation))
          GR.setcharheight(to_gr_font_size(size, ndc_min_y, ndc_max_y))
          GR.settextpath(TEXT_DIRECTION_MAP[direction])
          GR.settextcolorind(to_gr_color(color))
          GR.settextfontprec(TEXT_FONT_MAP[font], TEXT_PRECISION_MAP[font_precision])
          GR.settextalign(TEXT_HALIGNMENT_MAP[halign], TEXT_VALIGNMENT_MAP[valign])
          GR.text(x, y, text)
        end
      end
def draw_text ( text , color : , font : nil , size : , font_weight : nil , gravity : nil , abs_x : , abs_y : , rotation : nil , halign : nil , valign : nil , font_precision : :high , direction : :left_right , abs : true ) within_window ( abs ) do | ndc_min_x , ndc_max_x , ndc_min_y , ndc_max_y | if abs x = transform_x_ndc abs_x y = transform_y_ndc abs_y end GR . setcharup ( * to_gr_rotation_vector ( rotation ) ) GR . setcharheight ( to_gr_font_size ( size , ndc_min_y , ndc_max_y ) ) GR . settextpath ( TEXT_DIRECTION_MAP [ direction ] ) GR . settextcolorind ( to_gr_color ( color ) ) GR . settextfontprec ( TEXT_FONT_MAP [ font ] , TEXT_PRECISION_MAP [ font_precision ] ) GR . settextalign ( TEXT_HALIGNMENT_MAP [ halign ] , TEXT_VALIGNMENT_MAP [ valign ] ) GR . text ( x , y , text ) end end
Draw text on the canvas.
Draw text on the canvas .
text
color
font
size
font_weight
gravity
abs_x
abs_y
rotation
halign
valign
font_precision
direction
abs