lib/ctioga2/graphics/elements/primitive.rb in ctioga2-0.9 vs lib/ctioga2/graphics/elements/primitive.rb in ctioga2-0.10
- old
+ new
@@ -112,11 +112,15 @@
primitive = TiogaPrimitive.new(name, comp, opts, &code)
@known_primitives[name] = primitive
# Now, create the command
cmd_args = comp.map do |x|
- CmdArg.new(x)
+ if x.respond_to?(:type)
+ x
+ else
+ CmdArg.new(x)
+ end
end
cmd_opts = {}
for k,v in opts
cmd_opts[k] = if v.respond_to?(:type)
@@ -228,23 +232,10 @@
) do |t, point, string, style, options|
style.draw_string_marker(t, string, *point.to_figure_xy(t))
end
- # options for arrows (and therefore tangents)
- ArrowOptions = {
- 'color' => 'color',
- 'head_scale' => 'float',
- 'head_marker' => 'marker',
- 'head_color' => 'color',
- 'tail_scale' => 'float',
- 'tail_marker' => 'marker',
- 'tail_color' => 'color',
- 'line_width' => 'float',
- 'line_style' => 'line-style',
- }
-
styled_primitive("arrow", "arrow",
[ 'point', 'point' ],
Styles::ArrowStyle,
'arrow') do |t, tail, head, style, options|
style.draw_arrow(t, *( tail.to_figure_xy(t) +
@@ -256,9 +247,20 @@
Styles::StrokeStyle,
'line'
) do |t, tail, head, style, options|
style.draw_line(t, *( tail.to_figure_xy(t) +
head.to_figure_xy(t) ))
+ end
+
+
+ styled_primitive("image", "image",
+ [ CmdArg.new('text', 'file'),
+ CmdArg.new('point', 'top-left'),
+ CmdArg.new('point', 'bottom-right')
+ ],
+ Styles::ImageStyle,
+ 'image') do |t, file, tl, br, style, options|
+ style.draw_image(t, file, tl, br)
end
# Here, we need to add deprecated options for backward
# compatibility