From a4e357fb37d76d32d06ad8cc21e47bb2cc064cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20d=27Herbais=20de=20Thun?= Date: Tue, 3 Oct 2023 19:31:02 +0200 Subject: Gradient Part 2 - Linear gradients (#2279) --- crates/typst-library/src/visualize/image.rs | 2 +- crates/typst-library/src/visualize/line.rs | 2 +- crates/typst-library/src/visualize/mod.rs | 1 + crates/typst-library/src/visualize/path.rs | 4 ++-- crates/typst-library/src/visualize/polygon.rs | 2 +- crates/typst-library/src/visualize/shape.rs | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/typst-library/src/visualize') diff --git a/crates/typst-library/src/visualize/image.rs b/crates/typst-library/src/visualize/image.rs index b4a9015f..b0c9d8ea 100644 --- a/crates/typst-library/src/visualize/image.rs +++ b/crates/typst-library/src/visualize/image.rs @@ -206,7 +206,7 @@ impl Layout for ImageElem { // First, place the image in a frame of exactly its size and then resize // the frame to the target size, center aligning the image in the // process. - let mut frame = Frame::new(fitted); + let mut frame = Frame::soft(fitted); frame.push(Point::zero(), FrameItem::Image(image, fitted, self.span())); frame.resize(target, Axes::splat(FixedAlign::Center)); diff --git a/crates/typst-library/src/visualize/line.rs b/crates/typst-library/src/visualize/line.rs index 9960a2d3..6837caf1 100644 --- a/crates/typst-library/src/visualize/line.rs +++ b/crates/typst-library/src/visualize/line.rs @@ -75,7 +75,7 @@ impl Layout for LineElem { let size = start.max(start + delta).max(Size::zero()); let target = regions.expand.select(regions.size, size); - let mut frame = Frame::new(target); + let mut frame = Frame::soft(target); let shape = Geometry::Line(delta.to_point()).stroked(stroke); frame.push(start.to_point(), FrameItem::Shape(shape, self.span())); Ok(Fragment::frame(frame)) diff --git a/crates/typst-library/src/visualize/mod.rs b/crates/typst-library/src/visualize/mod.rs index a013853f..e39d50bc 100644 --- a/crates/typst-library/src/visualize/mod.rs +++ b/crates/typst-library/src/visualize/mod.rs @@ -18,6 +18,7 @@ use crate::prelude::*; pub(super) fn define(global: &mut Scope) { global.category("visualize"); global.define_type::(); + global.define_type::(); global.define_type::(); global.define_elem::(); global.define_elem::(); diff --git a/crates/typst-library/src/visualize/path.rs b/crates/typst-library/src/visualize/path.rs index c252e95f..79364b07 100644 --- a/crates/typst-library/src/visualize/path.rs +++ b/crates/typst-library/src/visualize/path.rs @@ -82,7 +82,7 @@ impl Layout for PathElem { let mut size = Size::zero(); if points.is_empty() { - return Ok(Fragment::frame(Frame::new(size))); + return Ok(Fragment::frame(Frame::soft(size))); } // Only create a path if there are more than zero points. @@ -138,7 +138,7 @@ impl Layout for PathElem { Smart::Custom(stroke) => stroke.map(Stroke::unwrap_or_default), }; - let mut frame = Frame::new(size); + let mut frame = Frame::soft(size); let shape = Shape { geometry: Geometry::Path(path), stroke, fill }; frame.push(Point::zero(), FrameItem::Shape(shape, self.span())); diff --git a/crates/typst-library/src/visualize/polygon.rs b/crates/typst-library/src/visualize/polygon.rs index 9f573467..1d19a94d 100644 --- a/crates/typst-library/src/visualize/polygon.rs +++ b/crates/typst-library/src/visualize/polygon.rs @@ -130,7 +130,7 @@ impl Layout for PolygonElem { .collect(); let size = points.iter().fold(Point::zero(), |max, c| c.max(max)).to_size(); - let mut frame = Frame::new(size); + let mut frame = Frame::hard(size); // Only create a path if there are more than zero points. if points.is_empty() { diff --git a/crates/typst-library/src/visualize/shape.rs b/crates/typst-library/src/visualize/shape.rs index 64d1ece6..3d4368f5 100644 --- a/crates/typst-library/src/visualize/shape.rs +++ b/crates/typst-library/src/visualize/shape.rs @@ -492,7 +492,7 @@ fn layout( if kind.is_quadratic() { size = Size::splat(size.min_by_side()); } - frame = Frame::new(size); + frame = Frame::soft(size); } // Prepare stroke. -- cgit v1.2.3