Class: Ruby2D::Square
Overview
A square
Constant Summary
Constants included from Interactive
Interactive::OBJECT_EVENTS, Interactive::OBJECT_EVENT_FILTER_PREDICATES
Instance Attribute Summary collapse
-
#size ⇒ Object
Returns the value of attribute size.
Attributes inherited from Quad
#fill, #rotate, #stroke_color, #stroke_width, #x1, #x2, #x3, #x4, #y1, #y2, #y3, #y4
Attributes included from Renderable
#color, #height, #padding_bottom, #padding_left, #padding_right, #padding_top, #visible, #width, #x, #x_align, #y, #y_align, #z
Class Method Summary collapse
-
.render(x: 0, y: 0, size: 100, rotate: 0, rx: nil, ry: nil, color: nil, colour: nil, opacity: nil, fill: true, stroke_width: 0, stroke_color: nil, stroke_colour: nil) ⇒ Object
Render a square without creating an instance Render a square without creating an instance.
Instance Method Summary collapse
Methods inherited from Rectangle
#contains?, #height=, #rx, #ry, #width=, #x, #x=, #y, #y=
Methods inherited from Quad
#color=, #contains?, #height, #rx, #rx=, #ry, #ry=, #width, #x, #x=, #y, #y=
Methods included from Renderable
#_alignment_anchor_dx, #_alignment_anchor_dy, #_apply_padding, #_extract_alignment, #_point_in_polygon?, #_point_on_segment?, #_render_scene, #_require_numeric_position, #_resolve_alignment, #_unrotate, #_validate_dimensions, #add, #colour=, #contains?, flatten_color, flatten_per_vertex, flatten_points, flatten_resolved_color, #hide, #opacity, #opacity=, #padding=, #remove, resolve_color_or_default, resolve_single_color, #show
Methods included from Interactive
#_fire_event, #interactive?, #off, #on
Constructor Details
#initialize(x: 0, y: 0, size: 100, z: 0, rotate: 0, rx: nil, ry: nil, color: nil, colour: nil, opacity: nil, fill: true, stroke_width: 0, stroke_color: nil, stroke_colour: nil, add: true, visible: true, padding: nil, padding_top: nil, padding_right: nil, padding_bottom: nil, padding_left: nil) ⇒ Square
Create a square
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby2d/square.rb', line 9 def initialize(x: 0, y: 0, size: 100, z: 0, rotate: 0, rx: nil, ry: nil, color: nil, colour: nil, opacity: nil, fill: true, stroke_width: 0, stroke_color: nil, stroke_colour: nil, add: true, visible: true, padding: nil, padding_top: nil, padding_right: nil, padding_bottom: nil, padding_left: nil) _validate_dimensions(size: size) @size = size super(x: x, y: y, width: size, height: size, z: z, rotate: rotate, rx: rx, ry: ry, color: color, colour: colour, opacity: opacity, fill: fill, stroke_width: stroke_width, stroke_color: stroke_color, stroke_colour: stroke_colour, add: add, visible: visible, padding: padding, padding_top: padding_top, padding_right: padding_right, padding_bottom: padding_bottom, padding_left: padding_left) end |
Instance Attribute Details
#size ⇒ Object
Returns the value of attribute size.
6 7 8 |
# File 'lib/ruby2d/square.rb', line 6 def size @size end |
Class Method Details
.render(x: 0, y: 0, size: 100, rotate: 0, rx: nil, ry: nil, color: nil, colour: nil, opacity: nil, fill: true, stroke_width: 0, stroke_color: nil, stroke_colour: nil) ⇒ Object
Render a square without creating an instance
Render a square without creating an instance. Calls the positional
internal directly rather than super — see Quad.draw_immediate.
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby2d/square.rb', line 35 def self.render(x: 0, y: 0, size: 100, rotate: 0, rx: nil, ry: nil, color: nil, colour: nil, opacity: nil, fill: true, stroke_width: 0, stroke_color: nil, stroke_colour: nil) draw_immediate(x, y, x + size, y, x + size, y + size, x, y + size, rotate, rx || x + size / 2.0, ry || y + size / 2.0, color || colour, opacity, fill, stroke_width, stroke_color || stroke_colour) end |