Skip to content

Commit

Permalink
Merge pull request rough-stuff#222 from rough-stuff/fraction-gap
Browse files Browse the repository at this point in the history
round the gap value for the algorithm
  • Loading branch information
pshihn authored Nov 20, 2023
2 parents 4293e89 + d0f5081 commit 56a2762
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 61 deletions.
118 changes: 59 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "roughjs",
"version": "4.6.5",
"version": "4.6.6",
"description": "Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance.",
"main": "bundled/rough.cjs.js",
"module": "bundled/rough.esm.js",
Expand Down
2 changes: 1 addition & 1 deletion src/fillers/scan-line-hachure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function polygonHachureLines(polygonList: Point[][], o: ResolvedOptions):
if (gap < 0) {
gap = o.strokeWidth * 4;
}
gap = Math.max(gap, 0.1);
gap = Math.round(Math.max(gap, 0.1));
let skipOffset = 1;
if (o.roughness >= 1) {
if ((o.randomizer?.next() || Math.random()) > 0.7) {
Expand Down
26 changes: 26 additions & 0 deletions visual-tests/svg/rectangle2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!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 Rectangle</title>
</head>

<body>
<svg width="800" height="800"></svg>

<script type="module">
import rough from '../../bin/rough.js';
const svg = document.querySelector('svg');
const rc = rough.svg(svg);

svg.appendChild(rc.rectangle(10, 10, 280, 280, {
fill: 'red',
hachureGap: 1.7
}));

</script>
</body>

</html>

0 comments on commit 56a2762

Please sign in to comment.