Module: Compass::Canvas::Functions::Canvas

Included in:
Compass::Canvas::Functions
Defined in:
lib/canvas/functions/canvas.rb

Overview

Functions for creating a canvas backend.

Instance Method Summary collapse

Instance Method Details

#canvas(*args) ⇒ Compass::Canvas::Backend

Creates a new Backend.

This function cannot be created in Sass as it is a variadic function.

Returns:



10
11
12
13
14
15
16
17
18
# File 'lib/canvas/functions/canvas.rb', line 10

def canvas(*args)
  backend = Compass.configuration.canvas_backend.sub(/^\w/) { |s| s.capitalize }
  begin
    klass = Compass::Canvas::Backend.const_get(backend)
  rescue NameError
    raise Compass::Canvas::Exception.new("(Compass::Canvas) '#{backend}' backend is not installed.")
  end
  klass.new(*Compass::Canvas::Functions.unpack(args).flatten)
end

#height_of(canvas) ⇒ Compass::Canvas::Backend

Gets the height of a Backend.

Returns:



30
31
32
# File 'lib/canvas/functions/canvas.rb', line 30

def height_of(canvas)
  Sass::Script::Number.new(canvas.property(:height))
end

#path_x(canvas) ⇒ Compass::Canvas::Backend

Gets the X position of the current path on a Backend.

Returns:



37
38
39
# File 'lib/canvas/functions/canvas.rb', line 37

def path_x(canvas)
  Sass::Script::Number.new(canvas.property(:x))
end

#path_y(canvas) ⇒ Compass::Canvas::Backend

Gets the Y position of the current path on a Backend.

Returns:



44
45
46
# File 'lib/canvas/functions/canvas.rb', line 44

def path_y(canvas)
  Sass::Script::Number.new(canvas.property(:y))
end

#width_of(canvas) ⇒ Compass::Canvas::Backend

Gets the width of a Backend.

Returns:



23
24
25
# File 'lib/canvas/functions/canvas.rb', line 23

def width_of(canvas)
  Sass::Script::Number.new(canvas.property(:width))
end