Module: CTioga2::Graphics::Elements::Contours

Defined in:
lib/ctioga2/graphics/elements/contour.rb

Constant Summary collapse

ContoursOptions =
{
  'width' => 'float',
  'color' => 'color',
  'style' => 'line-style',
  'closed' => 'boolean',
}

Instance Method Summary collapse

Instance Method Details

#contourObject

TODO:

Maybe this cumbersome level/point thing along with the

$last_curve_style calls for a context for the primitive, ie which was the state of the dataset/curve stack at the moment when the primitive was drawn ?

Worse, I already designed something better. I’ll need to get that straight some day.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ctioga2/graphics/elements/contour.rb', line 40

TiogaPrimitiveCall.
  primitive("contour", "contour", [ 'level'],
            ContoursOptions) do |t, level,options|
  options ||= {}
  # table = PlotMaker.plotmaker.data_stack.last.indexed_table
  l, d = *level
  table = d.indexed_table
  contour = table.make_contour(l)
  contour << options['closed']

  ## @todo This $last_curve_style isn't beautiful.
  ##
  ## Worse, it won't work !
  options['color'] ||= $last_curve_style.line.color

  stroke_style = Styles::StrokeStyle.from_hash(options, '%s')
  

  t.context do 
    stroke_style.set_stroke_style(t)
    t.append_points_with_gaps_to_path(*contour)
    t.stroke
  end
end