- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is HTML5 canvas and image on polygon possible?
Yes, it is possible. Create a pattern using the image, and then set the pattern to fillStyle.
Here, obj is our image object −
var context = canvas.getContext("2d"); var pattern = context.createPattern(obj, "repeat"); context.fillStyle = pattern;
You need to manipulate the image to fit an arbitrary polygon −
context.save(); context.setTransform(m11, m12, m21, m22, dx, dy); context.drawImage(obj); context.restore();
- Related Articles
- Play video on canvas and preserve the last frame/image on HTML5 Canvas
- Change colour of an image drawn on an HTML5 canvas element.
- Load image from url and draw to HTML5 Canvas
- HTML5 Canvas Font Size Based on Canvas Size
- HTML5 Canvas layer disappears on mouse click in Fabric.js and Firefox stops responding when creating a canvas for the image?
- Draw part of an image inside HTML5 canvas
- addEventListener for keydown on HTML5 Canvas
- Update HTML5 canvas rectangle on hover
- HTML5 drawImage() method to draw image onto the canvas
- World Map on HTML5 Canvas or SVG
- How to detect point on canvas after canvas rotation in HTML5
- Drawing an SVG file on an HTML5 canvas
- Measure text height on an HTML5 canvas element
- Enhance real-time performance on HTML5 canvas effects
- How to draw large font on HTML5 Canvas?

Advertisements