Created
September 28, 2024 08:58
-
-
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/9c7e16bffb97f77648afe4e7f1ad87f3638bb0ad
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 NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// 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