Class: CGSize

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.golden_section(options) ⇒ CGSize

Returns the new CGSize object.

Parameters:

  • options (Hash)

    the width or height, and optionally exponent

Returns:

  • (CGSize)

    the new CGSize object



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

def self.golden_section(options)
Golden_Sections::handler(Golden_Sections::CGSize_relations, options, &Golden_Sections::CGSize_proc)
end

Instance Method Details

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

Returns the new object.

Parameters:

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

    :width, :height, or :both, the default

  • exp (Integer) (defaults to: 1)

    the exponent of the golden mean, defaults to 1

Returns:



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

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