doodle icon indicating copy to clipboard operation
doodle copied to clipboard

Add an algebra for clipping

Open noelwelsh opened this issue 3 years ago • 5 comments

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 avatar May 20 '22 20:05 noelwelsh

@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?

medmabcf avatar Mar 13 '24 15:03 medmabcf

@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?

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 Path2D would be used (in the Java2D backend). There is alread code to do this conversion.

Does that help clear things up?

noelwelsh avatar Mar 14 '24 09:03 noelwelsh

I'll take this up! @noelwelsh please assign

VOSID8 avatar Apr 04 '24 20:04 VOSID8

can you please assign this issue to me

Shehrozkashif avatar Aug 26 '24 10:08 Shehrozkashif

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.

noelwelsh avatar Aug 26 '24 21:08 noelwelsh