Class: CGPoint

Inherits:
Object
  • Object
show all
Defined in:
lib/project/cg_point.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.golden_section(options) ⇒ CGPoint

Given an x or y coordinate, returns a point with the other coordinate set to the golden section

Parameters:

  • options (hash)

    either the :x or :y coordinate, and optionally exponent

Returns:



7
8
9
# File 'lib/project/cg_point.rb', line 7

def self.golden_section(options)
  Golden_Sections.handler(Golden_Sections::CGPoint_relations, options, &Golden_Sections::CGPoint_proc)
end

Instance Method Details

#golden_section(direction = :both, exp = 1) ⇒ CGPoint

Returns a CGPoint with one or both coordinates as a golden section

Parameters:

  • direction (Symbol) (defaults to: :both)

    Which coordinate to modify - :x, :y, or :both, the default.

  • exp (Integer) (defaults to: 1)

    The exponent of the golden mean, defaults to 1

Returns:



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/project/cg_point.rb', line 15

def golden_section(direction=:both, exp=1)
if direction==:both
CGPoint.new(self.x.golden_section(exp), self.y.golden_section(exp))
elsif direction==:x
CGPoint.new(self.x.golden_section(exp), self.y)
elsif direction==:y
CGPoint.new(self.x, self.y.golden_section(exp))
else
  raise "CGPoint: unknown direction #{direction}"
end
end