Class: XRVG::CircularGradient

Inherits:
Gradient show all
Defined in:
lib/color.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Gradient

#defsvg

Methods inherited from Palette

#apply_sample, #build_interpolators, #color, #initialize, #interpolate, #interpolators, #interpoltype=, #reverse

Methods included from Interpolation

#compute_simplebezier, #getcurve, #interpolate, #interpoltype, #linear, #samplelist, #simplebezier

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, #transform, #transforms, #trigger

Constructor Details

This class inherits a constructor from XRVG::Palette

Instance Method Details

#svgdefObject



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/color.rb', line 385

def svgdef
  template     = '<radialGradient id="%ID%" gradientUnits="userSpaceOnUse" cx="%cx%" cy="%cy%" r="%r%">%stops%</radialGradient>'
  stoptemplate = '<stop offset="%offset%" stop-color="%color%" stop-opacity="%opacity%"/>'
  
  stops = "\n"
  self.colorlist.foreach do |index, color|
    stops += stoptemplate.subreplace( {"%offset%" => index, "%color%" => color.svg, "%opacity%" => color.a} )
    stops += "\n"
  end
  
  return template.subreplace( {"%stops%" => stops,
		 "%cx%"    => circle.center.x,
		 "%cy%"    => circle.center.y,
		 "%r%"     => circle.radius} )
end