Skip to content

Commit

Permalink
Use integer for randomized hachure-gap. Fixes #98
Browse files Browse the repository at this point in the history
  • Loading branch information
fskpf committed Nov 18, 2023
1 parent dcde0cc commit 3b6d5cc
Show file tree
Hide file tree
Showing 125 changed files with 156 additions and 169 deletions.
30 changes: 21 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svg2roughjs",
"version": "3.1.3",
"version": "3.1.5",
"description": "Leverages Rough.js to convert SVGs to a hand-drawn, sketchy representation",
"author": "Fabian Schwarzkopf",
"contributors": [
Expand All @@ -27,7 +27,7 @@
"scripts": {
"prepare": "npm run lint && npm run build",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"clean": "rimraf dist/ && rimraf out-tsc/",
"clean": "rimraf -g *.tgz && rimraf dist/ && rimraf out-tsc/",
"lint": "eslint --ext .ts ./src",
"tsc": "tsc --noEmit",
"test-all": "npm run clean && tsc && wtr"
Expand Down
2 changes: 1 addition & 1 deletion sample-application/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function run() {
if (originalFontCheckbox.checked) {
svg2roughjs.fontFamily = null
} else {
svg2roughjs.fontFamily = 'Comic Sans MS, sans-serif'
svg2roughjs.fontFamily = 'Comic Sans MS, cursive'
}
setUIState(false)
await svg2roughjs.sketch()
Expand Down
4 changes: 2 additions & 2 deletions src/styles/pens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getPenConfiguration(fillStyle?: string): PenConfiguration {
},
gap: {
normal: [2, 5],
small: [1.5, 2]
small: [1, 3]
}
}

Expand All @@ -52,7 +52,7 @@ function getPenConfiguration(fillStyle?: string): PenConfiguration {
return {
...defaultConfig,
weight: { normal: [0.5, 3], small: [0.5, 2] },
gap: { normal: [3.5, 6], small: [2.5, 4.5] }
gap: { normal: [2, 6], small: [2, 5] }
}
case 'cross-hatch':
return {
Expand Down
2 changes: 1 addition & 1 deletion src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function parseStyleConfig(
if (context.randomize) {
const { angle, gap, weight } = createPen(context, element)
config.hachureAngle = angle
config.hachureGap = gap
config.hachureGap = Math.round(gap) // must be integer (avg gap in pixels)
config.fillWeight = parseFloat(weight.toFixed(precision)) // value is used in the sketched output as-is
// randomize double stroke effect if not explicitly set through user config
if (typeof config.disableMultiStroke === 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion test/complex/bpmn-diagram/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/complex/bpmn-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/computer-network-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/flowchart-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/hierarchical1-diagram/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"hachure","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/complex/hierarchical1-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/hierarchical2-diagram/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"hachure","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/complex/hierarchical2-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/mindmap-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/movies-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/organic1-diagram/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"hachure","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/complex/organic1-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/organic2-diagram/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"hachure","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/complex/organic2-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/complex/tree-diagram/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/specs/circle-transform/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/specs/clippath-circle-transformed/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/specs/clippath-circle-transformed/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/specs/clippath-circle/config.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"roughConfig":{"bowing":0,"roughness":0,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
{"roughConfig":{"bowing":1,"roughness":1,"fillStyle":"solid","fixedDecimalPlaceDigits":3,"seed":4242},"outputType":0,"pencilFilter":false,"sketchPatterns":true,"backgroundColor":"white"}
2 changes: 1 addition & 1 deletion test/specs/clippath-circle/expect.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3b6d5cc

Please sign in to comment.