class Circle
class Circle
lib/geometry/circle.tya:2
Circle provides the geometry/Circle standard library API.
Source
# Circle provides the geometry/Circle standard library API.
class Circle
# Circle.radius stores instance state.
# @type Int
radius: 0
# Circle.x stores instance state.
# @type Int
x: 0
# Circle.y stores instance state.
# @type Int
y: 0
# Circle.initialize provides the geometry/Circle standard library operation.
# @param x Int x value.
# @param y Int y value.
# @param radius Any radius value.
# @return Self the initialized object.
initialize: x = 0, y = 0, radius = 0 ->
self.x = self.number(x, "x")
self.y = self.number(y, "y")
self.radius = self.radius_value(radius)
# Circle.area provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
area: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
3.141592653589793 * circle.radius * circle.radius
# Circle.bounding_rect provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
bounding_rect: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
Rect(
circle.x - circle.radius,
circle.y - circle.radius,
circle.radius * 2,
circle.radius * 2
)
# Circle.center provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
center: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
Point(circle.x, circle.y)
# Circle.circumference provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
circumference: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
2 * 3.141592653589793 * circle.radius
# Circle.contains_point? provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param point Any point value.
# @return Boolean whether the condition is true.
contains_point?: circle, point = nil ->
if point == nil
point = circle
circle = self
self.expect(circle, "circle")
Point(0, 0).expect(point, "point")
Point(0, 0).distance(self.center(circle), point) <= circle.radius
# Circle.equal? provides the geometry/Circle standard library operation.
# @param a Int a value.
# @param b Int b value.
# @return Boolean whether the condition is true.
equal?: a, b = nil ->
if b == nil
b = a
a = self
a.class == Circle and b.class == Circle and a.x == b.x and a.y == b.y and a.radius == b.radius
# Circle.expect provides the geometry/Circle standard library operation.
# @param value String value value.
# @param name String name value.
# @return Any the resulting value.
expect: value, name ->
if value.class != Circle
raise error("geometry.Circle: " + name + " must be a Circle")
# Circle.from_center provides the geometry/Circle standard library operation.
# @param center Any center value.
# @param radius Any radius value.
# @return Self the resulting value.
from_center: center, radius ->
Point(0, 0).expect(center, "center")
Circle(center.x, center.y, radius)
# Circle.intersects_circle? provides the geometry/Circle standard library operation.
# @param a Int a value.
# @param b Int b value.
# @return Boolean whether the condition is true.
intersects_circle?: a, b = nil ->
if b == nil
b = a
a = self
self.expect(a, "a")
self.expect(b, "b")
Point(0, 0).distance(self.center(a), self.center(b)) <= a.radius + b.radius
# Circle.intersects_rect? provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param rect Any rect value.
# @return Boolean whether the condition is true.
intersects_rect?: circle, rect = nil ->
if rect == nil
rect = circle
circle = self
self.expect(circle, "circle")
Rect(0, 0, 0, 0).expect(rect, "rect")
geometry_clamped = Rect(0, 0, 0, 0).clamp_point(rect, self.center(circle))
self.contains_point?(circle, geometry_clamped)
# Circle.new provides the geometry/Circle standard library operation.
# @param x Int x value.
# @param y Int y value.
# @param radius Any radius value.
# @return Self the resulting value.
new: x, y, radius ->
Circle(x, y, radius)
# Circle.number provides the geometry/Circle standard library operation.
# @param value String value value.
# @param name String name value.
# @return Any the resulting value.
number: value, name ->
if value.class != Number
raise error("geometry.Circle: " + name + " must be a number")
value
# Circle.radius_value provides the geometry/Circle standard library operation.
# @param value String value value.
# @return Any the resulting value.
radius_value: value ->
self.number(value, "radius")
if value < 0
raise error("geometry.Circle: radius must be non-negative")
value
# Circle.translate provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param vector Any vector value.
# @return Any the resulting value.
translate: circle, vector = nil ->
if vector == nil
vector = circle
circle = self
self.expect(circle, "circle")
if vector.class != Vector2
raise error("geometry.Circle.translate: vector must be a Vector2")
Circle(circle.x + vector.x, circle.y + vector.y, circle.radius)
Instance Variables
radius
Circle.radius
lib/geometry/circle.tya:5
Circle.radius stores instance state.
Source
# Circle.radius stores instance state.
# @type Int
radius: 0
x
Circle.x
lib/geometry/circle.tya:9
Circle.x stores instance state.
Source
# Circle.x stores instance state.
# @type Int
x: 0
y
Circle.y
lib/geometry/circle.tya:13
Circle.y stores instance state.
Source
# Circle.y stores instance state.
# @type Int
y: 0
Methods
area
Circle.area(circle = nil)
lib/geometry/circle.tya:28
Circle.area provides the geometry/Circle standard library operation.
Source
# Circle.area provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
area: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
3.141592653589793 * circle.radius * circle.radius
bounding_rect
Circle.bounding_rect(circle = nil)
lib/geometry/circle.tya:37
Circle.bounding_rect provides the geometry/Circle standard library operation.
Source
# Circle.bounding_rect provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
bounding_rect: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
Rect(
circle.x - circle.radius,
circle.y - circle.radius,
circle.radius * 2,
circle.radius * 2
)
center
Circle.center(circle = nil)
lib/geometry/circle.tya:51
Circle.center provides the geometry/Circle standard library operation.
Source
# Circle.center provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
center: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
Point(circle.x, circle.y)
circumference
Circle.circumference(circle = nil)
lib/geometry/circle.tya:60
Circle.circumference provides the geometry/Circle standard library operation.
Source
# Circle.circumference provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @return Any the resulting value.
circumference: circle = nil ->
if circle == nil
circle = self
self.expect(circle, "circle")
2 * 3.141592653589793 * circle.radius
contains_point?
Circle.contains_point?(circle, point = nil)
lib/geometry/circle.tya:70
Circle.contains_point? provides the geometry/Circle standard library operation.
Source
# Circle.contains_point? provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param point Any point value.
# @return Boolean whether the condition is true.
contains_point?: circle, point = nil ->
if point == nil
point = circle
circle = self
self.expect(circle, "circle")
Point(0, 0).expect(point, "point")
Point(0, 0).distance(self.center(circle), point) <= circle.radius
equal?
Circle.equal?(a, b = nil)
lib/geometry/circle.tya:82
Circle.equal? provides the geometry/Circle standard library operation.
Source
# Circle.equal? provides the geometry/Circle standard library operation.
# @param a Int a value.
# @param b Int b value.
# @return Boolean whether the condition is true.
equal?: a, b = nil ->
if b == nil
b = a
a = self
a.class == Circle and b.class == Circle and a.x == b.x and a.y == b.y and a.radius == b.radius
expect
Circle.expect(value, name)
lib/geometry/circle.tya:92
Circle.expect provides the geometry/Circle standard library operation.
Source
# Circle.expect provides the geometry/Circle standard library operation.
# @param value String value value.
# @param name String name value.
# @return Any the resulting value.
expect: value, name ->
if value.class != Circle
raise error("geometry.Circle: " + name + " must be a Circle")
from_center
Circle.from_center(center, radius)
lib/geometry/circle.tya:100
Circle.from_center provides the geometry/Circle standard library operation.
Source
# Circle.from_center provides the geometry/Circle standard library operation.
# @param center Any center value.
# @param radius Any radius value.
# @return Self the resulting value.
from_center: center, radius ->
Point(0, 0).expect(center, "center")
Circle(center.x, center.y, radius)
initialize
Circle.initialize(x = 0, y = 0, radius = 0)
lib/geometry/circle.tya:20
Circle.initialize provides the geometry/Circle standard library operation.
Source
# Circle.initialize provides the geometry/Circle standard library operation.
# @param x Int x value.
# @param y Int y value.
# @param radius Any radius value.
# @return Self the initialized object.
initialize: x = 0, y = 0, radius = 0 ->
self.x = self.number(x, "x")
self.y = self.number(y, "y")
self.radius = self.radius_value(radius)
intersects_circle?
Circle.intersects_circle?(a, b = nil)
lib/geometry/circle.tya:108
Circle.intersects_circle? provides the geometry/Circle standard library operation.
Source
# Circle.intersects_circle? provides the geometry/Circle standard library operation.
# @param a Int a value.
# @param b Int b value.
# @return Boolean whether the condition is true.
intersects_circle?: a, b = nil ->
if b == nil
b = a
a = self
self.expect(a, "a")
self.expect(b, "b")
Point(0, 0).distance(self.center(a), self.center(b)) <= a.radius + b.radius
intersects_rect?
Circle.intersects_rect?(circle, rect = nil)
lib/geometry/circle.tya:120
Circle.intersects_rect? provides the geometry/Circle standard library operation.
Source
# Circle.intersects_rect? provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param rect Any rect value.
# @return Boolean whether the condition is true.
intersects_rect?: circle, rect = nil ->
if rect == nil
rect = circle
circle = self
self.expect(circle, "circle")
Rect(0, 0, 0, 0).expect(rect, "rect")
geometry_clamped = Rect(0, 0, 0, 0).clamp_point(rect, self.center(circle))
self.contains_point?(circle, geometry_clamped)
new
Circle.new(x, y, radius)
lib/geometry/circle.tya:134
Circle.new provides the geometry/Circle standard library operation.
Source
# Circle.new provides the geometry/Circle standard library operation.
# @param x Int x value.
# @param y Int y value.
# @param radius Any radius value.
# @return Self the resulting value.
new: x, y, radius ->
Circle(x, y, radius)
number
Circle.number(value, name)
lib/geometry/circle.tya:141
Circle.number provides the geometry/Circle standard library operation.
Source
# Circle.number provides the geometry/Circle standard library operation.
# @param value String value value.
# @param name String name value.
# @return Any the resulting value.
number: value, name ->
if value.class != Number
raise error("geometry.Circle: " + name + " must be a number")
value
radius_value
Circle.radius_value(value)
lib/geometry/circle.tya:149
Circle.radius_value provides the geometry/Circle standard library operation.
Source
# Circle.radius_value provides the geometry/Circle standard library operation.
# @param value String value value.
# @return Any the resulting value.
radius_value: value ->
self.number(value, "radius")
if value < 0
raise error("geometry.Circle: radius must be non-negative")
value
translate
Circle.translate(circle, vector = nil)
lib/geometry/circle.tya:159
Circle.translate provides the geometry/Circle standard library operation.
Source
# Circle.translate provides the geometry/Circle standard library operation.
# @param circle Any circle value.
# @param vector Any vector value.
# @return Any the resulting value.
translate: circle, vector = nil ->
if vector == nil
vector = circle
circle = self
self.expect(circle, "circle")
if vector.class != Vector2
raise error("geometry.Circle.translate: vector must be a Vector2")
Circle(circle.x + vector.x, circle.y + vector.y, circle.radius)