Code Sketch


Gen-art #1 created by Aditya Pant
By: Anusha Pant
cleari()
size(900, 900)
setBackground(white)

initRandomGenerator(1365921688707445988L)

val pic1 = Picture {
    setPenColor(black)
    setPenThickness(.1)
    def shape() {
        //    savePosHe()
        val n = 3 + random(5)
        repeat(n) {
            forward(200 / n)
            right(360 / n)
        }
        //    restorePosHe()
    }

    val cb = canvasBounds
    val nx = 17
    val ny = 30
    val dx = cb.width / (nx + 1)
    val dy = (cb.height - 340) / (ny + 1)

    var currX = 1
    var currY = 1
    var heading = 90
    def block() {
        setFillColor(randomColor.fadeOut(0.9))
        if (currX > nx) {
            currX = 1
            currY += 1
        }
        val px = cb.x + currX * dx
        val py = cb.y + currY * dy
        setPosition(px, py)
        setHeading(heading)
        shape()
        currX += 1
        heading += 10
    }

    repeat(nx * ny) {
        block()
    }
}

val pic2 = Picture {
    def shape() {
        setFillColor(randomColor.fadeOut(0.2))
        repeat(2) {
            forward(50)
            right(60, 20)
            forward(50)
            right(120, 20)
        }
    }
    def block() {
        shape()
        right(60)
    }
    def shape2() {

        repeat(6) {
            block()
        }
    }
    def block2() {
        shape2()
        hop(50)
        penUp()
        right(60, 100)
        penDown()
    }
    setPenColor(darkGray)
    setPenThickness(3)
    repeat(6) {
        block2()
    }
}

val pic3 = Picture {
    val f = Font("Noto Serif", 65)
    setPenFont(f)
    setPenColor(cm.purple)
    write("Made with Code")
}

val pic4 = Picture {
    val f = Font("Consolas", 35)
    setPenFont(f)
    setPenColor(cm.black)
    write("www.kojo.in")
}

val kojoIcon = {
    val kojo = Picture {
        setFillColor(red.fadeOut(0.3))
        setPenColor(noColor)
        savePosHe()
        hop(-50)
        right(90)
        hop(60)
        left(90)
        circle(40)
        restorePosHe()
        val fsize = 90
        val te = textExtent("k", fsize)
        setPenColor(white)
        setPenFont(Font("Blackadder ITC", fsize))
        write("k")
        setPenColor(black)
        hop(-31)
        right()
        hop(te.width + 8)
        left()
        setPenFont(Font("Consolas", 60))
        write("ojo")
    }

    val playCreateLearn = Picture {
        setPenColor(darkGray)
        setPenFont(Font("Noto Serif", 25))
        write("play . create . learn")
    }

    val pic = picStack(playCreateLearn, trans(39, 90) -> kojo)
    pic
}

val text = picColCentered(pic4, pic3)

val logo1 = kojoIcon

val reachaText = Picture {
    setPenColor(Color(218, 20, 0))
    setPenFont(Font("Noto Serif", 50))
    write("REACHA")
}

val logos = logo1

val shapes = picStackCentered(pic1, pic2)
val finalPic = picColCentered(text, shapes, Picture.vgap(2), logos)

drawCentered(finalPic)