Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit 6b983f5

Browse files
committed
Force minimum line width of 0.1, update readme
1 parent 0684ddb commit 6b983f5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ Here's an example usage of options:
4141
-p 3 -e parametric --transform="translate(10 10) rotate(30) skewX(10)" --latex --lenient
4242
```
4343

44+
If using the style script, the stroke width will most likely have to be tuned manually.
45+
This is because Desmos doesn't have an absolute stroke width, but rather the width is kept the same for
46+
all zoom levels. Therefore, the width must be adjusted for whatever zoom level will be used to view.
47+
Also note that the script can only set widths ranging from 0.1 to 25.5.
48+
4449
#### Current limitations
4550
- The only supported tag is `path`, and the only supported attributes are `d`, `transform`, `opacity`,
4651
`stroke-opacity`, `stroke` and `stroke-width`. Make sure to manually check your SVG file content before

app/src/main/kotlin/com/maltaisn/svgequations/main.kt

+10-5
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ fun main(args: Array<String>) {
9999
val tokens = pathTokenizer.tokenize(it.path)
100100
val curves = pathParser.parse(tokens)
101101
val color = colorParser.parse(it.color, it.opacity)
102-
val width = if (it.width != null) {
103-
(it.width.toDoubleOrNull() ?: parseError("Invalid stroke width")) * params.lineWidthMult
104-
} else {
105-
2.5 // default width
106-
}
102+
val width = parsePathWidth(it.width, params.lineWidthMult)
107103
val transform = if (it.transform != null) {
108104
transformParser.parse(it.transform)
109105
} else {
@@ -132,3 +128,12 @@ fun main(args: Array<String>) {
132128
}
133129

134130
}
131+
132+
private fun parsePathWidth(width: String?, mult: Double) =
133+
if (width != null) {
134+
// Parse line width. Force a minimum of 0.1 to avoid making lines invisible.
135+
((width.toDoubleOrNull() ?: parseError("Invalid stroke width")) * mult)
136+
.coerceAtLeast(0.1)
137+
} else {
138+
2.5 // default width
139+
}

0 commit comments

Comments
 (0)