creativescala / doodle

Compositional vector graphics in Scala / Scala.JS
https://creativescala.org/doodle/
Apache License 2.0
327 stars 75 forks source link

Adding clipping to doodle [Draft] #157

Closed VOSID8 closed 4 months ago

VOSID8 commented 4 months ago

I'm done with the Algebra, Syntax, Constructor and now working on Java2d Backend. Clipit is the end implementation, taking clipping area as Closed Path as argument as it was intended to.

@main def hello(): Unit =
  val closed = ClosedPath.empty
                  .moveTo(80, -60)
                  .lineTo(10, 10).lineTo(10, 60).lineTo(80, 60).lineTo(80, -60)
  val blackSquare = Picture.triangle(200, 100).fillColor(Color.red).clipit(closed)
  blackSquare.draw()

Right now with the Java2dClip.scala file where after the setClip is done, when doing Clip, java.awt.Shape is required as argument where I have Drawing[A], and need to return vice versa.

[error] 20 |    gg.clip(image) //Graphics2D.clip() requires java.awt.Shape as argument 
[error]    |            ^^^^^
[error]    |            Found:    (image : Java2dClip.this.Drawing[A])
[error]    |            Required: java.awt.Shape