lib/ctioga2/graphics/elements/primitive.rb in ctioga2-0.13.1 vs lib/ctioga2/graphics/elements/primitive.rb in ctioga2-0.14
- old
+ new
@@ -159,10 +159,33 @@
PrimitiveCommands[name] = cmd
return primitive_class
end
+
+
+ primitive("legend-pictogram", "legend-pictogram",
+ ["point", "object"], {
+ 'width' => 'dimension'
+ },
+ "Draws the legend pictogram for the given curve"
+ ) do |t, point, obj, opts|
+ al = Types::AlignedPoint::from_point(point)
+ cs = obj.curve_style
+
+ dx = opts['width'] || Types::Dimension.new(:dy, 2.5)
+ # dy = opts['height'] || Types::Dimension.new(:dy, 1)
+ dy = dx*0.4 # I'm not sure it really matters
+ pbb = Types::PointBasedBox.new(al, dx, dy)
+ pbb.within_frames(t) do
+ cs.draw_legend_pictogram(t)
+ end
+ end
+
+
+
+
# This creates a primitive base on a style object, given a
# _style_class_, the base _style_name_ for the underlying
# styling system, options to remove and options to add.
#
# The underlying code receives:
@@ -263,11 +286,12 @@
# @todo Do the same thing for arrows...
styled_primitive("oriented-line", "oriented-line",
[ 'point', 'dimension' ],
Styles::OrientedLineStyle,
'oriented-line'
- ) do |t, org, dim, style, options|
- style.draw_oriented_arrow(t, *org.to_figure_xy(t), dim)
+ ) do |t, org, dim, style, options|
+
+ style.draw_oriented_arrow(t, *(org.to_figure_xy(t) + [dim]))
end
styled_primitive("image", "image",
[ CmdArg.new('text', 'file'),