Class: Shoes::Arc

Inherits:
Common::ArtElement show all
Defined in:
shoes-core/lib/shoes/arc.rb

Overview

Note:

Angle is the gradient angle used across all art elements. Angle1/2 are the angles of the arc itself!

Note:

The angle passed in is measured in Radians starting at 90 degrees or the 3 o’clock position.

Arc. A basic element representing a curve of a circle or an oval.

Examples:

A simple arc which describes the bottom half of a circle and uses the centered style.

arc 200, 200, 100, 100, 0, Shoes::PI, center: true

An arc which describes the top half of a circle.

arc 200, 200, 100, 100, Shoes::PI, 0

Constant Summary collapse

STYLES =
{ wedge: false, fill: Shoes::COLORS[:black] }.freeze

Constants inherited from Common::ArtElement

Common::ArtElement::REDRAW_OFFSET_FACTOR, Common::ArtElement::REDRAW_SIZING_FACTOR

Constants included from Common::Style

Common::Style::DEFAULT_STYLES, Common::Style::STYLE_GROUPS

Instance Attribute Summary

Attributes included from Common::Clickable

#pass_coordinates

Attributes inherited from Common::UIElement

#app, #dimensions, #gui, #parent

Instance Method Summary collapse

Methods inherited from Common::ArtElement

#painted?, #redraw_height, #redraw_left, #redraw_top, #redraw_width

Methods included from Common::Translate

#clear_translate, #translate_left, #translate_top

Methods included from Common::Stroke

#update_stroke

Methods included from Common::Rotate

#needs_rotate?

Methods included from Common::Fill

#update_fill

Methods included from Common::Clickable

#click, #pass_coordinates?, #register_click, #release

Methods inherited from Common::UIElement

#add_to_parent, #after_initialize, #before_initialize, #create_backend, #handle_block, #initialize, #needs_rotate?, #painted?, #redraw_height, #redraw_left, #redraw_top, #redraw_width, #update_fill, #update_stroke

Methods included from Common::Style

#applicable_app_styles, #create_style_hash, included, #style, #style_init

Methods included from Common::SafelyEvaluate

#safely_evaluate

Methods included from Common::Remove

#remove

Methods included from Common::Positioning

#_position, #displace, #move

Methods included from Common::Visibility

#hidden?, #hidden_from_view?, #hide, #outside_parent_view?, #show, #toggle, #visible?

Methods included from Common::Inspect

#inspect, #to_s

Methods included from Common::Attachable

#attached_to

Constructor Details

This class inherits a constructor from Shoes::Common::UIElement

Instance Method Details

#center_pointShoes::Point

Access the center point of the arc.

Examples:

my_point = my_arc.center_point

Returns:



38
39
40
41
42
# File 'shoes-core/lib/shoes/arc.rb', line 38

def center_point
  center_x = left + (element_width * 0.5).to_i
  center_y = top + (element_height * 0.5).to_i
  Point.new(center_x, center_y)
end

#center_point=(point) ⇒ Object

Set the center point of an arc.

Examples:

Set an arc’s center point at the [x, y] coordinates [100, 300]

my_arc.center_point = Shoes::Point.new(100, 300)

Parameters:

  • point (Shoes::Point)

    the point to set as the center of the arc.



49
50
51
52
53
54
55
56
57
# File 'shoes-core/lib/shoes/arc.rb', line 49

def center_point=(point)
  if style[:center]
    self.left = point.x
    self.top = point.y
  else
    self.left = point.x - (width * 0.5).to_i
    self.top = point.y - (height * 0.5).to_i
  end
end

#create_dimensions(left, top, width, height, angle1, angle2) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'shoes-core/lib/shoes/arc.rb', line 17

def create_dimensions(left, top, width, height, angle1, angle2)
  @style[:angle1] = angle1 || @style[:angle1] || 0
  @style[:angle2] = angle2 || @style[:angle2] || 0

  left   ||= @style[:left] || 0
  top    ||= @style[:top] || 0
  width  ||= @style[:width] || 0
  height ||= @style[:height] || 0

  @dimensions = Dimensions.new parent, left, top, width, height, @style
end

#wedge?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'shoes-core/lib/shoes/arc.rb', line 29

def wedge?
  wedge
end