Class: Plushie::Canvas::Shape::CanvasText

Inherits:
Data
  • Object
show all
Defined in:
lib/plushie/canvas/shape/canvas_text.rb

Overview

Text drawn on a canvas.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x:, y:, content:, fill: nil, size: nil, font: nil, opacity: nil) ⇒ CanvasText

Returns a new instance of CanvasText.



8
9
10
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 8

def initialize(x:, y:, content:, fill: nil, size: nil, font: nil, opacity: nil)
  super
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content

Returns:

  • (Object)

    the current value of content



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def content
  @content
end

#fillObject (readonly)

Returns the value of attribute fill

Returns:

  • (Object)

    the current value of fill



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def fill
  @fill
end

#fontObject (readonly)

Returns the value of attribute font

Returns:

  • (Object)

    the current value of font



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def font
  @font
end

#opacityObject (readonly)

Returns the value of attribute opacity

Returns:

  • (Object)

    the current value of opacity



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def opacity
  @opacity
end

#sizeObject (readonly)

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def size
  @size
end

#xObject (readonly)

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



7
8
9
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 7

def y
  @y
end

Instance Method Details

#[](key) ⇒ Object

Access shape properties by key.

Parameters:

  • key (Symbol)

Returns:

  • (Object)


16
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 16

def [](key) = to_wire[key]

#to_wireObject

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.

Encode shape for the wire protocol.



20
21
22
23
24
25
26
27
# File 'lib/plushie/canvas/shape/canvas_text.rb', line 20

def to_wire
  h = {type: "text", x: x, y: y, content: content}
  h[:fill] = fill if fill
  h[:size] = size if size
  h[:font] = font if font
  h[:opacity] = opacity if opacity
  h
end