class SyncSign::Widget::Circle

A widget that draws a circle.

Attributes

bgcolour[RW]
colour[RW]
fillpattern[RW]
radius[RW]
strokepattern[RW]

Public Class Methods

new(x: nil, y: nil, radius: nil, bgcolour: :white, colour: :black, fillpattern: :none, strokepattern: :solid, pen_width: 1) click to toggle source

Initialize a new circle widget. @param x [Integer] horizontal position of the centre of the circle. @param y [Integer] vertical position of the centre of the circle @param radius [Integer] The radius of the circle in pixels. @param colour [Symbol] The stroke colour used for the circle

(either black, white, or red).

@param bgcolour [Symbol] The fill colour used for the circle

(either black, white, or red).

@param fillpattern [Symbol] The fill pattern to use when filling the circle. @param strokepattern [Symbol] The stroke pattern to use when drawing the circle. @param pen_width [Integer] The thickness in pixels of the stroke.

Calls superclass method SyncSign::Widget::Item::new
# File lib/syncsign/widgets/circle.rb, line 20
def initialize(x: nil, y: nil, radius: nil, bgcolour: :white, colour: :black, fillpattern: :none, strokepattern: :solid, pen_width: 1)
  Widget::check_colours [colour, bgcolour]
  Widget::check_patterns [fillpattern, strokepattern]
  @radius = radius
  @colour = colour
  @bgcolour = bgcolour
  @fillpattern = fillpattern
  @strokepattern = strokepattern
  @pen_width = pen_width
  super(x: x, y:y)
end

Public Instance Methods

==(other) click to toggle source
# File lib/syncsign/widgets/circle.rb, line 48
def ==(other)
  @x == other.x                         &&
  @y == other.x                         &&
  @width == other.width                 &&
  @height == other.height               &&
  @radius == other.radius               &&
  @bgcolour == other.bgcolour           &&
  @colour == other.colour               &&
  @fillpattern == other.fillpattern     &&
  @strokepattern == other.strokepattern &&
  @pen_width == other.pen_width
end
to_a() click to toggle source

Convert the widget into an array for sending to the SyncSign service.

# File lib/syncsign/widgets/circle.rb, line 34
def to_a
  {
    'type': 'CIRCLE',
    'data': {
      'center': {x: @x, y: @y},
      'fillColor': @bgcolour.to_s.upcase,
      'fillPattern': @fillpattern.to_s.upcase,
      'strokeColor': @colour.to_s.upcase,
      'strokePattern': @strokepattern.to_s.upcase,
      'strokeThickness': @pen_width
    }
  }
end