Code Sketch
Republic Day Art(improved code)
By: Aditya Pant
Category: Art
1


0




size(775, 527) cleari() setAnimationDelay(0) originBottomLeft() initRandomGenerator(-4566063618077315813L) val bgc1 = cm.linearGradient(0, 0, Color(255, 222, 149), 0, cheight / 2, Color(173, 41, 0), false) val bg1 = fillColor(bgc1) * penColor(noColor) -> Picture.rectangle(cwidth, cheight / 2) val bgc2 = cm.linearGradient(0, 0, Color(0, 102, 45), 0, cheight / 2, Color(204, 204, 204), false) val bg2 = fillColor(bgc2) * penColor(noColor) -> Picture.rectangle(cwidth, cheight / 2) val bg = picColCentered(bg2, bg1) def building(n: Int) { repeat(2) { forward(n) right(90) forward(30) right(90) } right(90) hop(30) left(90) } def buildings = Picture { repeat(26) { building(random(40, 150)) } } def chakra = penColor(ColorMaker.hsl(219, 0.93, 0.60)) -> Picture { left(-90) hop(25) left(90) circle(25) right(-90) forward(50) hop(-25) left(90) hop(25) right(180) forward(50) hop(-25) right(45) hop(25) right(180) forward(50) hop(-25) right(90) hop(25) right(180) forward(50) } def city = picStack( buildings.withFillColor(white) .withPenColor(ColorMaker.hsl(0, 0.00, 0.93)) .withTranslation(0, cheight / 2 - 43), chakra .withTranslation(cwidth * 0.5 + 2.5, cheight * 0.5) ) def f = Picture { setFillColor(ColorMaker.hsl(0, 0.17, 0.21)) setPenColor(noColor) forward(60) left(90) forward(5) left(90) forward(60) left(90) forward(5) left(90) hop(60) right(90) setFillColor(cm.darkOrange) forward(40) right(90) forward(10) right(90) forward(40) right(180) setFillColor(white) forward(40) right(90) forward(10) right(90) forward(40) right(180) setFillColor(cm.green) forward(40) right(90) forward(10) right(90) forward(40) right(180) } val flag = picStack( f, chakra.withTranslation(20, 45) .withScaling(0.18) ) def text = Picture { setPenColor(white) write("Happy Republic Day!") } val pic = picStack( bg, city, flag.withTranslation(197, 367).withScaling(0.5), text.withTranslation(cwidth / 2 - 183, 120).withScaling(2) ) draw(pic)





Your Comment:





Login to post a comment