Class: CTioga2::Graphics::Styles::FillStyle

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

Overview

TODO:

This class should also provide image-based fills, with

A style that handles drawing a fill.

todo add ways to specify complex fills, such as patterned fills and so on. Those would use clipping the path and base themselves on the coordinates of the current frame – or more nicely use dimensions ? (which would allow to mix both to some extent ?)

todo more attributes ?

CSS-like capacities (scaling, tiling, centering, and so on…)

Direct Known Subclasses

CurveFillStyle

Constant Summary

Constants inherited from BasicStyle

BasicStyle::AllStyles, BasicStyle::OldAttrAccessor

Instance Method Summary collapse

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

#do_fill(t) ⇒ Object

Does the actual filling step. Must be used within a context, as it quite messes up with many things. Must be called after a call to #setup_fill.



246
247
248
249
250
251
252
253
# File 'lib/ctioga2/graphics/styles/fill.rb', line 246

def do_fill(t)
  if @pattern  && @color
    t.clip
    @pattern.do(t, @color)
  else
    t.fill
  end
end

#setup_fill(t) ⇒ Object

Sets up the parameters for the fill. Must be called before any path drawing.

warning You must call FillStyle#do_fill for filling. Directly calling FigureMaker#fill is not a good idea, as you lose all ‘hand-crafted’ fills !



236
237
238
239
240
241
# File 'lib/ctioga2/graphics/styles/fill.rb', line 236

def setup_fill(t)
  if ! @pattern
    t.fill_color = @color if @color
    t.fill_transparency = @transparency if @transparency
  end
end