Files
rough/visual-tests/canvas/path6.html
Preet eec4c6b5a8 .
2023-09-23 12:01:35 -07:00

98 lines
2.2 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 Curve</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);
const roughness = 2;
const path = `M 32 0 L 153.96380615234375 0 Q 185.96380615234375 0, 185.96380615234375 32 L 185.96380615234375 157.74319458007812 Q 185.96380615234375 189.74319458007812, 153.96380615234375 189.74319458007812 L 32 189.74319458007812 Q 0 189.74319458007812, 0 157.74319458007812 L 0 32 Q 0 0, 32 0`;
const ctx = rc.ctx;
ctx.translate(0, 50);
let shape = rc.path(path, {
roughness: roughness,
seed: 2142156371,
preserveVertices: true
});
ctx.translate(200, 0);
shape = rc.path(path, {
roughness: roughness,
seed: 2142156371,
preserveVertices: true,
fill: 'red',
hachureGap: 15
});
ctx.translate(200, 0);
shape = rc.path(path, {
roughness: roughness,
seed: 2142156371,
preserveVertices: true,
fill: 'red',
fillStyle: 'solid',
});
ctx.translate(200, 0);
shape = rc.path(path, {
roughness: roughness,
seed: 2142156371,
preserveVertices: true,
fill: 'red',
fillStyle: 'solid',
stroke: 'none'
});
ctx.resetTransform();
ctx.translate(0, 250);
rc.ellipse(110, 150, 180, 180, {
roughness: roughness,
seed: 2142156371,
});
ctx.translate(200, 0);
rc.ellipse(110, 150, 180, 180, {
roughness: roughness,
seed: 2142156371,
fill: 'red',
hachureGap: 15
});
ctx.translate(200, 0);
rc.ellipse(110, 150, 180, 180, {
roughness: roughness,
seed: 2142156371,
fill: 'red',
fillStyle: 'solid'
});
ctx.translate(200, 0);
rc.ellipse(110, 150, 180, 180, {
roughness: roughness,
seed: 2142156371,
fill: 'red',
fillStyle: 'solid',
stroke: 'none'
});
</script>
</body>
</html>