Last active
February 3, 2026 20:24
-
-
Save dacr/4c61abf30699250ab5f6e9900fd6dafb to your computer and use it in GitHub Desktop.
simple doodle animation ex / published by https://github.com/dacr/code-examples-manager #0a41d9e2-c5d8-4c18-9276-41dd071e3989/b9b1b6eaed636e92815d6dcd30b07d94b1b43eb4
This file contains hidden or 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 : simple doodle animation ex | |
| // keywords : scala, vector-graphics, doodle, examples | |
| // publish : gist | |
| // authors : Noel Welsh, David Crosson | |
| // license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) | |
| // id : 0a41d9e2-c5d8-4c18-9276-41dd071e3989 | |
| // created-on : 2024-09-28T10:52:16+02:00 | |
| // managed-by : https://github.com/dacr/code-examples-manager | |
| // run-with : scala-cli $file | |
| // --------------------- | |
| //> using scala "3.5.1" | |
| //> using dep "org.creativescala::doodle:0.26.0" | |
| // --------------------- | |
| import cats.effect.IO | |
| import doodle.core.* | |
| import doodle.syntax.* | |
| import doodle.syntax.all.* | |
| import doodle.interact.* | |
| import doodle.interact.syntax.* | |
| import doodle.interact.syntax.all.* | |
| import doodle.java2d.* | |
| import doodle.java2d.effect.* | |
| import fs2.Stream | |
| import cats.effect.unsafe.implicits.global | |
| import scala.concurrent.duration.{FiniteDuration, MILLISECONDS} | |
| import cats.instances.all._ | |
| import cats.syntax.all._ | |
| val frame: Frame = Frame( | |
| size = Size.fixedSize(600, 600), | |
| title = "Photos", | |
| center = Center.atOrigin, | |
| background = Some(Color.midnightBlue), | |
| redraw = Redraw.clearToBackground | |
| ) | |
| val ball = | |
| -100.0 | |
| .upTo(100.0) | |
| .map(x => | |
| Picture | |
| .circle(30) | |
| .fillColor(Color.chartreuse) | |
| .strokeWidth(3.0) | |
| .at(x, 0.0) | |
| ) | |
| .forSteps(100) | |
| .repeatForever | |
| ball | |
| .animate(frame) | |
| scala.io.StdIn.readLine("Enter to exit...") // required when run as a script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment