Gradient Part 5b: Fix gradients in math (#2604)

This commit is contained in:
Sébastien d'Herbais de Thun 2023-11-07 12:09:51 +01:00 committed by GitHub
parent 4d5255d9cb
commit 241a6d9e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 74 additions and 6 deletions

View File

@ -108,7 +108,7 @@ impl LayoutMath for CancelElem {
let length = self.length(styles).resolve(styles);
let stroke = self.stroke(styles).unwrap_or(FixedStroke {
paint: TextElem::fill_in(styles),
paint: TextElem::fill_in(styles).as_decoration(),
..Default::default()
});

View File

@ -143,7 +143,7 @@ fn layout(
line_pos,
FrameItem::Shape(
Geometry::Line(Point::with_x(line_width)).stroked(FixedStroke {
paint: TextElem::fill_in(ctx.styles()),
paint: TextElem::fill_in(ctx.styles()).as_decoration(),
thickness,
..FixedStroke::default()
}),

View File

@ -225,7 +225,7 @@ impl GlyphFragment {
c,
font: ctx.font.clone(),
lang: TextElem::lang_in(ctx.styles()),
fill: TextElem::fill_in(ctx.styles()),
fill: TextElem::fill_in(ctx.styles()).as_decoration(),
shift: TextElem::baseline_in(ctx.styles()),
style: ctx.style,
font_size: ctx.size,

View File

@ -397,7 +397,7 @@ fn layout_mat_body(
let default_stroke_thickness = DEFAULT_STROKE_THICKNESS.scaled(ctx);
let default_stroke = FixedStroke {
thickness: default_stroke_thickness,
paint: TextElem::fill_in(ctx.styles()),
paint: TextElem::fill_in(ctx.styles()).as_decoration(),
line_cap: LineCap::Square,
..Default::default()
};

View File

@ -122,7 +122,7 @@ fn layout(
line_pos,
FrameItem::Shape(
Geometry::Line(Point::with_x(radicand.width())).stroked(FixedStroke {
paint: TextElem::fill_in(ctx.styles()),
paint: TextElem::fill_in(ctx.styles()).as_decoration(),
thickness,
..FixedStroke::default()
}),

View File

@ -96,7 +96,7 @@ fn layout_underoverline(
line_pos,
FrameItem::Shape(
Geometry::Line(Point::with_x(width)).stroked(FixedStroke {
paint: TextElem::fill_in(ctx.styles()),
paint: TextElem::fill_in(ctx.styles()).as_decoration(),
thickness: bar_height,
..FixedStroke::default()
}),

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,68 @@
// Test that gradients are applied correctly on equations.
---
// Test on cancel
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ a dot cancel(5) = cancel(25) 5 x + cancel(5) 1 $
---
// Test on frac
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ nabla dot bold(E) = frac(rho, epsilon_0) $
---
// Test on root
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ x_"1,2" = frac(-b +- sqrt(b^2 - 4 a c), 2 a) $
---
// Test on matrix
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ A = mat(
1, 2, 3;
4, 5, 6;
7, 8, 9
) $
---
// Test on underover
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ underline(X^2) $
$ overline("hello, world!") $
---
// Test a different direction
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow, dir: ttb))
#show math.equation: box
$ A = mat(
1, 2, 3;
4, 5, 6;
7, 8, 9
) $
$ x_"1,2" = frac(-b +- sqrt(b^2 - 4 a c), 2 a) $
---
// Test miscelaneous
#show math.equation: set text(fill: gradient.linear(..color.map.rainbow))
#show math.equation: box
$ hat(x) = bar x bar = vec(x, y, z) = tilde(x) = dot(x) $
$ x prime = vec(1, 2, delim: "[") $
$ sum_(i in NN) 1 + i $
$ attach(
Pi, t: alpha, b: beta,
tl: 1, tr: 2+3, bl: 4+5, br: 6,
) $