import static uk.co.nickthecoder.foocad.changefilament.v1.ChangeFilament.* import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.* import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.* class WordSheet : Model, PostProcessor { // -1 : Three puzzles that help put all the pieces back! // 0.. size of a,b,c,d lists : Four puzzles of similar difficulty @Custom var piece = 0 var size = 60 var radius = 5 var fontSize = 9 var base = 0.4 // At least 2 layers. I use a layer height of 0.2. var textHeight = 0.4 // At least 2 layers especially if changing colours. val a = listOf("SPY\nJAR", "PEN\nSAT", "RID\nUTE", "PIE\nWAR") val b = listOf("SKY\nWAR", "PIE\nTIN", "KEY\nPAD", "RUN\nAPE") val c = listOf("STY\nPAD", "TIP\nDIE", "PET\nSIN", "NUT\nPIE" ) val d = listOf("RAD\nSET", "PET\nAID", "TIN\nEAR", "TOE\nNAP" ) val difficulty = listOf( 5, 4, 3, 3 ) fun txt( str : String ) = Text( str, BOLD, fontSize ).hAlign(CENTER).center().translate( -size/4, -size/4 ) override fun build() : Shape3d { val square = Square( size ).roundAllCorners( radius ).center().color("White") val edge = square - Square( size - 1 ).roundAllCorners( radius - 0.5 ).center() val top : Shape2d = if (piece == -1) { txt("WE SKIT").translate(size/4,4 * size/7) + txt("I DO JAR" ).translate(size/4, size/4) + txt( "PUNY" ).translate(size/4, -size/14) } else { txt(a[piece]) + txt(b[piece]).rotate(90) + txt(c[piece]).rotate(180) + txt(d[piece]).rotate(-90) } // Create a difficulty indicator 1..5 squares 5 = very hard 2 = Easy val diff = if (piece <0 ) 0 else difficulty[piece] val center = Square(2).center().translateX(3).repeatAround( diff, 360/diff ) return square.extrude( base ) + edge.extrude( base + textHeight ) + top.extrude( base + textHeight ).color("DimGray" ) + center.extrude( base + textHeight ).color( "DimGray" ) } override fun postProcess(gcode: GCode) { pauseAtHeight( gcode, base, "Change Filament" ) } }