diff --git a/CHANGES.md b/CHANGES.md index 56f2a526f..ca1cf1fb5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ CeTZ 0.3.1 requires Typst 0.12.0. - Added a new `padding` parameter to the canvas element. - Some elements now support Typst 0.12.0 `fill-rule` style. +- Fixed an issue with reversed marks and `anchor: "center"`. # 0.3.0 diff --git a/README.md b/README.md index 3be0b1d55..5523cff27 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ For information, see the [online manual](https://cetz-package.github.io/docs). To use this package, simply add the following code to your document: ``` -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #cetz.canvas({ import cetz.draw: * @@ -59,7 +59,7 @@ just install The installed version can be imported by prefixing the package name with `@local`. ```typ -#import "@local/cetz:0.3.0" +#import "@local/cetz:0.3.1" #cetz.canvas({ import cetz.draw: * diff --git a/docs/getting-started.mdx b/docs/getting-started.mdx index 3c9c74ef0..2637abf70 100644 --- a/docs/getting-started.mdx +++ b/docs/getting-started.mdx @@ -8,7 +8,7 @@ sidebar_position: 1 This is the minimal starting point in a `.typ` file: ```typ -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #cetz.canvas({ import cetz.draw: * ... diff --git a/docs/tutorials/karl.mdx b/docs/tutorials/karl.mdx index 7170a411b..bfb9ce2ac 100644 --- a/docs/tutorials/karl.mdx +++ b/docs/tutorials/karl.mdx @@ -20,7 +20,7 @@ In CeTZ, to draw a picture, two imports and a function call is all you need. Kar ```typ #set page(width: auto, height: auto) -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" We are working on #cetz.canvas({ diff --git a/gallery/karls-picture.png b/gallery/karls-picture.png index 1ffd596d5..d943ccdfd 100644 Binary files a/gallery/karls-picture.png and b/gallery/karls-picture.png differ diff --git a/gallery/karls-picture.typ b/gallery/karls-picture.typ index 9582c925c..cb740073f 100644 --- a/gallery/karls-picture.typ +++ b/gallery/karls-picture.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #set page(width: auto, height: auto, margin: .5cm) #show math.equation: block.with(fill: white, inset: 1pt) diff --git a/gallery/tree.png b/gallery/tree.png index 9ce90a814..b735c2223 100644 Binary files a/gallery/tree.png and b/gallery/tree.png differ diff --git a/gallery/tree.typ b/gallery/tree.typ index dc9293262..e088e62a1 100644 --- a/gallery/tree.typ +++ b/gallery/tree.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0": canvas, draw, tree +#import "@preview/cetz:0.3.1": canvas, draw, tree #set page(width: auto, height: auto, margin: .5cm) diff --git a/gallery/waves.typ b/gallery/waves.typ index 74daaab76..56b385ed6 100644 --- a/gallery/waves.typ +++ b/gallery/waves.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0": canvas, draw, vector, matrix +#import "@preview/cetz:0.3.1": canvas, draw, vector, matrix #set page(width: auto, height: auto, margin: .5cm) diff --git a/src/anchor.typ b/src/anchor.typ index 9f25a475e..82f92edb2 100644 --- a/src/anchor.typ +++ b/src/anchor.typ @@ -2,8 +2,6 @@ #import deps.oxifmt: strfmt #import "util.typ" -#import util: typst-length - #import "intersection.typ" #import "drawable.typ" #import "path-util.typ" diff --git a/src/canvas.typ b/src/canvas.typ index cebefb64c..bb4ca9735 100644 --- a/src/canvas.typ +++ b/src/canvas.typ @@ -7,8 +7,6 @@ #import "process.typ" #import "version.typ" -#import util: typst-length - /// Sets up a canvas for drawing on. /// /// - length (length, ratio): Used to specify what 1 coordinate unit is. If given a ratio, that ratio is relative to the containing elements width! @@ -26,7 +24,7 @@ message: "Incorrect type for body: " + repr(type(body)), ) - assert(type(length) in (typst-length, ratio), message: "Expected `length` to be of type length or ratio, got " + repr(length)) + assert(type(length) in (std.length, ratio), message: "Expected `length` to be of type length or ratio, got " + repr(length)) let length = if type(length) == ratio { length * ly.width } else { @@ -120,7 +118,7 @@ vertices += pts } } - if type(drawable.stroke) == dictionary and "thickness" in drawable.stroke and type(drawable.stroke.thickness) != typst-length { + if type(drawable.stroke) == dictionary and "thickness" in drawable.stroke and type(drawable.stroke.thickness) != std.length { drawable.stroke.thickness *= length } path( @@ -131,7 +129,7 @@ ..vertices, ) } else if drawable.type == "content" { - let (width, height) = util.typst-measure(drawable.body) + let (width, height) = std.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, diff --git a/src/mark.typ b/src/mark.typ index 78b25e1c0..97e960587 100644 --- a/src/mark.typ +++ b/src/mark.typ @@ -7,8 +7,6 @@ #import "mark-shapes.typ": get-mark #import "process.typ" -#import util: typst-length - /// Checks if a mark should be drawn according to the current style. /// - style (style): The current style. /// -> bool diff --git a/src/util.typ b/src/util.typ index 059fe32c9..2b4175f64 100644 --- a/src/util.typ +++ b/src/util.typ @@ -5,14 +5,9 @@ #import "vector.typ" #import "bezier.typ" - /// Constant to be used as float rounding error #let float-epsilon = 0.000001 -#let typst-measure = measure -#let typst-length = length - - /// Multiplies vectors by a transformation matrix. If multiple vectors are given they are returned as an array, if only one vector is given only one will be returned, if a dictionary is given they will be returned in the dictionary with the same keys. /// /// - transform (matrix,function): The $4 \times 4$ transformation matrix or a function that accepts and returns a vector. @@ -200,7 +195,7 @@ /// - cnt (content): The content to measure. /// -> vector #let measure(ctx, cnt) = { - let size = typst-measure(cnt) + let size = std.measure(cnt) return ( calc.abs(size.width / ctx.length), calc.abs(size.height / ctx.length) diff --git a/src/version.typ b/src/version.typ index 05d47a08b..f26df2280 100644 --- a/src/version.typ +++ b/src/version.typ @@ -1 +1 @@ -#let version = version(0,3,0) +#let version = version(0,3,1) diff --git a/typst.toml b/typst.toml index 9e9d875c5..c15208384 100644 --- a/typst.toml +++ b/typst.toml @@ -1,6 +1,6 @@ [package] name = "cetz" -version = "0.3.0" +version = "0.3.1" compiler = "0.12.0" repository = "https://github.com/cetz-package/cetz" homepage = "https://cetz-package.github.io/"