Class: CrystalScad::Color

Inherits:
CSGModifier show all
Defined in:
lib/crystalscad/CrystalScad.rb

Instance Attribute Summary

Attributes inherited from Primitive

#children

Attributes inherited from CrystalScadObject

#args, #transformations

Instance Method Summary collapse

Methods inherited from CSGModifier

#to_rubyscad

Methods inherited from Primitive

#mirror, #rotate, #rotate_around, #scale, #transform, #translate, #union

Methods inherited from CrystalScadObject

#method_missing, #save, #to_rubyscad, #walk_tree, #walk_tree_classes

Constructor Details

#initialize(object, attributes) ⇒ Color

Returns a new instance of Color.



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# File 'lib/crystalscad/CrystalScad.rb', line 476

def initialize(object, attributes)
	@operation = "color"
	if attributes.kind_of? String
		attributes = "\"#{attributes}\""			
	elsif attributes.kind_of? Hash
		attributes[:a] ||= 255
		
		r = attributes[:r].to_f / 255.0
		g = attributes[:g].to_f / 255.0
		b = attributes[:b].to_f / 255.0
		a = attributes[:a].to_f / 255.0
		attributes = [r,g,b,a]
	end
	
	super(object, attributes)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class CrystalScad::CrystalScadObject