Home > front end >  How do I on the canvas drawing pictures to polygon
How do I on the canvas drawing pictures to polygon

Time:11-26

As title, I want to make a picture painted on the canvas of a polygon, but seems CanvasRenderingContext2D drawing picture interface only rectangular, how should do?

CodePudding user response:

Recommend the use of the fabric. Js operation canvas address: http://fabricjs.com/

CodePudding user response:

You said this might call shear CTX. Clip ();
Work principle is, first a shear area (such as a polygon), then no matter what you paint pictures or, as long as it is beyond the content of the shear zone, won't be displayed,

CodePudding user response:

First draw the path of the polygon, then use pictures as a fill style fill

CTX. FillStyle=CTX. CreatePattern (image, "no - repeat");
CTX. The fill ();
  • Related