class CTioga2::Graphics::Styles::MarkerStyle

This class represents all the stylistic information to draw a Marker.

todo many things are still missing here…

Public Instance Methods

draw_markers_at(t, x, y, override = nil) click to toggle source

Shows the marker at a given location/set of locations.

p override is a hash that can override part of the dictionnary specification.

# File lib/ctioga2/graphics/styles/drawable.rb, line 101
def draw_markers_at(t, x, y, override = nil)
  return if (! @marker || @marker == 'None')

  dict = { 
    'marker' => @marker
  }
  if @line_width
    dict['stroke_width'] = @line_width
  end
  if !(@fill_color.nil?) || !(@line_color.nil?)
    dict['fill_color'] = @fill_color.nil? ? @color : @fill_color
    dict['stroke_color'] = @line_color.nil? ? @color : @line_color
    dict['rendering_mode'] = 
      if dict['fill_color']
        if dict['stroke_color']
          Tioga::FigureConstants::FILL_AND_STROKE
        else
          Tioga::FigureConstants::FILL
        end
      else
        Tioga::FigureConstants::STROKE
      end
    dict.strip_if_false!(%w{fill_color stroke_color})
  else
    dict['color'] = @color
    if ! @color
      return            # Nothing to do !
    end
  end
  if @angle
    dict['angle'] = @angle
  end
  
  if x.is_a? Numeric
    dict['x'] = x
    dict['y'] = y
  else
    dict['Xs'] = x
    dict['Ys'] = y
  end

  if @scale
    dict['scale'] = @scale
  end
  if override
    dict.merge!(override)
  end
  t.context do
    ## \todo allow custom line types for markers ?
    t.line_type = LineStyles::Solid
    t.show_marker(dict)
  end
end