import 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 NamedBauble : Model { var name = "STEVE ♥ KATY ♥ " var size = 60.0 var thickness = 1.0 var hole = 1.6 var repeat = 6 var around = 50 override fun build() : Shape3d { val text = Text(name,BOLD).resolution(1).convexity(10) .extrude(thickness*1.5).center() val scaledText = text.scale( size / 2 /text.size.x*6, size * 0.25 / text.size.y, 1 ) val height = scaledText.size.y * 1.2 val l = height * Math.sqrt(2) / repeat val grid = Cube( l/4, l, l/4 ) .tileY(repeat) .rotateZ(45).center() .repeatX(around,Math.PI * size / around) .rotateX(90) .aroundCylinder( size/2 ) .mirrorX().also() val topAndBottom = (Circle(size/2 + thickness/2) - Circle( size/2 - thickness/2)) .extrude(2).translateZ(height/2) .mirrorZ().also() val around = scaledText .rotateX(90) .aroundCylinder( size/2 ) .mirrorX() .darker() val hooks = (Circle( 4 ).sides(3) - Circle( 2 ).sides(3)) .extrude( thickness ) .center() .rotateY(-90) .translate( size/2, 0, height + 6 ) .repeatAroundZ( 3 ) return (around + topAndBottom + grid).bottomTo(0) + hooks } }