package uk.co.nickthecoder.foocad.woodworking.v1 class Wood( val name : String, val profile : Shape2d ) : Customisable { constructor( name : String, width : double, thickness : double ) : this( name, Square( width, thickness ) ) constructor( name : String, width : double, thickness : double, color : Color ) : this( name, Square( width, thickness ).color( color ) ) constructor( name : String, width : double, thickness : double, color : String ) : this( name, Square( width, thickness ).color( Color.valueOf(color) ) ) @Custom val width = profile.size.x @Custom val thickness = profile.size.y meth width( width : double ) = Wood( name, Square( width, profile.size.y ).color(profile.color) ) meth thickness( thickness : double ) = Wood( name, Square( profile.size.x, thickness ).color(profile.color) ) meth color( color : Color ) = Wood( name, profile.color(color) ) meth color( color : String ) = Wood( name, profile.color(color) ) meth cut( length : double ) = CutPieceOfWood( this, length ) meth getSize() = profile.size meth size( side : int ) : Vector2 = if (side == Woodworking.FACE_SIDE || side == Woodworking.OPPOSITE_SIDE) { Vector2(width, thickness) } else { Vector2(thickness, width) } }