Class: Sevgi::Geometry::Circle

Inherits:
Ellipse show all
Defined in:
lib/sevgi/geometry/elements/circle.rb

Overview

Complete circular boundary with a positive radius and a center. Uniform scaling preserves Circle. General affine transforms can return Ellipse.

Examples:

Create an upper semicircle from a circle

Sevgi::Geometry::Circle[10].arc(starting_angle: 180, extent: 180)

Instance Attribute Summary

Attributes inherited from Ellipse

#position, #rotation, #rx, #ry

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ellipse

#approx, #arc, #box, #circular?, #empty?, #equation, #equations, #initialize, #inside?, #length, #on?, #perimeter, #point, #reflect, #rotate, #scale, #skew, #skew_x, #skew_y, #translate

Methods inherited from Element::Arced

#eq?, #eql?, #hash, #outside?

Methods inherited from Element

#at, #box, #closed?, #equations, #ignorable?, #intersection, lined, #position, #translate

Constructor Details

This class inherits a constructor from Sevgi::Geometry::Ellipse

Class Method Details

.[](radius, position: Origin) ⇒ Sevgi::Geometry::Circle

Builds a circle from its radius and center.

Parameters:

  • radius (Numeric) —

    positive finite radius

  • position (Sevgi::Geometry::Point, Array<Numeric>) (defaults to: Origin) —

    circle center

Returns:

Raises:



15
# File 'lib/sevgi/geometry/elements/circle.rb', line 15

def self.[](radius, position: Origin) = new(radius, radius, position:, rotation: 0)

Instance Method Details

#draw(node, **attributes) ⇒ Object

Draws a native SVG circle without rounding the geometry.

Parameters:

  • node (Object) —

    graphics node receiving the circle

  • attributes (Hash) —

    SVG attributes

Returns:

  • (Object) —

    graphics command result



21
# File 'lib/sevgi/geometry/elements/circle.rb', line 21

def draw(node, **attributes) = node.circle(cx: position.x, cy: position.y, r: radius, **attributes)

#radius ⇒ Float

Returns the circle radius.

Returns:

  • (Float)


25
# File 'lib/sevgi/geometry/elements/circle.rb', line 25

def radius = rx