-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draw: Add get-/set-ctx functions (#160)
- Loading branch information
1 parent
6c0154f
commit e5d1d6d
Showing
5 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#set page(width: auto, height: auto) | ||
#import "../../src/lib.typ": * | ||
|
||
#box(stroke: 2pt + red, canvas(length: 1cm, { | ||
import draw: * | ||
set-ctx(ctx => { | ||
ctx.my-custom-attribute = "123" | ||
return ctx | ||
}) | ||
|
||
get-ctx(ctx => { | ||
set-style(stroke: green) | ||
content((0, 0), ctx.my-custom-attribute, frame: "rect") | ||
}) | ||
|
||
// Note that the set-style is _not_ scoped! | ||
circle((0,0)) | ||
})) |