rough-native
Version:
Create graphics using HTML Canvas or SVG with a hand-drawn, sketchy, appearance. Features comprehensive React hooks, memory management, and React 18 concurrent rendering support.
19 lines (18 loc) • 759 B
JavaScript
import { hachureLines } from 'hachure-fill';
import { CONFIG } from '../config';
export function polygonHachureLines(polygonList, o) {
var _a;
const angle = o.hachureAngle + CONFIG.FILL_PATTERN.HACHURE_ANGLE_ADJUSTMENT;
let gap = o.hachureGap;
if (gap < 0) {
gap = o.strokeWidth * CONFIG.FILL_PATTERN.DEFAULT_HACHURE_GAP_MULTIPLIER;
}
gap = Math.round(Math.max(gap, CONFIG.FILL_PATTERN.MIN_HACHURE_GAP));
let skipOffset = 1;
if (o.roughness >= 1) {
if ((((_a = o.randomizer) === null || _a === void 0 ? void 0 : _a.next()) || Math.random()) > CONFIG.FILL_PATTERN.HACHURE_SKIP_OFFSET_THRESHOLD) {
skipOffset = gap;
}
}
return hachureLines(polygonList, gap, angle, skipOffset || 1);
}