FooCAD Source Codeimport static uk.co.nickthecoder.foocad.circular.v1.Circular.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
class FlatBauble : Model {
var diameter = 84
var width=4
var line = 1.2
var thickness = 0.8
fun line(length : double) : Shape2d {
return Square( length, line ).centerY().roundAllCorners(line/2)
}
fun branch1() : Shape2d {
return line(10) +
line(2).rotate(60).translateX(3).mirrorY().also() +
line(3).rotate(60).translateX(5).mirrorY().also() +
line(3).rotate(60).translateX(7).mirrorY().also()
}
fun snowflake1() = branch1().repeatAround( 6 )
override fun build() : Shape3d {
val outside = Circle(diameter/2).sides(50)
val inside = outside.offset(-width)
val circle = outside - inside
val hook = (Square( 10, 10 ).center().roundAllCorners(3) -
Circle( 2 ).translateY(1)
).frontTo(inside.back)
val foo = Circle( diameter*1.5 ).sides(80).frontTo(diameter*0.13)
val strip = foo.offset(diameter*.29) - foo
val text = Text( "Mum", "Caladea:style=Italic", 14 )
.center().translateX(-1).aroundCircle( -diameter*1.5 )
.frontTo(-diameter*0.095)
val holes1 = Circle(1.5).sides(4).repeatX(10, 9)
.center().aroundCircle(-diameter*1.5)
.frontTo( -diameter* -0.08)
val holes2 = Circle(1.5).sides(4).repeatX(11, 9)
.center().aroundCircle(-diameter*1.5)
.frontTo(-diameter*0.145)
val mum = (strip - text - holes1 - holes2)
.rotate(10)
.translateY(-1)
val flake1 = snowflake1().scale(1.8).translate(22,-26) / outside
val flake2 = snowflake1().scale(1.3).translate(15,30) / outside
val flake3 = snowflake1().scale(1.0).translate(-21,32) / outside
val shape = circle + hook + mum / outside + flake1 + flake2 + flake3
return shape.extrude(thickness).color("Red")
}
}