Add an algebra for clipping
Overview
Most 2D backends have a notion of clipping, which basically means restricting where drawing can take place. We don't expose clipping in Doodle but it would be straightforward to define an algebra for clipping and implement it on a backend or two, and it opens up a lot of creative possibilities.
Details
Tasks:
- [ ] Investigate how clipping is exposed in various 2D backends. I think it's basically a single operation that requires a path
- [ ] Define algebra for clipping operation(s)
- [ ] Implement for at least Java 2D
Assuming it's a single operation, the clipping algebra could look like
trait Clip extends Algebra {
def clip[A](img: Drawing[A], path: ClosedPath): Drawing[A]
}
@noelwelsh Hello, I hope that you are well , this is my first time contributing. I know about clipping from my experience in dealing with images. What I understand is that I have to implement the clipping types (points, line, ellipse, etc.) and I have an idea to use Path2D from java.awt.geom. Am I right?
@noelwelsh Hello, I hope that you are well , this is my first time contributing. I know about clipping from my experience in dealing with images. What I understand is that I have to implement the clipping types (points, line, ellipse, etc.) and I have an idea to use
Path2Dfromjava.awt.geom. Am I right?
I don't think there is quite enough detail in your description that I'm confident I understand what you mean.
There are two parts to this:
-
defining the path that should be used to clip the
Picture. There is aleady a ClosedPath type in Doodle that can be used for this. -
implementing clipping on the different backends. This is where
Path2Dwould be used (in the Java2D backend). There is alread code to do this conversion.
Does that help clear things up?
I'll take this up! @noelwelsh please assign
can you please assign this issue to me
can you please assign this issue to me
We don't assign issues to people, as the project is small enough that we don't need this formality (and, in the past, people have been assigned issues they have never completed). I've added a little section at https://www.creativescala.org/doodle/development/process.html that describes this a bit more.