Last active
August 18, 2023 07:29
-
-
Save dacr/a4dc2ceb1ae5836670038b8ee20ef890 to your computer and use it in GitHub Desktop.
Playing basics vector graphics using doodle library. / published by https://github.com/dacr/code-examples-manager #21cf7cd4-e493-4375-ade4-9aa82568daae/605ae089b2794bc97ecbd75d60d1bc9388992e6a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// summary : Playing basics vector graphics using doodle library. | |
// keywords : scala, vector-graphics, doodle | |
// publish : gist | |
// authors : David Crosson | |
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// id : 21cf7cd4-e493-4375-ade4-9aa82568daae | |
// created-on : 2019-06-25T16:47:49Z | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
// --------------------- | |
//> using scala "3.3.0" | |
//> using dep "org.creativescala::doodle:0.20.0" | |
// --------------------- | |
// doodle home page : https://github.com/creativescala/doodle/tree/master | |
// more info : https://www.youtube.com/watch?v=ENiyUi2IWJE | |
// Adapted example coming from https://www.creativescala.org/doodle/ | |
import doodle.core.* | |
import doodle.syntax.* | |
import doodle.image.* | |
// Extension methods | |
import doodle.image.syntax.* | |
import doodle.syntax.all.* | |
import doodle.image.syntax.all.* | |
import cats.effect.unsafe.implicits.global | |
// Render to a window using Java2D (must be running in the JVM) | |
import doodle.java2d.* | |
val blackSquare = Image.rectangle(30, 30).fillColor(Color.black) | |
val redSquare = Image.rectangle(30, 30).fillColor(Color.red) | |
// A chessboard, broken into steps showing the recursive construction | |
val twoByTwo = (redSquare.beside(blackSquare)).above(blackSquare.beside(redSquare)) | |
val fourByFour = (twoByTwo.beside(twoByTwo)).above(twoByTwo.beside(twoByTwo)) | |
val chessboard = (fourByFour.beside(fourByFour)).above(fourByFour.beside(fourByFour)) | |
val drawn = chessboard.rotate(45.degrees).draw() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment