Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
crate: typst-test
git: https://github.com/tingerrr/typst-test.git
tag: ci-semi-stable
- uses: yusancky/setup-typst@v2
id: setup-typst
- uses: typst-community/setup-typst@v3
with:
version: 'v0.10.0'
typst-version: '0.11.0'
cache-dependency-path: src/deps.typ
- run: |
just install @local
just install @preview
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 0.3.0

CeTZ 0.3.0 requires Typst 0.11.0

# 0.2.2

Expand Down
2 changes: 1 addition & 1 deletion doc/style.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
description = description.map(e => if e.func() == heading {
let fields = e.fields()
let label = fields.remove("label", default: none)
heading(level: style-args.first-heading-level + 1 + fields.remove("level"), fields.remove("body"), ..fields); [#label]
heading(offset: style-args.first-heading-level + 1, fields.remove("body"), ..fields); [#label]
} else { e })

if parameter-index != none {
Expand Down
Binary file modified manual.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions requirements.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#import "/src/deps.typ"
#import "@preview/tidy:0.1.0"
#import "@preview/tidy:0.2.0"
#import "@preview/t4t:0.3.2"
10 changes: 4 additions & 6 deletions src/canvas.typ
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/// - background (none,color): A color to be used for the background of the canvas.
/// - debug (bool): Shows the bounding boxes of each element when `true`.
/// -> content
#let canvas(length: 1cm, debug: false, background: none, body) = layout(ly => style(st => {
#let canvas(length: 1cm, debug: false, background: none, body) = context { layout(ly => {
if body == none {
return []
}
Expand All @@ -34,18 +34,16 @@
let length = if type(length) == ratio {
length * ly.width
} else {
measure(box(width: length, height: length), st).width
length.to-absolute()
}
assert(length / 1cm != 0,
message: "Canvas length must be != 0!")

let ctx = (
typst-style: st,
length: length,
debug: debug,
// Previous element position & bbox
prev: (pt: (0, 0, 0)),
em-size: measure(box(width: 1em, height: 1em), st),
style: styles.default,
// Current transformation matrix, a lhs coordinate system
// where z is sheared by a half x and y.
Expand Down Expand Up @@ -130,7 +128,7 @@
..vertices,
)
} else if drawable.type == "content" {
let (width, height) = util.typst-measure(drawable.body, ctx.typst-style)
let (width, height) = util.typst-measure(drawable.body)
move(
dx: (drawable.pos.at(0) - bounds.low.at(0)) * length - width / 2,
dy: (drawable.pos.at(1) - bounds.low.at(1)) * length - height / 2,
Expand All @@ -139,4 +137,4 @@
}, dx: x * length, dy: y * length)
}
}))
}))
})}
5 changes: 2 additions & 3 deletions src/path-util.typ
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#import "@preview/oxifmt:0.2.0": strfmt

// This file contains utility functions for path calculation
#import "util.typ"
#import "vector.typ"
#import "bezier.typ"

#import "deps.typ"
#import deps.oxifmt: strfmt

#let default-samples = 25

Expand Down
14 changes: 5 additions & 9 deletions src/util.typ
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,12 @@
}

#let resolve-number(ctx, num) = {
if type(num) == length {
if repr(num).ends-with("em") {
float(repr(num).slice(0, -2)) * ctx.em-size.width / ctx.length
} else {
float(num / ctx.length)
}
return if type(num) == length {
float(num.to-absolute() / ctx.length)
} else if type(num) == ratio {
return num
num
} else {
return float(num)
float(num)
}
}

Expand Down Expand Up @@ -198,7 +194,7 @@

// Measure content in canvas coordinates
#let measure(ctx, cnt) = {
let size = typst-measure(cnt, ctx.typst-style)
let size = typst-measure(cnt)
return (
calc.abs(size.width / ctx.length),
calc.abs(size.height / ctx.length)
Expand Down
Binary file modified tests/anchor/element-anchors/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/angle/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/angle/right-angle/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/axes/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/bezier/shorten/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/chart/boxwhisker/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/chart/piechart/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/chart/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/content/anchor/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/content/intersection/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/content/padding/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/content/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/content/rotate/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/content/rtl/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/content/transform/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/coordinate/lerp/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/group/nested-anchor/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/group/transform/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/group/translate/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/hide/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/intersection/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/layer/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/line/element-element/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/plot/annotation/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/plot/boxwhisker/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/plot/contour/ref/1.png
Binary file modified tests/plot/equal-axis/ref/1.png
Binary file modified tests/plot/grid/ref/1.png
Binary file modified tests/plot/hvline/ref/1.png
Binary file modified tests/plot/legend/ref/1.png
Binary file modified tests/plot/line/between/ref/1.png
Binary file modified tests/plot/line/fill/ref/1.png
Binary file modified tests/plot/line/line-type/ref/1.png
Binary file modified tests/plot/line/linearization/ref/1.png
Binary file modified tests/plot/line/mark/ref/1.png
Binary file modified tests/plot/line/spline/ref/1.png
Binary file modified tests/plot/mirror-axes/ref/1.png
Binary file modified tests/plot/parametric/ref/1.png
Binary file modified tests/plot/ref/1.png
Binary file modified tests/plot/reverse-axis/ref/1.png
Binary file modified tests/plot/vertical/ref/1.png
Binary file modified tests/projection/ortho/ref/1.png
Binary file modified tests/relative-length/ref/1.png
Binary file modified tests/set-get-ctx/ref/1.png
Binary file modified tests/translation/ref/1.png
Binary file modified tests/tree/ref/1.png
Binary file modified tests/viewport/ref/1.png
3 changes: 2 additions & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "cetz"
version = "0.2.2"
compiler = "0.10.0"
compiler = "0.11.0"
repository = "https://github.com/johannes-wolf/cetz"
entrypoint = "src/lib.typ"
authors = [
"Johannes Wolf <https://github.com/johannes-wolf>",
"fenjalien <https://github.com/fenjalien>"
]
categories = [ "visualization" ]
license = "Apache-2.0"
description = "Drawing with Typst made easy, providing an API inspired by TikZ and Processing. Includes modules for plotting, charts and tree layout."
keywords = [ "draw", "canvas", "plot", "chart", "tree" ]
Expand Down