Class: CTioga2::Graphics::Styles::ArrowStyle
- Inherits:
-
StrokeStyle
- Object
- BasicStyle
- LineStyle
- StrokeStyle
- CTioga2::Graphics::Styles::ArrowStyle
- Defined in:
- lib/ctioga2/graphics/styles/arrows.rb
Overview
This class represents an arrow
Direct Known Subclasses
Constant Summary collapse
- TiogaDefaults =
{ 'head_marker' => Tioga::MarkerConstants::Arrowhead, 'tail_marker' => Tioga::MarkerConstants::BarThin }
Constants inherited from BasicStyle
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Method Summary collapse
Methods inherited from StrokeStyle
Methods inherited from LineStyle
Methods inherited from BasicStyle
alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other, #use_defaults_from
Instance Method Details
#draw_arrow(t, x1, y1, x2, y2) ⇒ Object
Draws an arrow.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ctioga2/graphics/styles/arrows.rb', line 59 def draw_arrow(t, x1, y1, x2, y2) dx = x2 - x1 dy = y2 - y1 angle = Types::Dimension.get_angle(t, dx, dy) len = Types::Dimension.get_distance(t, dx, dy) rs = symbol_size(t, "head") ls = symbol_size(t, "tail") x1n, y1n, x2n, y2n = *Types::Dimension::adjust_line(t, x1, y1, x2, y2, -ls, -rs) # Must shorten the path first... sv = t.line_cap # This has for effect to disable changing the line cap when # there are now arrows to draw. if ! (has_marker?('head') || has_marker?('tail')) sv = Tioga::FigureConstants::LINE_CAP_BUTT end if sv != Tioga::FigureConstants::LINE_CAP_BUTT t.line_cap = Tioga::FigureConstants::LINE_CAP_BUTT end draw_line(t, x1n, y1n, x2n, y2n) if sv != Tioga::FigureConstants::LINE_CAP_BUTT t.line_cap = sv end # Then, draw the arrow heads/tails draw_symbol(t, 'head', angle, x2, y2) draw_symbol(t, 'tail', angle - 180, x1, y1) end |
#old_draw_arrow(t, x1, y1, x2, y2) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ctioga2/graphics/styles/arrows.rb', line 43 def old_draw_arrow(t, x1, y1, x2, y2) dict = self.to_hash dict.rename_key('width', 'line_width') dict.rename_key('style', 'line_style') dict['head'] = [x2,y2] dict['tail'] = [x1,y1] for w in %w(head tail) if dict["#{w}_marker"] == false dict["#{w}_marker"] = "None" end end t.show_arrow(dict) end |