Files
rough/visual-tests/canvas/dashed/polygon.html
Preet fd621f41c3 Dashed line support (#159)
* stroke line dash for canvas

* canvas fill dashes

* dashed line support in SVG
2020-05-11 00:29:33 -07:00

85 lines
1.8 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<title>RoughJS Polygon</title>
</head>
<body>
<canvas width="800" height="800"></canvas>
<script type="module">
import rough from '../../../bin/rough.js';
const canvas = document.querySelector('canvas');
const rc = rough.canvas(canvas, {
options: {
strokeLineDash: [15, 5],
strokeLineDashOffset: 10
}
});
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { stroke: 'black', strokeWidth: 2, fill: 'red', hachureAngle: 90 });
canvas.getContext('2d').translate(0, 210);
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { fill: 'red', fillStyle: 'solid' });
canvas.getContext('2d').translate(0, 210);
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { fill: 'red', fillStyle: 'dots', hachureGap: 16, fillWeight: 2 });
canvas.getContext('2d').translate(300, 0);
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { fill: 'red', fillStyle: 'cross-hatch', hachureGap: 8 });
canvas.getContext('2d').translate(0, -210);
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { fill: 'red', fillStyle: 'zigzag', hachureGap: 8 });
canvas.getContext('2d').translate(0, -210);
rc.polygon([
[10, 10],
[200, 10],
[100, 100],
[100, 50],
[300, 100],
[60, 200]
], { stroke: 'orange', strokeWidth: 5 });
</script>
</body>
</html>