Class: Vizcore::DSL::LayerBuilder

Inherits:
Object
  • Object
show all
Includes:
ColorHelpers, LayoutHelpers
Defined in:
lib/vizcore/dsl/layer_builder.rb

Overview

Builder for one render layer in a scene.

Defined Under Namespace

Classes: ShapeReference

Constant Summary collapse

NO_ARGUMENT =
Object.new.freeze
SHAPE_SCHEMA_VERSION =
2
MAPPING_SOURCE_KINDS =
%i[
  amplitude peak frequency_band frequency_band_peak fft_spectrum onset kick snare hihat beat beat_confidence beat_pulse beat_count bpm
  beat_phase beat_2 beat_4 beat_8 beat_triplet triplet bar_phase bar_count phrase_count bpm_confidence
  spectral_centroid spectral_rolloff spectral_flatness spectral_flux zero_crossing_rate global lfo adsr envelope
].freeze
PATH_DEFAULT_DETAIL =
32
PATH_MIN_DETAIL =
4
PATH_MAX_DETAIL =
128
PATH_DEFAULT_MAX_SEGMENTS =
4096
SHAPE_TARGET_ALIASES =
{
  "translate_x" => "transform.translate.x",
  "translate_y" => "transform.translate.y",
  "rotate" => "transform.rotate",
  "rotation" => "transform.rotate",
  "scale" => "transform.scale",
  "scale_x" => "transform.scale.x",
  "scale_y" => "transform.scale.y",
  "origin_x" => "transform.origin.x",
  "origin_y" => "transform.origin.y"
}.freeze
SHAPE_STYLE_KEYS =
Vizcore::Shape::STYLE_KEYS
SHAPE_TRANSFORM_KEYS =
%i[translate rotate rotation scale origin].freeze
STRICT_PARAM_ALLOWLIST =
%i[
  custom_shape_controls custom_shapes glsl_source group origin rotate scale translate
].freeze

Instance Method Summary collapse

Methods included from LayoutHelpers

#circle_pack, #grid, #radial, #scatter, #spiral

Methods included from ColorHelpers

#gradient, #hsl, #hsv

Constructor Details

#initialize(name:, styles: {}, defaults: {}, mapping_presets: {}, strict: false) ⇒ LayerBuilder

Returns a new instance of LayerBuilder.

Parameters:

  • name (Symbol, String)

    layer identifier

  • styles (Hash) (defaults to: {})

    reusable layer parameter styles

  • defaults (Hash) (defaults to: {})

    default params applied before layer-specific values

  • strict (Boolean) (defaults to: false)

    true when unknown layer params should fail

  • mapping_presets (Hash) (defaults to: {})

    reusable mapping presets



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/vizcore/dsl/layer_builder.rb', line 66

def initialize(name:, styles: {}, defaults: {}, mapping_presets: {}, strict: false)
  @name = name.to_sym
  @styles = styles
  @mapping_presets = mapping_presets
  @strict = !!strict
  @type = nil
  @shader = nil
  @glsl = nil
  @params = deep_dup(defaults)
  @param_schema = {}
  @mappings = []
  @shape_index_by_id = {}
  @shape_group_stack = [{}]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Stores dynamic one-argument setters into ‘params`.



989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
# File 'lib/vizcore/dsl/layer_builder.rb', line 989

def method_missing(method_name, *args, &block)
  if @current_shape && block.nil? && args.length == 1
    @current_shape[method_name.to_sym] = args.first
    return args.first
  end

  if @current_custom_shape && block.nil? && args.length == 1
    @current_custom_shape[:params][method_name.to_sym] = args.first
    return args.first
  end

  if in_shape_group? && block.nil? && args.length == 1
    current_shape_group[method_name.to_sym] = args.first
    return args.first
  end

  if block.nil? && args.length == 1
    @params[method_name.to_sym] = args.first
    return args.first
  end

  super
end

Instance Method Details

#adsr(source = :kick, attack: 0.02, decay: 0.08, sustain: 0.7, release: 0.16, threshold: 0.0, peak: 1.0) ⇒ Hash

Returns source descriptor for an ADSR envelope.

Parameters:

  • source (Symbol, Hash) (defaults to: :kick)

    source to trigger the envelope

  • attack (Numeric) (defaults to: 0.02)

    seconds from 0.0 to peak

  • decay (Numeric) (defaults to: 0.08)

    seconds from peak to sustain

  • sustain (Numeric) (defaults to: 0.7)

    sustain gain once decay is complete (0.0..1.0)

  • release (Numeric) (defaults to: 0.16)

    seconds from sustain to 0.0

  • threshold (Numeric) (defaults to: 0.0)

    value threshold that starts attack

  • peak (Numeric) (defaults to: 1.0)

    peak gain multiplier

Returns:

  • (Hash)

    source descriptor for an ADSR envelope



949
950
951
952
953
954
955
956
957
958
959
960
961
# File 'lib/vizcore/dsl/layer_builder.rb', line 949

def adsr(source = :kick, attack: 0.02, decay: 0.08, sustain: 0.7, release: 0.16, threshold: 0.0, peak: 1.0)
  source_value = source.nil? ? { kind: :kick } : normalize_source(source)
  mapping_source(
    :adsr,
    source: source_value,
    attack: normalize_non_negative_float(attack, :attack),
    decay: normalize_non_negative_float(decay, :decay),
    sustain: clamp(normalize_float(sustain, :sustain), 0.0, 1.0),
    release: normalize_non_negative_float(release, :release),
    threshold: normalize_float(threshold, :threshold),
    peak: normalize_float(peak, :peak)
  )
end

#align(value) ⇒ Symbol

Parameters:

  • value (Symbol, String)

    text alignment (‘left`, `center`, `right`)

Returns:

  • (Symbol)

Raises:

  • (ArgumentError)


313
314
315
316
317
318
# File 'lib/vizcore/dsl/layer_builder.rb', line 313

def align(value)
  alignment = value.to_sym
  raise ArgumentError, "unsupported text align: #{value.inspect}" unless %i[left center right].include?(alignment)

  @params[:align] = alignment
end

#amplitudeHash

Returns source descriptor for overall amplitude.

Returns:

  • (Hash)

    source descriptor for overall amplitude



705
706
707
# File 'lib/vizcore/dsl/layer_builder.rb', line 705

def amplitude
  mapping_source(:amplitude)
end

#arc_to(rx, ry, rotation, large_arc, sweep, x, y) ⇒ Object



574
575
576
# File 'lib/vizcore/dsl/layer_builder.rb', line 574

def arc_to(rx, ry, rotation, large_arc, sweep, x, y)
  append_path_command("A", rx, ry, rotation, large_arc, sweep, x, y)
end

#bar_count(value = NO_ARGUMENT) ⇒ Hash

Returns source descriptor for completed 4-beat bars.

Returns:

  • (Hash)

    source descriptor for completed 4-beat bars



879
880
881
882
883
# File 'lib/vizcore/dsl/layer_builder.rb', line 879

def bar_count(value = NO_ARGUMENT)
  return @params[:bar_count] = Integer(value) unless value.equal?(NO_ARGUMENT)

  mapping_source(:bar_count)
end

#bar_phaseHash

Returns source descriptor for 0.0..1.0 phase within the current 4-beat bar.

Returns:

  • (Hash)

    source descriptor for 0.0..1.0 phase within the current 4-beat bar



874
875
876
# File 'lib/vizcore/dsl/layer_builder.rb', line 874

def bar_phase
  mapping_source(:bar_phase)
end

#bassHash

Returns source descriptor for the low/bass frequency band.

Returns:

  • (Hash)

    source descriptor for the low/bass frequency band



746
747
748
# File 'lib/vizcore/dsl/layer_builder.rb', line 746

def bass
  frequency_band(:low)
end

#bass_peakHash

Returns source descriptor for the held low/bass peak.

Returns:

  • (Hash)

    source descriptor for the held low/bass peak



751
752
753
# File 'lib/vizcore/dsl/layer_builder.rb', line 751

def bass_peak
  frequency_band_peak(:low)
end

#beatHash

Returns source descriptor for beat trigger.

Returns:

  • (Hash)

    source descriptor for beat trigger



824
825
826
# File 'lib/vizcore/dsl/layer_builder.rb', line 824

def beat
  beat?
end

#beat?Hash

Returns source descriptor for beat trigger.

Returns:

  • (Hash)

    source descriptor for beat trigger



819
820
821
# File 'lib/vizcore/dsl/layer_builder.rb', line 819

def beat?
  mapping_source(:beat)
end

#beat_2Hash

Returns source descriptor for half-beat subdivision pulses.

Returns:

  • (Hash)

    source descriptor for half-beat subdivision pulses



849
850
851
# File 'lib/vizcore/dsl/layer_builder.rb', line 849

def beat_2
  mapping_source(:beat_2)
end

#beat_4Hash

Returns source descriptor for quarter-beat subdivision pulses.

Returns:

  • (Hash)

    source descriptor for quarter-beat subdivision pulses



854
855
856
# File 'lib/vizcore/dsl/layer_builder.rb', line 854

def beat_4
  mapping_source(:beat_4)
end

#beat_8Hash

Returns source descriptor for eighth-beat subdivision pulses.

Returns:

  • (Hash)

    source descriptor for eighth-beat subdivision pulses



859
860
861
# File 'lib/vizcore/dsl/layer_builder.rb', line 859

def beat_8
  mapping_source(:beat_8)
end

#beat_confidenceHash

Returns source descriptor for beat detector confidence.

Returns:

  • (Hash)

    source descriptor for beat detector confidence



829
830
831
# File 'lib/vizcore/dsl/layer_builder.rb', line 829

def beat_confidence
  mapping_source(:beat_confidence)
end

#beat_countHash

Returns source descriptor for beat counter.

Returns:

  • (Hash)

    source descriptor for beat counter



839
840
841
# File 'lib/vizcore/dsl/layer_builder.rb', line 839

def beat_count
  mapping_source(:beat_count)
end

#beat_phaseHash

Returns source descriptor for 0.0..1.0 phase within the current beat.

Returns:

  • (Hash)

    source descriptor for 0.0..1.0 phase within the current beat



844
845
846
# File 'lib/vizcore/dsl/layer_builder.rb', line 844

def beat_phase
  mapping_source(:beat_phase)
end

#beat_pulseHash

Returns source descriptor for beat pulse decay value.

Returns:

  • (Hash)

    source descriptor for beat pulse decay value



834
835
836
# File 'lib/vizcore/dsl/layer_builder.rb', line 834

def beat_pulse
  mapping_source(:beat_pulse)
end

#beat_tripletHash

Returns source descriptor for triplet subdivision pulses.

Returns:

  • (Hash)

    source descriptor for triplet subdivision pulses



864
865
866
# File 'lib/vizcore/dsl/layer_builder.rb', line 864

def beat_triplet
  mapping_source(:beat_triplet)
end

#bezier(id = nil, from:, to:, control: nil, c1: nil, c2: nil, **options) { ... } ⇒ Hash

Declare a quadratic or cubic bezier curve. The serialized primitive is a path.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • from (Array<Numeric>)

    start point

  • to (Array<Numeric>)

    end point

  • control (Array<Numeric>, nil) (defaults to: nil)

    quadratic control point

  • c1 (Array<Numeric>, nil) (defaults to: nil)

    first cubic control point

  • c2 (Array<Numeric>, nil) (defaults to: nil)

    second cubic control point

  • options (Hash)

    additional path params

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/vizcore/dsl/layer_builder.rb', line 196

def bezier(id = nil, from:, to:, control: nil, c1: nil, c2: nil, **options, &block)
  commands = [["M", *point_values(from)]]
  if control
    commands << ["Q", *point_values(control), *point_values(to)]
  elsif c1 && c2
    commands << ["C", *point_values(c1), *point_values(c2), *point_values(to)]
  else
    raise ArgumentError, "bezier requires either :control or both :c1 and :c2"
  end

  build_shape(:path, shape_options(id, options).merge(commands: commands), schema_version: true, &block)
end

#blend(value) ⇒ Symbol

Parameters:

  • value (Symbol, String)

    layer compositing mode

Returns:

  • (Symbol)


389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/vizcore/dsl/layer_builder.rb', line 389

def blend(value)
  if @current_shape
    @current_shape[:blend] = value.to_sym
    mark_shape_schema_version!
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_style[:blend] = value.to_sym
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group[:blend] = value.to_sym
    return current_shape_group
  end

  @params[:blend] = value.to_sym
end

#bpmHash

Returns source descriptor for estimated BPM.

Returns:

  • (Hash)

    source descriptor for estimated BPM



891
892
893
# File 'lib/vizcore/dsl/layer_builder.rb', line 891

def bpm
  mapping_source(:bpm)
end

#bpm_confidenceHash

Returns source descriptor for tempo estimator confidence.

Returns:

  • (Hash)

    source descriptor for tempo estimator confidence



896
897
898
# File 'lib/vizcore/dsl/layer_builder.rb', line 896

def bpm_confidence
  mapping_source(:bpm_confidence)
end

#circle(id = nil, **options) { ... } ⇒ Hash

Declare a 2D circle/ring primitive for a shape layer.

Parameters:

  • options (Hash)

    shape params such as ‘count`, `radius`, `x`, and `y`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


130
131
132
# File 'lib/vizcore/dsl/layer_builder.rb', line 130

def circle(id = nil, **options, &block)
  build_shape(:circle, shape_options(id, options), &block)
end

#closeObject



578
579
580
# File 'lib/vizcore/dsl/layer_builder.rb', line 578

def close
  append_path_command("Z")
end

#content(value) ⇒ String

Parameters:

  • value (String)

    text content

Returns:

  • (String)


295
296
297
# File 'lib/vizcore/dsl/layer_builder.rb', line 295

def content(value)
  @params[:content] = value.to_s
end

#count(value) ⇒ Integer

Parameters:

  • value (Integer)

    particle count or similar numeric parameter

Returns:

  • (Integer)


289
290
291
# File 'lib/vizcore/dsl/layer_builder.rb', line 289

def count(value)
  @params[:count] = Integer(value)
end

#cubic_to(c1x, c1y, c2x, c2y, x, y) ⇒ Object



562
563
564
# File 'lib/vizcore/dsl/layer_builder.rb', line 562

def cubic_to(c1x, c1y, c2x, c2y, x, y)
  append_path_command("C", c1x, c1y, c2x, c2y, x, y)
end

#custom_shape(renderer, **options) { ... } ⇒ Array<Hash>

Expand a registered Ruby custom shape into normal shape primitives.

Parameters:

  • renderer (Symbol, String, Class, Module, #call)

    registered shape name or renderer

  • options (Hash)

    custom shape params

Yields:

  • optional block applied to each generated primitive

Returns:

  • (Array<Hash>)

Raises:

  • (ArgumentError)


225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/vizcore/dsl/layer_builder.rb', line 225

def custom_shape(renderer, **options, &block)
  mark_shape_schema_version!
  shape_id = options.delete(:id)
  dynamic = options.delete(:dynamic)
  static = options.delete(:static)
  raise ArgumentError, "custom_shape cannot be both static and dynamic" if dynamic && static

  dynamic = true if static == false
  return append_dynamic_custom_shape(renderer, options, shape_id: shape_id, &block) if dynamic

  primitives = expand_custom_shape(renderer, options, shape_id: shape_id, cache: !!static)
  raise ArgumentError, "custom_shape produced no primitives" if primitives.empty?
  raise ArgumentError, "custom_shape id can only be assigned when one primitive is produced" if shape_id && primitives.length > 1

  @type ||= :shape
  @params[:shapes] ||= []
  primitives.map do |primitive|
    primitive[:id] ||= shape_id.to_sym if shape_id
    append_expanded_shape(primitive, &block)
  end
end

#draw { ... } ⇒ Array<Hash>

Group shape primitives in a block for readability.

Yields:

  • shape declarations

Returns:

  • (Array<Hash>)


272
273
274
275
276
# File 'lib/vizcore/dsl/layer_builder.rb', line 272

def draw(&block)
  @type ||= :shape
  instance_eval(&block) if block
  @params[:shapes] || []
end

#envelope(source = :kick, **options) ⇒ Hash

Alias for ADSR envelope mapping source.

Parameters:

  • source (Symbol, Hash) (defaults to: :kick)

    source to trigger the envelope

  • options (Numeric)

    envelope timing and shaping values

Returns:

  • (Hash)

    source descriptor for a general envelope



968
969
970
# File 'lib/vizcore/dsl/layer_builder.rb', line 968

def envelope(source = :kick, **options)
  adsr(source, **options)
end

#evaluate { ... } ⇒ Vizcore::DSL::LayerBuilder

Evaluate a layer block.

Yields:

  • Layer DSL methods

Returns:



88
89
90
91
# File 'lib/vizcore/dsl/layer_builder.rb', line 88

def evaluate(&block)
  instance_eval(&block) if block
  self
end

#fft_spectrumHash

Returns source descriptor for FFT spectrum array.

Returns:

  • (Hash)

    source descriptor for FFT spectrum array



786
787
788
# File 'lib/vizcore/dsl/layer_builder.rb', line 786

def fft_spectrum
  mapping_source(:fft_spectrum)
end

#file(path) ⇒ String

Parameters:

  • path (String, Pathname)

    asset file path used by media-like layers

Returns:

  • (String)


121
122
123
# File 'lib/vizcore/dsl/layer_builder.rb', line 121

def file(path)
  @params[:file] = path.to_s
end

#fill(value) ⇒ String

Parameters:

  • value (String)

    text fill color

Returns:

  • (String)


328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/vizcore/dsl/layer_builder.rb', line 328

def fill(value)
  if @current_shape
    @current_shape[:fill] = value.to_s
    mark_shape_schema_version!
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_style[:fill] = value.to_s
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group[:fill] = value.to_s
    return current_shape_group
  end

  @params[:color] = value.to_s
end

#font(value) ⇒ String

Parameters:

  • value (String)

    text font family

Returns:

  • (String)


322
323
324
# File 'lib/vizcore/dsl/layer_builder.rb', line 322

def font(value)
  @params[:font] = value.to_s
end

#font_size(value) ⇒ Integer

Parameters:

  • value (Integer)

    font size in pixels

Returns:

  • (Integer)


301
302
303
# File 'lib/vizcore/dsl/layer_builder.rb', line 301

def font_size(value)
  @params[:font_size] = Integer(value)
end

#frequency_band(name) ⇒ Hash

Returns source descriptor for a frequency band.

Parameters:

  • name (Symbol, String)

    band key (‘sub`, `low`, `mid`, `high`)

Returns:

  • (Hash)

    source descriptor for a frequency band



716
717
718
# File 'lib/vizcore/dsl/layer_builder.rb', line 716

def frequency_band(name)
  mapping_source(:frequency_band, band: name.to_sym)
end

#frequency_band_peak(name) ⇒ Hash

Returns source descriptor for a held frequency-band peak.

Returns:

  • (Hash)

    source descriptor for a held frequency-band peak



721
722
723
# File 'lib/vizcore/dsl/layer_builder.rb', line 721

def frequency_band_peak(name)
  mapping_source(:frequency_band_peak, band: name.to_sym)
end

#global(name) ⇒ Hash

Returns source descriptor for mutable runtime globals.

Parameters:

  • name (Symbol, String)

    runtime global value name

Returns:

  • (Hash)

    source descriptor for mutable runtime globals



927
928
929
# File 'lib/vizcore/dsl/layer_builder.rb', line 927

def global(name)
  mapping_source(:global, name: name.to_sym)
end

#glsl(path) ⇒ String

Parameters:

  • path (String, Pathname)

    custom fragment shader path

Returns:

  • (String)


114
115
116
117
# File 'lib/vizcore/dsl/layer_builder.rb', line 114

def glsl(path)
  @glsl = path.to_s
  @type ||= :shader
end

#group(_id = nil, **attrs) { ... } ⇒ Array<Hash>

Apply shared style and transform to shape primitives declared in the block.

Group attributes are flattened into child primitives so the frontend only needs to render regular shape primitives.

Parameters:

  • id (Symbol, String, nil)

    optional group identifier, currently documentation-only

  • attrs (Hash)

    initial group style/transform attrs

Yields:

  • shape declarations

Returns:

  • (Array<Hash>)


256
257
258
259
260
261
262
263
264
265
266
# File 'lib/vizcore/dsl/layer_builder.rb', line 256

def group(_id = nil, **attrs, &block)
  raise ArgumentError, "group requires a block" unless block

  mark_shape_schema_version!
  @type ||= :shape
  @shape_group_stack << merge_shape_group(current_shape_group, normalize_shape_group(attrs))
  instance_eval(&block)
  @params[:shapes] || []
ensure
  @shape_group_stack.pop if @shape_group_stack.length > 1
end

#highHash

Returns source descriptor for the high frequency band.

Returns:

  • (Hash)

    source descriptor for the high frequency band



766
767
768
# File 'lib/vizcore/dsl/layer_builder.rb', line 766

def high
  frequency_band(:high)
end

#high_peakHash

Returns source descriptor for the held high peak.

Returns:

  • (Hash)

    source descriptor for the held high peak



771
772
773
# File 'lib/vizcore/dsl/layer_builder.rb', line 771

def high_peak
  frequency_band_peak(:high)
end

#hihat(value = NO_ARGUMENT) ⇒ Hash

Returns source descriptor for high-band percussive confidence.

Returns:

  • (Hash)

    source descriptor for high-band percussive confidence



812
813
814
815
816
# File 'lib/vizcore/dsl/layer_builder.rb', line 812

def hihat(value = NO_ARGUMENT)
  return @params[:hihat] = value unless value.equal?(NO_ARGUMENT)

  mapping_source(:hihat)
end

#horizontal_to(x) ⇒ Object



566
567
568
# File 'lib/vizcore/dsl/layer_builder.rb', line 566

def horizontal_to(x)
  append_path_command("H", x)
end

#kick(value = NO_ARGUMENT) ⇒ Hash

Returns source descriptor for low-band percussive confidence.

Returns:

  • (Hash)

    source descriptor for low-band percussive confidence



798
799
800
801
802
# File 'lib/vizcore/dsl/layer_builder.rb', line 798

def kick(value = NO_ARGUMENT)
  return @params[:kick] = value unless value.equal?(NO_ARGUMENT)

  mapping_source(:kick)
end

#letter_spacing(value) ⇒ Float

Parameters:

  • value (Numeric)

    extra spacing between text glyphs in pixels

Returns:

  • (Float)


307
308
309
# File 'lib/vizcore/dsl/layer_builder.rb', line 307

def letter_spacing(value)
  @params[:letter_spacing] = normalize_non_negative_param_number(value, :letter_spacing)
end

#lfo(wave = :sine, rate: 1.0, phase: 0.0) ⇒ Hash

Returns source descriptor for a time-based low-frequency oscillator.

Parameters:

  • wave (Symbol, String) (defaults to: :sine)

    one of ‘sine`, `triangle`, `saw`, `square`

  • rate (Numeric) (defaults to: 1.0)

    cycles per second

  • phase (Numeric) (defaults to: 0.0)

    phase offset in cycles

Returns:

  • (Hash)

    source descriptor for a time-based low-frequency oscillator



935
936
937
938
939
# File 'lib/vizcore/dsl/layer_builder.rb', line 935

def lfo(wave = :sine, rate: 1.0, phase: 0.0)
  mapping_source(:lfo, wave: wave.to_sym, rate: Float(rate), phase: Float(phase))
rescue ArgumentError, TypeError
  raise ArgumentError, "lfo rate and phase must be numeric"
end

#line(id = nil, **options) { ... } ⇒ Hash

Declare a 2D line primitive for a shape layer.

Parameters:

  • options (Hash)

    shape params such as ‘x1`, `y1`, `x2`, and `y2`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


139
140
141
# File 'lib/vizcore/dsl/layer_builder.rb', line 139

def line(id = nil, **options, &block)
  build_shape(:line, shape_options(id, options), &block)
end

#line_to(x, y) ⇒ Object



554
555
556
# File 'lib/vizcore/dsl/layer_builder.rb', line 554

def line_to(x, y)
  append_path_command("L", x, y)
end

#lowHash

Returns source descriptor for the low/bass frequency band.

Returns:

  • (Hash)

    source descriptor for the low/bass frequency band



736
737
738
# File 'lib/vizcore/dsl/layer_builder.rb', line 736

def low
  frequency_band(:low)
end

#low_peakHash

Returns source descriptor for the held low/bass peak.

Returns:

  • (Hash)

    source descriptor for the held low/bass peak



741
742
743
# File 'lib/vizcore/dsl/layer_builder.rb', line 741

def low_peak
  frequency_band_peak(:low)
end

#map(definition = nil, **options, &block) ⇒ void

This method returns an undefined value.

Map analysis source(s) to layer parameter target(s).

Parameters:

  • definition (Hash, Symbol, String) (defaults to: nil)

    mapping pairs or a single source

Raises:

  • (ArgumentError)

    when the mapping is empty or invalid



644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
# File 'lib/vizcore/dsl/layer_builder.rb', line 644

def map(definition = nil, **options, &block)
  definition, options = normalize_custom_shape_mapping(definition, options) if @custom_shape_target_prefix
  definition, options = normalize_shape_mapping(definition, options) if @shape_target_prefix

  if options.key?(:to)
    transform_options = options.dup
    to = transform_options.delete(:to)
    transform_options = evaluate_transform_block(transform_options, &block) if block
    @mappings << build_mapping(
      source: normalize_source(definition),
      target: to,
      transform: normalize_transform(**transform_options)
    )
    return
  end

  mapping = definition.nil? ? options : Hash(definition)
  raise ArgumentError, "map requires at least one mapping pair" if mapping.empty?
  raise ArgumentError, "map block syntax supports one mapping pair" if block && mapping.length != 1

  mapping.each do |source, target|
    target_name, transform = normalize_target(target)
    transform = normalize_transform(**evaluate_transform_block(transform, &block)) if block
    @mappings << build_mapping(source: normalize_source(source), target: target_name, transform: transform)
  end
end

#midHash

Returns source descriptor for the mid frequency band.

Returns:

  • (Hash)

    source descriptor for the mid frequency band



756
757
758
# File 'lib/vizcore/dsl/layer_builder.rb', line 756

def mid
  frequency_band(:mid)
end

#mid_peakHash

Returns source descriptor for the held mid peak.

Returns:

  • (Hash)

    source descriptor for the held mid peak



761
762
763
# File 'lib/vizcore/dsl/layer_builder.rb', line 761

def mid_peak
  frequency_band_peak(:mid)
end

#move_to(x, y) ⇒ Object



550
551
552
# File 'lib/vizcore/dsl/layer_builder.rb', line 550

def move_to(x, y)
  append_path_command("M", x, y)
end

#onset(band = nil) ⇒ Hash

Returns source descriptor for positive audio feature changes.

Parameters:

  • band (Symbol, String, nil) (defaults to: nil)

    optional band-specific onset key

Returns:

  • (Hash)

    source descriptor for positive audio feature changes



792
793
794
795
# File 'lib/vizcore/dsl/layer_builder.rb', line 792

def onset(band = nil)
  options = band.nil? ? {} : { band: band.to_sym }
  mapping_source(:onset, **options)
end

#opacity(value) ⇒ Float, Hash

Set layer or shape opacity.

Parameters:

  • value (Numeric)

Returns:

  • (Float, Hash)


413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/vizcore/dsl/layer_builder.rb', line 413

def opacity(value)
  if @current_shape
    @current_shape[:opacity] = normalize_param_number(value, :opacity)
    mark_shape_schema_version!
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_style[:opacity] = normalize_param_number(value, :opacity)
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group[:opacity] = current_shape_group.key?(:opacity) ? normalize_param_number(current_shape_group[:opacity], :opacity) * normalize_param_number(value, :opacity) : normalize_param_number(value, :opacity)
    return current_shape_group
  end

  @params[:opacity] = normalize_param_number(value, :opacity)
end

#origin(*args, x: nil, y: nil) ⇒ Hash

Set a shape/layer transform origin.

Parameters:

  • args (Array<Numeric>)
  • x (Numeric, nil) (defaults to: nil)
  • y (Numeric, nil) (defaults to: nil)

Returns:

  • (Hash)


515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/vizcore/dsl/layer_builder.rb', line 515

def origin(*args, x: nil, y: nil)
  values = normalize_xy_args(args, x: x, y: y, name: :origin)
  if @current_shape
    current_shape_transform[:origin] = values
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_transform[:origin] = values
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group_transform[:origin] = values
    return current_shape_group
  end

  @params[:origin] = values
end

#palette(*colors) ⇒ Array<String>

Store an ordered color palette for this layer.

Parameters:

  • colors (Array<String, Array<String>>)

    color values such as “#00ffff”

Returns:

  • (Array<String>)

Raises:

  • (ArgumentError)

    when no non-blank colors are supplied



587
588
589
# File 'lib/vizcore/dsl/layer_builder.rb', line 587

def palette(*colors)
  @params[:palette] = normalize_palette(colors)
end

#param(name, default: nil, range: nil, min: nil, max: nil, step: nil) ⇒ Hash

Declare numeric metadata for a shader/layer parameter.

Parameters:

  • name (Symbol, String)

    parameter name exposed as ‘u_param_<name>` for shaders

  • default (Numeric, nil) (defaults to: nil)

    default value stored in layer params

  • range (Range, Array, nil) (defaults to: nil)

    allowed numeric range

  • min (Numeric, nil) (defaults to: nil)

    allowed minimum when ‘range` is not used

  • max (Numeric, nil) (defaults to: nil)

    allowed maximum when ‘range` is not used

  • step (Numeric, nil) (defaults to: nil)

    preferred UI step

Returns:

  • (Hash)


622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/vizcore/dsl/layer_builder.rb', line 622

def param(name, default: nil, range: nil, min: nil, max: nil, step: nil)
  key = normalize_param_name(name)
  range_min, range_max = normalize_range(range, context: "param")
  min = range_min if min.nil?
  max = range_max if max.nil?

   = { name: key }
  [:default] = normalize_param_number(default, :default) unless default.nil?
  [:min] = normalize_param_number(min, :min) unless min.nil?
  [:max] = normalize_param_number(max, :max) unless max.nil?
  [:step] = normalize_param_number(step, :step) unless step.nil?
  validate_param_range!()

  @params[key] = [:default] if .key?(:default)
  @param_schema[key] = 
end

#path(id = nil, **options) { ... } ⇒ Hash

Declare a path primitive using SVG-like path commands.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • options (Hash)

    path params such as ‘detail`

Yields:

  • block containing path commands and shape styling

Returns:

  • (Hash)


179
180
181
182
183
# File 'lib/vizcore/dsl/layer_builder.rb', line 179

def path(id = nil, **options, &block)
  shape = shape_options(id, options)
  shape[:commands] ||= []
  build_shape(:path, shape, schema_version: true, &block)
end

#peakHash

Returns source descriptor for absolute sample peak level.

Returns:

  • (Hash)

    source descriptor for absolute sample peak level



710
711
712
# File 'lib/vizcore/dsl/layer_builder.rb', line 710

def peak
  mapping_source(:peak)
end

#phrase_countHash

Returns source descriptor for completed 8-bar phrases.

Returns:

  • (Hash)

    source descriptor for completed 8-bar phrases



886
887
888
# File 'lib/vizcore/dsl/layer_builder.rb', line 886

def phrase_count
  mapping_source(:phrase_count)
end

#polygon(id = nil, **options) { ... } ⇒ Hash

Declare a closed polygon primitive for a shape layer.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • options (Hash)

    shape params including ‘points`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


159
160
161
# File 'lib/vizcore/dsl/layer_builder.rb', line 159

def polygon(id = nil, **options, &block)
  build_shape(:polygon, shape_options(id, options), schema_version: true, &block)
end

#polyline(id = nil, **options) { ... } ⇒ Hash

Declare an open polyline primitive for a shape layer.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • options (Hash)

    shape params including ‘points`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


169
170
171
# File 'lib/vizcore/dsl/layer_builder.rb', line 169

def polyline(id = nil, **options, &block)
  build_shape(:polyline, shape_options(id, options).merge(closed: false), schema_version: true, &block)
end

#post(name) ⇒ Symbol

Append one post effect to this layer’s post effect chain.

Parameters:

  • name (Symbol, String)

    effect key

Returns:

  • (Symbol)

Raises:

  • (ArgumentError)


595
596
597
598
599
600
# File 'lib/vizcore/dsl/layer_builder.rb', line 595

def post(name)
  raise ArgumentError, "post expects a symbol or string" unless name

  @params[:post_effects] ||= []
  @params[:post_effects] << name.to_sym
end

#quad_to(cx, cy, x, y) ⇒ Object



558
559
560
# File 'lib/vizcore/dsl/layer_builder.rb', line 558

def quad_to(cx, cy, x, y)
  append_path_command("Q", cx, cy, x, y)
end

#react_to(source_value) { ... } ⇒ void

This method returns an undefined value.

High-level mapping DSL for describing audio reactions inside a layer.

Parameters:

  • source_value (Hash, Symbol, String)

    analysis source descriptor

Yields:

  • Reaction block with ‘change` and `trigger`

Raises:

  • (ArgumentError)

    when no reaction block is provided



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
# File 'lib/vizcore/dsl/layer_builder.rb', line 688

def react_to(source_value, &block)
  raise ArgumentError, "react_to requires a block" unless block

  source_descriptor = normalize_source(source_value)
  reaction = ReactionBuilder.new(
    mapping_factory: lambda do |target, transform_options|
      build_mapping(
        source: source_descriptor,
        target: target,
        transform: normalize_transform(**transform_options)
      )
    end
  )
  @mappings.concat(reaction.evaluate(&block))
end

#rect(id = nil, **options) { ... } ⇒ Hash

Declare a 2D rectangle primitive for a shape layer.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • options (Hash)

    shape params such as ‘x`, `y`, `width`, `height`, and `radius`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


149
150
151
# File 'lib/vizcore/dsl/layer_builder.rb', line 149

def rect(id = nil, **options, &block)
  build_shape(:rect, shape_options(id, options), schema_version: true, &block)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


1013
1014
1015
# File 'lib/vizcore/dsl/layer_builder.rb', line 1013

def respond_to_missing?(method_name, include_private = false)
  !!@current_custom_shape || @params.key?(method_name.to_sym) || super
end

#rotate(value) ⇒ Float, Hash

Set a shape/layer rotation transform in degrees.

Parameters:

  • value (Numeric)

Returns:

  • (Float, Hash)


463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/vizcore/dsl/layer_builder.rb', line 463

def rotate(value)
  rotation = normalize_param_number(value, :rotate)
  if @current_shape
    current_shape_transform[:rotate] = rotation
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_transform[:rotate] = normalize_param_number(current_custom_shape_transform[:rotate] || 0, :rotate) + rotation
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group_transform[:rotate] = normalize_param_number(current_shape_group_transform[:rotate] || 0, :rotate) + rotation
    return current_shape_group
  end

  @params[:rotate] = rotation
end

#scale(value = NO_ARGUMENT, x: nil, y: nil) ⇒ Float, Hash

Set a shape/layer scale transform.

Parameters:

  • value (Numeric) (defaults to: NO_ARGUMENT)
  • x (Numeric, nil) (defaults to: nil)
  • y (Numeric, nil) (defaults to: nil)

Returns:

  • (Float, Hash)


489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
# File 'lib/vizcore/dsl/layer_builder.rb', line 489

def scale(value = NO_ARGUMENT, x: nil, y: nil)
  scale_value = normalize_scale_args(value, x: x, y: y)
  if @current_shape
    current_shape_transform[:scale] = scale_value
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_transform[:scale] = multiply_shape_scale(current_custom_shape_transform[:scale], scale_value)
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group_transform[:scale] = multiply_shape_scale(current_shape_group_transform[:scale], scale_value)
    return current_shape_group
  end

  @params[:scale] = scale_value
end

#shader(value, reload: nil) ⇒ Symbol

Parameters:

  • value (Symbol, String)

    built-in shader key or custom GLSL path

  • reload (Boolean, nil) (defaults to: nil)

    accepted for custom shader path compatibility

Returns:

  • (Symbol)


102
103
104
105
106
107
108
109
110
# File 'lib/vizcore/dsl/layer_builder.rb', line 102

def shader(value, reload: nil)
  if shader_path?(value)
    @glsl = value.to_s
    @params[:shader_reload] = !!reload unless reload.nil?
  else
    @shader = value.to_sym
  end
  @type ||= :shader
end

#shadow(color: nil, blur: nil) ⇒ Hash

Parameters:

  • color (String, nil) (defaults to: nil)

    text shadow color

  • blur (Numeric, nil) (defaults to: nil)

    text shadow blur in pixels

Returns:

  • (Hash)


381
382
383
384
385
# File 'lib/vizcore/dsl/layer_builder.rb', line 381

def shadow(color: nil, blur: nil)
  @params[:shadow_color] = color.to_s unless color.nil?
  @params[:shadow_blur] = normalize_non_negative_param_number(blur, :shadow_blur) unless blur.nil?
  @params
end

#shape(id) ⇒ ShapeReference

Return a reference object for mapping to a named shape.

Parameters:

  • id (Symbol, String)

Returns:



539
540
541
542
543
544
545
546
547
548
# File 'lib/vizcore/dsl/layer_builder.rb', line 539

def shape(id)
  key = id.to_sym
  index = @shape_index_by_id.fetch(key) do
    suggestion_message = shape_id_suggestions(key)
    message = "unknown shape id: #{key.inspect}"
    message = "#{message}. Did you mean: #{suggestion_message}" unless suggestion_message.empty?
    raise ArgumentError, message
  end
  ShapeReference.new("shapes.#{index}")
end

#snare(value = NO_ARGUMENT) ⇒ Hash

Returns source descriptor for mid-band percussive confidence.

Returns:

  • (Hash)

    source descriptor for mid-band percussive confidence



805
806
807
808
809
# File 'lib/vizcore/dsl/layer_builder.rb', line 805

def snare(value = NO_ARGUMENT)
  return @params[:snare] = value unless value.equal?(NO_ARGUMENT)

  mapping_source(:snare)
end

#source(value, **options) ⇒ Symbol, Hash

Parameters:

  • value (Symbol, String)

    input source for media-like layers

Returns:

  • (Symbol, Hash)


280
281
282
283
284
285
# File 'lib/vizcore/dsl/layer_builder.rb', line 280

def source(value, **options)
  source_name = value.to_sym
  return mapping_source(source_name, **options) if options.any? || MAPPING_SOURCE_KINDS.include?(source_name)

  @params[:source] = source_name
end

#spectral_centroidHash

Returns source descriptor for spectral centroid in Hz.

Returns:

  • (Hash)

    source descriptor for spectral centroid in Hz



901
902
903
# File 'lib/vizcore/dsl/layer_builder.rb', line 901

def spectral_centroid
  mapping_source(:spectral_centroid)
end

#spectral_flatnessHash

Returns source descriptor for spectral flatness.

Returns:

  • (Hash)

    source descriptor for spectral flatness



911
912
913
# File 'lib/vizcore/dsl/layer_builder.rb', line 911

def spectral_flatness
  mapping_source(:spectral_flatness)
end

#spectral_fluxHash

Returns source descriptor for positive spectrum delta.

Returns:

  • (Hash)

    source descriptor for positive spectrum delta



916
917
918
# File 'lib/vizcore/dsl/layer_builder.rb', line 916

def spectral_flux
  mapping_source(:spectral_flux)
end

#spectral_rolloffHash

Returns source descriptor for spectral rolloff in Hz.

Returns:

  • (Hash)

    source descriptor for spectral rolloff in Hz



906
907
908
# File 'lib/vizcore/dsl/layer_builder.rb', line 906

def spectral_rolloff
  mapping_source(:spectral_rolloff)
end

#star(id = nil, **options) { ... } ⇒ Hash

Declare a star polygon primitive for a shape layer.

Parameters:

  • id (Symbol, String, nil) (defaults to: nil)

    optional shape identifier

  • options (Hash)

    shape params such as ‘points`, `radius`, and `inner_radius`

Yields:

  • optional block evaluated in the shape context

Returns:

  • (Hash)


215
216
217
# File 'lib/vizcore/dsl/layer_builder.rb', line 215

def star(id = nil, **options, &block)
  build_shape(:star, shape_options(id, options), schema_version: true, &block)
end

#stroke(value = NO_ARGUMENT, width: nil, color: nil) ⇒ Hash

Parameters:

  • width (Numeric, nil) (defaults to: nil)

    text stroke width in pixels

  • color (String, nil) (defaults to: nil)

    text stroke color

Returns:

  • (Hash)


351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/vizcore/dsl/layer_builder.rb', line 351

def stroke(value = NO_ARGUMENT, width: nil, color: nil)
  if @current_shape
    @current_shape[:stroke] = normalize_non_negative_param_number(value, :stroke) unless value.equal?(NO_ARGUMENT)
    @current_shape[:stroke_width] = normalize_non_negative_param_number(width, :stroke_width) unless width.nil?
    @current_shape[:stroke_color] = color.to_s unless color.nil?
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_style[:stroke] = normalize_non_negative_param_number(value, :stroke) unless value.equal?(NO_ARGUMENT)
    current_custom_shape_style[:stroke_width] = normalize_non_negative_param_number(width, :stroke_width) unless width.nil?
    current_custom_shape_style[:stroke_color] = color.to_s unless color.nil?
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group[:stroke] = normalize_non_negative_param_number(value, :stroke) unless value.equal?(NO_ARGUMENT)
    current_shape_group[:stroke_width] = normalize_non_negative_param_number(width, :stroke_width) unless width.nil?
    current_shape_group[:stroke_color] = color.to_s unless color.nil?
    return current_shape_group
  end

  @params[:stroke_width] = normalize_non_negative_param_number(width, :stroke_width) unless width.nil?
  @params[:stroke_color] = color.to_s unless color.nil?
  @params
end

#subHash

Returns source descriptor for the sub-bass frequency band.

Returns:

  • (Hash)

    source descriptor for the sub-bass frequency band



726
727
728
# File 'lib/vizcore/dsl/layer_builder.rb', line 726

def sub
  frequency_band(:sub)
end

#sub_peakHash

Returns source descriptor for the held sub-bass peak.

Returns:

  • (Hash)

    source descriptor for the held sub-bass peak



731
732
733
# File 'lib/vizcore/dsl/layer_builder.rb', line 731

def sub_peak
  frequency_band_peak(:sub)
end

#to_hHash

Returns serialized layer payload.

Returns:

  • (Hash)

    serialized layer payload



973
974
975
976
977
978
979
980
981
982
983
984
985
# File 'lib/vizcore/dsl/layer_builder.rb', line 973

def to_h
  validate_strict_params! if @strict
  layer = {
    name: @name,
    type: resolved_type,
    params: @params.dup
  }
  layer[:shader] = @shader if @shader
  layer[:glsl] = @glsl if @glsl
  layer[:param_schema] = @param_schema.values.map(&:dup) unless @param_schema.empty?
  layer[:mappings] = @mappings.map { |mapping| mapping.dup } unless @mappings.empty?
  layer
end

#translate(*args, x: nil, y: nil) ⇒ Hash

Set a shape/layer translation transform.

Parameters:

  • args (Array<Numeric>)
  • x (Numeric, nil) (defaults to: nil)
  • y (Numeric, nil) (defaults to: nil)

Returns:

  • (Hash)


439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
# File 'lib/vizcore/dsl/layer_builder.rb', line 439

def translate(*args, x: nil, y: nil)
  values = normalize_xy_args(args, x: x, y: y, name: :translate)
  if @current_shape
    current_shape_transform[:translate] = values
    return @current_shape
  end

  if @current_custom_shape
    current_custom_shape_transform[:translate] = add_shape_xy(current_custom_shape_transform[:translate], values)
    return @current_custom_shape
  end

  if in_shape_group?
    current_shape_group_transform[:translate] = add_shape_xy(current_shape_group_transform[:translate], values)
    return current_shape_group
  end

  @params[:translate] = values
end

#trebleHash

Returns source descriptor for the high/treble frequency band.

Returns:

  • (Hash)

    source descriptor for the high/treble frequency band



776
777
778
# File 'lib/vizcore/dsl/layer_builder.rb', line 776

def treble
  frequency_band(:high)
end

#treble_peakHash

Returns source descriptor for the held high/treble peak.

Returns:

  • (Hash)

    source descriptor for the held high/treble peak



781
782
783
# File 'lib/vizcore/dsl/layer_builder.rb', line 781

def treble_peak
  frequency_band_peak(:high)
end

#tripletHash

Returns source descriptor for triplet subdivision pulses.

Returns:

  • (Hash)

    source descriptor for triplet subdivision pulses



869
870
871
# File 'lib/vizcore/dsl/layer_builder.rb', line 869

def triplet
  mapping_source(:beat_triplet)
end

#type(value) ⇒ Symbol

Parameters:

  • value (Symbol, String)

    layer type (‘shader`, `particle_field`, etc.)

Returns:

  • (Symbol)


95
96
97
# File 'lib/vizcore/dsl/layer_builder.rb', line 95

def type(value)
  @type = value.to_sym
end

#use_mapping(name) ⇒ void

This method returns an undefined value.

Apply a named mapping preset to this layer.

Parameters:

  • name (Symbol, String)

    mapping preset identifier

Raises:

  • (ArgumentError)

    when the preset is unknown



676
677
678
679
680
# File 'lib/vizcore/dsl/layer_builder.rb', line 676

def use_mapping(name)
  preset_name = name.to_sym
  preset = @mapping_presets.fetch(preset_name) { raise ArgumentError, "unknown mapping preset: #{preset_name}" }
  preset.each { |mapping| @mappings << deep_dup(mapping) }
end

#use_style(name) ⇒ Hash

Apply a named style by merging its params into this layer.

Parameters:

  • name (Symbol, String)

    style identifier

Returns:

  • (Hash)

    applied style params

Raises:

  • (ArgumentError)

    when the style is unknown



607
608
609
610
611
# File 'lib/vizcore/dsl/layer_builder.rb', line 607

def use_style(name)
  style_name = name.to_sym
  style_params = @styles.fetch(style_name) { raise ArgumentError, "unknown style: #{style_name}" }
  @params.merge!(deep_dup(style_params))
end

#vertical_to(y) ⇒ Object



570
571
572
# File 'lib/vizcore/dsl/layer_builder.rb', line 570

def vertical_to(y)
  append_path_command("V", y)
end

#zero_crossing_rateHash

Returns source descriptor for time-domain zero crossing rate.

Returns:

  • (Hash)

    source descriptor for time-domain zero crossing rate



921
922
923
# File 'lib/vizcore/dsl/layer_builder.rb', line 921

def zero_crossing_rate
  mapping_source(:zero_crossing_rate)
end