-
Notifications
You must be signed in to change notification settings - Fork 2
/
12.html
23 lines (23 loc) · 895 Bytes
/
12.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>12、图案填充</title>
</head>
<body>
<canvas id="c"></canvas>
<script src="./bower_components/jQuery/dist/jquery.js"></script>
<script src="./bower_components/fabric.js/dist/fabric.js"></script>
<script>
var canvas = new fabric.Canvas('c', { width: 500, height: 300, backgroundColor: '#ccc' });
fabric.util.loadImage('images/bg01.png', function (img) {
var pattern = new fabric.Pattern({ source: img, repeat: 'repeat' });
var points = [{ x: 185, y: 0 }, { x: 250, y: 100 }, { x: 385, y: 170 }, { x: 0, y: 245 }];
var polygon = new fabric.Polygon(points, { left: 10, top: 10, fill: pattern, objectCaching: false });
canvas.add(polygon);
});
</script>
</body>
</html>