Skip to content

Commit

Permalink
Release 0.3.1 (#727)
Browse files Browse the repository at this point in the history
* release: 0.3.1

* canvas: Use Typst 12 std module
  • Loading branch information
johannes-wolf authored Oct 19, 2024
1 parent bfdc0e7 commit 98ac77a
Show file tree
Hide file tree
Showing 15 changed files with 14 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: *
Expand All @@ -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: *
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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: *
...
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/karl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Binary file modified gallery/karls-picture.png
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 gallery/karls-picture.typ
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Binary file modified gallery/tree.png
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 gallery/tree.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion gallery/waves.typ
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 0 additions & 2 deletions src/anchor.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions src/canvas.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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 {
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions src/mark.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/util.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/version.typ
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#let version = version(0,3,0)
#let version = version(0,3,1)
2 changes: 1 addition & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down

0 comments on commit 98ac77a

Please sign in to comment.