class CTioga2::Graphics::Styles::OrientedLineStyle

This class represents all the stylistic information necessary to draw a line parallel to a certain direction, indicated by an angle (default to horizontal)

Public Instance Methods

draw_oriented_arrow(t, xo, yo, len) click to toggle source

len is a dimension

# File lib/ctioga2/graphics/styles/arrows.rb, line 170
def draw_oriented_arrow(t, xo, yo, len)

  angle = @angle || 0.0

  dx,dy = *len.to_figure(t, angle)

  case @origin || Tioga::FigureConstants::LEFT_JUSTIFIED
  when Tioga::FigureConstants::LEFT_JUSTIFIED
    x1, y1 = xo, yo
    x2, y2 = xo + dx, yo + dy
  when Tioga::FigureConstants::CENTERED
    x1, y1 = xo - 0.5 * dx, yo - 0.5 * dy
    x2, y2 = xo + 0.5 * dx, yo + 0.5 * dy
  when Tioga::FigureConstants::RIGHT_JUSTIFIED
    x1, y1 = xo - dx, yo - dy
    x2, y2 = xo, yo
  end
  
  draw_arrow(t, x1, y1, x2, y2)
end