Code Sketch


Digital-Clock
By: Nitin Mishra
def clock() {
    val f = java.time.format.DateTimeFormatter.ofPattern("hh:mm:ss a")
    val currentTime = java.time.LocalTime.now().format(f)
    val pTime = Picture.text(
        currentTime,
        Font("Digital-7 Italic", 180)

    ).withTranslation(-370, 250)

    pTime.draw()
    pause(1)
    pTime.erase()
    clock()
}
val cb = canvasBounds
val vgap = Picture.vgap(10)
val dformat = java.time.format.DateTimeFormatter.ofPattern("dd-MM-yyyy")
val date = java.time.LocalDate.now().format(dformat).toString
val day = java.time.LocalDate.now().getDayOfWeek.toString
val datePic = Picture.text(date, Font("Digital-7 Italic", 170))
val dayPic = Picture.text(day, Font("Digital-7 Italic", 130))
val ddPic = picColCentered(dayPic, vgap, datePic).withTranslation(-180, -120)
val border = Picture.rect(cheight - 40, cwidth - 40)
.withTranslation(cb.x + 20, cb.y + 20)
.withPenThickness(5)
.withPenColor(white)

//toggleFullScreenCanvas()
cleari
setBackground(black)
draw(ddPic, border)
clock