这是indexloc提供的服务,不要输入任何密码
Skip to content

Allow gradient and pattern fills #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
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
2 changes: 1 addition & 1 deletion src/col-row-size.typ
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
}
}

if cell-fill != none and type(cell-fill) != _color_type {
if cell-fill != none and not is-color(cell-fill) {
panic("Tablex error: Invalid fill specified (must be either a function (column, row) -> fill, a color, an array of valid fill values, or 'none').")
}

Expand Down
2 changes: 1 addition & 1 deletion src/lines.typ
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// -- end imports --

#let parse-stroke(stroke) = {
if type(stroke) == _color_type {
if is-color(stroke) {
stroke + 1pt
} else if type(stroke) in (_length_type, _rel_len_type, _ratio_type, _stroke_type, _dict_type) or stroke in (none, auto) {
stroke
Expand Down
5 changes: 5 additions & 0 deletions src/type-validators.typ
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
type(len) == _length_type and "em" not in repr(len)
}

// Check if this is a valid color (color, gradient or pattern).
#let is-color(val) = {
type(val) == _color_type or str(type(val)) in ("gradient", "pattern")
}

#let validate-cols-rows(columns, rows, items: ()) = {
if type(columns) == _int_type {
assert(columns >= 0, message: "Error: Cannot have a negative amount of columns.")
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.typ
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
convert-length-to-pt(stroke, styles: styles)
} else if type(stroke) in (_rel_len_type, _ratio_type) {
panic(no-ratio-error)
} else if type(stroke) == _color_type {
} else if is-color(stroke) {
1pt
} else if type(stroke) == _stroke_type {
// support:
Expand Down