Skip to content

Commit

Permalink
Add an app for easy drawing.
Browse files Browse the repository at this point in the history
  • Loading branch information
zainab-ali committed Mar 16, 2024
1 parent badde05 commit b9ee6f4
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions core/src/main/scala/aquascape/AquascapeApp.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package aquascape

import cats.effect.*
import aquascape.drawing.Config
import doodle.java2d.*
import doodle.syntax.all.*
import doodle.core.format.*

object AquascapeApp {
trait Core {
def config: Config = Config.default

def stream(using Stage[IO]): IO[Unit]
}

trait Simple extends IOApp.Simple with Core {
def run: IO[Unit] = Stage
.unchunked[IO]
.flatMap { case t @ given Stage[IO] =>
stream(using t).draw()
}
.flatMap(_.drawToIO())
}
object Simple {
abstract class File(name: String) extends IOApp.Simple with Core {
def run: IO[Unit] = Stage
.unchunked[IO]
.flatMap { case t @ given Stage[IO] =>
stream(using t).draw()
}
.flatMap(_.writeToIO[Png](s"$name.png"))
}
}

trait Chunked extends IOApp.Simple with Core {
def run: IO[Unit] = Stage
.unchunked[IO]
.flatMap { case t @ given Stage[IO] =>
stream(using t).draw()
}
.flatMap(_.drawToIO())
}

object Chunked {
abstract class File(name: String) extends IOApp.Simple with Core {
def run: IO[Unit] = Stage
.chunked[IO]
.flatMap { case t @ given Stage[IO] =>
stream(using t).draw()
}
.flatMap(_.writeToIO[Png](s"$name.png"))
}
}
}

0 comments on commit b9ee6f4

Please sign in to comment.