draw2d icon indicating copy to clipboard operation
draw2d copied to clipboard

Is opacity/masking in the plans?

Open stephenwithav opened this issue 10 years ago • 4 comments

If anyone's working on adding it already, please speak up. :)

image/draw's private drawGlyphOver func could be a good starting point.

stephenwithav avatar Aug 19 '15 22:08 stephenwithav

Yes we need a clipping path Api. For draw2dimg a MaskPainter can be used so that we can use drawGlyphOver or sth. For opacity we have alpha of RGBA, we can already use opacity.

llgcode avatar Aug 20 '15 07:08 llgcode

gofpdf supports already some clipping:

func (f *Fpdf) ClipCircle(x, y, r float64, outline bool)
func (f *Fpdf) ClipEllipse(x, y, rx, ry float64, outline bool)
func (f *Fpdf) ClipEnd()
func (f *Fpdf) ClipPolygon(points []PointType, outline bool)
func (f *Fpdf) ClipRect(x, y, w, h float64, outline bool)
func (f *Fpdf) ClipRoundedRect(x, y, w, h, r float64, outline bool)
func (f *Fpdf) ClipText(x, y float64, txtStr string, outline bool)

http://godoc.org/github.com/jung-kurt/gofpdf

I guess this should be doable, also for different clipping shapes/paths. I can always extend gofpdf if necessary. However I would prefer if first we can complete the low level api before adding new features.

stanim avatar Aug 20 '15 07:08 stanim

I agree, pdf, ps svg already have clipping capability, I prefer to implement it in draw2dimg before.

I was thinking of a method gc.Clip() that clip a path

llgcode avatar Aug 20 '15 07:08 llgcode

Has the low-level API been decided upon yet?

@llgcode the alpha values work to a point, but produce incorrect output when drawing one image over another. (Using draw.DrawMask produces the correct output, so I'll use that for now.)

stephenwithav avatar Aug 20 '15 08:08 stephenwithav