Class: Compass::Canvas::Backend::Interface::Pattern
- Inherits:
-
Base
- Object
- Sass::Script::Literal
- Base
- Compass::Canvas::Backend::Interface::Pattern
- Defined in:
- lib/canvas/backend/interface/pattern.rb
Overview
Interface Pattern class.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#brush(*args) ⇒ Object
Unpacks brush arguments to a Ruby object.
-
#dash_pattern(*pattern) ⇒ Object
Unpacks dash
pattern
arguments to Ruby objects. -
#mask(*args) ⇒ Object
Unpacks
canvas
and optional arguments to a Ruby object.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Compass::Canvas::Backend::Interface::Base
Instance Method Details
#brush(*args) ⇒ Object
Unpacks brush arguments to a Ruby object.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/canvas/backend/interface/pattern.rb', line 5 def brush(*args) if args.length == 1 type = args.shift if type.is_a?(Sass::Script::Color) [Compass::Canvas::Constants::SOLID, Pattern.split(type)] elsif type.is_a?(Sass::Script::String) && type.value == Compass::Canvas::Actions::RETRIEVE.to_s [Compass::Canvas::Actions::RETRIEVE] elsif type.is_a?(Compass::Canvas::Backend::Base) [Compass::Canvas::Constants::CANVAS, type] else raise Compass::Canvas::Exception.new("(#{self.class}.#{@action}) Unsupported solid brush type: #{type.inspect}") end elsif args.length == 2 canvas = args.shift extends = args.shift if canvas.is_a?(Compass::Canvas::Backend::Base) && extends.is_a?(Sass::Script::String) [Compass::Canvas::Constants::CANVAS, canvas, extends.value] else raise Compass::Canvas::Exception.new("(#{self.class}.#{@action}) Unsupported pattern brush type: #{canvas.inspect}") end elsif args.length > 4 index = 0 index = index + 1 while index < args.length && args[index].is_a?(Sass::Script::Number) type = Compass::Canvas::Constants::LINEAR if index == 4 type = Compass::Canvas::Constants::RADIAL if index == 6 if type [type, args.slice(0, index).map { |value| value.value }, Pattern.stops(args.slice(index, args.length))] else raise Compass::Canvas::Exception.new("(#{self.class}.#{@action}) Unsupported gradient brush type: #{args.inspect}") end else raise Compass::Canvas::Exception.new("(#{self.class}.#{@action}) Unsupported brush type: #{args.inspect}") end end |
#dash_pattern(*pattern) ⇒ Object
Unpacks dash pattern
arguments to Ruby objects.
41 42 43 |
# File 'lib/canvas/backend/interface/pattern.rb', line 41 def dash_pattern(*pattern) pattern.map { |value| value.value } end |
#mask(*args) ⇒ Object
Unpacks canvas
and optional arguments to a Ruby object.
46 47 48 49 50 51 52 |
# File 'lib/canvas/backend/interface/pattern.rb', line 46 def mask(*args) type = args.shift if type.is_a?(Sass::Script::String) && type.value == Compass::Canvas::Actions::RETRIEVE.to_s type = Compass::Canvas::Actions::RETRIEVE end [type].concat(args.map { |value| value.value }) end |