fogleman / gg

Go Graphics - 2D rendering in Go with a simple API.
https://godoc.org/github.com/fogleman/gg
MIT License
4.37k stars 354 forks source link

How to clip a picture of a polygon through a path #129

Closed JoiLa closed 3 years ago

JoiLa commented 3 years ago

Hi,Man~ I want to consult how to cut out the drawn path image information and output it to the new content through the drawing of the path

source picture: https://img-blog.csdnimg.cn/20210308113406132.png Effect picture after cutting: https://img-blog.csdnimg.cn/20210308113621684.png

JoiLa commented 3 years ago

I've tried some ways, but I don't know what's better to do with my business scenarios. Because there are complex custom paths, such as star and diamond, to process the selected path image

JoiLa commented 3 years ago

I tried this examples rotated-image.go ,Solved my problem

The main code is

dc.??Preserve()
dc.Clip()
dc.DrawImageAnchored(im, ...)