Class: XRVG::Filter
Overview
Filter class
Intro
Filter class allows to call generically a method with arg between 0.0..0.1 on a given object, for use in a FloatFunctor
context.
Example
this allow to do for example
[bezier1.filter(:point), bezier1.filter(:tangent), palette].samples( 10 ) do |point, tangent, color|
Direct Known Subclasses
AlternateFilter, GeoFullFilter, RandomFilter, ShuffleFilter, SortFilter
Class Method Summary collapse
-
.with(&block) ⇒ Object
shortcut method aliasing Filter.new( nil, nil, &block).
Instance Method Summary collapse
-
#initialize(object = nil, samplemethod = :sample, &block) ⇒ Filter
constructor
to define a filter on “object” with method “samplemethod”, or with a block (exclusive).
-
#transform(abs) ⇒ Object
Samplable redefinition : call previous proc built from initialize to process float “abs”.
Methods included from Samplable
#apply_sample, #apply_samples, build, #mean, #sample, #samples
Methods included from FloatFunctor
#addfilter, #alternate, #apply, #applyhash, #compute, #filter, #generate, #geo, #geofull, #modify, #process, #random, #shuffle, #sin, #ssort, #transforms, #trigger
Constructor Details
#initialize(object = nil, samplemethod = :sample, &block) ⇒ Filter
to define a filter on “object” with method “samplemethod”, or with a block (exclusive)
from these two alternatives, returns a proc to call for float processing
316 317 318 319 320 321 322 323 |
# File 'lib/samplation.rb', line 316 def initialize(object=nil, samplemethod=:sample, &block) if object # Trace("Filter::initialize object #{object.inspect} method #{samplemethod.inspect} ") @proc = object.method( samplemethod ) else @proc = Proc.new( &block ) end end |
Class Method Details
.with(&block) ⇒ Object
shortcut method aliasing Filter.new( nil, nil, &block)
must change the name, because “with” seems to refer to LISP “with” design pattern, and this is not the case here
335 336 337 |
# File 'lib/samplation.rb', line 335 def Filter.with( &block ) return Filter.new( nil, nil, &block) end |
Instance Method Details
#transform(abs) ⇒ Object
Samplable redefinition : call previous proc built from initialize to process float “abs”
326 327 328 329 330 |
# File 'lib/samplation.rb', line 326 def transform( abs ) result = @proc.call( abs ) # Trace("Filter::transform abs #{abs} result #{result.inspect}") return result end |