Class: CTioga2::Graphics::Styles::MarkerStyle

Inherits:
BasicStyle
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/drawable.rb

Overview

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

todo many things are still missing here…

  • in particular, angles could be handled here, and they could be handled directly in the marker specification…

Constant Summary

Constants inherited from BasicStyle

BasicStyle::OldAttrAccessor

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicStyle

attr_accessor, attributes, from_hash, #instance_variable_defined?, #set_from_hash, #to_hash, #update_from_other

Instance Attribute Details

#colorObject

The color



57
58
59
# File 'lib/ctioga2/graphics/styles/drawable.rb', line 57

def color
  @color
end

#markerObject

The marker



60
61
62
# File 'lib/ctioga2/graphics/styles/drawable.rb', line 60

def marker
  @marker
end

#scaleObject

The marker scale



63
64
65
# File 'lib/ctioga2/graphics/styles/drawable.rb', line 63

def scale
  @scale
end

Instance Method Details

#draw_markers_at(t, x, y, override = nil) ⇒ Object

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

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



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/ctioga2/graphics/styles/drawable.rb', line 69

def draw_markers_at(t, x, y, override = nil)
  t.context do
    ## \todo allow custom line types for markers ?
    t.line_type = LineStyles::Solid
    dict = { 
      'marker' => @marker, 
      'color' => @color
    }
    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.show_marker(dict)
  end
end