Exit Full View
Up

/Words/Outline.foocad

Outline
FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.Debug.*
/**
    Creates outlines of a single letter.
    There is a better version Outline2.foocad.

    Note, there is a similar script House/HouseNumbers.foocad,
    which has screw attachments.

    I created this for my front door.

    WARNING. This may fail for large widths and bezels. The *inside* of the shape
    Only works for a single character. Also fails for characters with holes. Ooops.
*/
class Outline : Model {
    
    @Custom
    var letter = "0"

    @Custom
    var style = TextStyle( "Liberation Sans", 90)

    @Custom
    var thickness = 4.0

    @Custom
    var width = 1.0

    @Custom
    var bevel = 2.0

    override fun build() : Shape3d {

        val text = Text( letter, style )

        val result = ExtrusionBuilder().apply {
            crossSection( text.offset(width + bevel*2) )
            forward( thickness )
            crossSection( -bevel )
            crossSection( -width )
            forward( -thickness )
            crossSection( -bevel )
        }.buildClosed()

        return result
    }
}