Skip to content

Commit

Permalink
Do not strok ab, ac and bc
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
johannes-wolf committed Jul 18, 2024
1 parent e5c8f51 commit ce73769
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/venn.typ
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
let keys = (
"fill": style.fill,
"stroke": style.stroke,
"ab-stroke": none,
"ac-stroke": none,
"bc-stroke": none,
)

let new = (:)
for combo in set-combinations {
for (key, def) in keys {
key = combo + "-" + key
new.insert(key, args.at(key, default: def))
new.insert(key, args.at(key, default: keys.at(key, default: def)))
}
}

return new
}

Expand Down Expand Up @@ -79,6 +83,11 @@
(rel: (+1 + padding, +1 + padding), to: pos-b),
fill: args.not-ab-fill, stroke: args.not-ab-stroke, name: "frame")

merge-path(name: "ab-shape", {
arc-through("ab.0", (rel: (-1, 0), to: pos-b), "ab.1")
arc-through("ab.1", (rel: (+1, 0), to: pos-a), "ab.0")
}, fill: args.ab-fill, stroke: args.ab-stroke, close: true)

merge-path(name: "a-shape", {
arc-through("ab.0", (rel: (-1, 0), to: pos-a), "ab.1")
arc-through("ab.1", (rel: (-1, 0), to: pos-b), "ab.0")
Expand All @@ -89,11 +98,6 @@
arc-through("ab.1", (rel: (+1, 0), to: pos-a), "ab.0")
}, fill: args.b-fill, stroke: args.b-stroke, close: true)

merge-path(name: "ab-shape", {
arc-through("ab.0", (rel: (-1, 0), to: pos-b), "ab.1")
arc-through("ab.1", (rel: (+1, 0), to: pos-a), "ab.0")
}, fill: args.ab-fill, stroke: args.ab-stroke, close: true)

anchor("a", (rel: (-1 + distance / 2, 0), to: pos-a))
anchor("b", (rel: (+1 - distance / 2, 0), to: pos-b))
anchor("ab", (pos-a, 50%, pos-b))
Expand Down Expand Up @@ -164,17 +168,6 @@
(rel: (+1 + padding, -1 - padding), to: (pos-b.at(0), pos-c.at(1))),
fill: args.not-abc-fill, stroke: args.not-abc-stroke, name: "frame")

for (name, angle) in (("a", 0deg), ("c", 360deg / 3), ("b", 2 * 360deg / 3)) {
merge-path(name: "a-shape", {
group({
rotate(angle)
arc-through(i-ab-0, (rel: (-1, 0), to: pos-a), i-ac-0)
arc-through((), (rel: cetz.vector.rotate-z((-1,0), angle-ac), to: pos-c), i-bc-1)
arc-through((), (rel: (-1, 0), to: pos-b), i-ab-0)
})
}, fill: args.at(name + "-fill"), stroke: args.at(name + "-stroke"), close: true)
}

for (name, angle) in (("ab", 0deg), ("ac", 360deg / 3), ("bc", 2 * 360deg / 3)) {
merge-path(name: name + "-shape", {
group({
Expand All @@ -192,6 +185,17 @@
arc-through((), (rel: cetz.vector.rotate-z((-1,0), (180deg + angle-ab + angle-bc) / 2), to: pos-b), i-ab-1)
}, fill: args.abc-fill, stroke: args.abc-stroke, close: true)

for (name, angle) in (("a", 0deg), ("c", 360deg / 3), ("b", 2 * 360deg / 3)) {
merge-path(name: "a-shape", {
group({
rotate(angle)
arc-through(i-ab-0, (rel: (-1, 0), to: pos-a), i-ac-0)
arc-through((), (rel: cetz.vector.rotate-z((-1,0), angle-ac), to: pos-c), i-bc-1)
arc-through((), (rel: (-1, 0), to: pos-b), i-ab-0)
})
}, fill: args.at(name + "-fill"), stroke: args.at(name + "-stroke"), close: true)
}

let a-a = cetz.vector.lerp(i-bc-0, i-bc-1, 1.5)
let a-b = cetz.vector.lerp(i-ac-0, i-ac-1, 1.5)
let a-c = cetz.vector.lerp(i-ab-0, i-ab-1, 1.5)
Expand Down
Binary file modified tests/venn2/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/venn3/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce73769

Please sign in to comment.