2021-01-10 14:42:46 +00:00
|
|
|
use crate::{
|
|
|
|
text::{Fonts, Galley, TextStyle},
|
2021-01-25 20:23:24 +00:00
|
|
|
Color32, Mesh, Stroke,
|
2020-05-19 20:28:57 +00:00
|
|
|
};
|
2021-01-10 14:42:46 +00:00
|
|
|
use emath::*;
|
2020-05-19 20:28:57 +00:00
|
|
|
|
2020-12-27 11:57:15 +00:00
|
|
|
/// A paint primitive such as a circle or a piece of text.
|
2020-12-29 00:13:14 +00:00
|
|
|
/// Coordinates are all screen space points (not physical pixels).
|
2021-01-16 17:49:10 +00:00
|
|
|
#[must_use = "Add a Shape to a Painter"]
|
2021-03-13 11:58:17 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq)]
|
2021-01-10 10:43:01 +00:00
|
|
|
pub enum Shape {
|
2020-07-30 12:11:09 +00:00
|
|
|
/// Paint nothing. This can be useful as a placeholder.
|
|
|
|
Noop,
|
2021-01-10 10:43:01 +00:00
|
|
|
/// Recursively nest more shapes - sometimes a convenience to be able to do.
|
2020-12-29 00:13:14 +00:00
|
|
|
/// For performance reasons it is better to avoid it.
|
2021-01-10 10:43:01 +00:00
|
|
|
Vec(Vec<Shape>),
|
2020-05-19 20:28:57 +00:00
|
|
|
Circle {
|
|
|
|
center: Pos2,
|
2020-08-05 17:45:39 +00:00
|
|
|
radius: f32,
|
2021-01-02 16:02:18 +00:00
|
|
|
fill: Color32,
|
2020-09-01 21:54:21 +00:00
|
|
|
stroke: Stroke,
|
2020-05-19 20:28:57 +00:00
|
|
|
},
|
|
|
|
LineSegment {
|
|
|
|
points: [Pos2; 2],
|
2020-09-01 21:54:21 +00:00
|
|
|
stroke: Stroke,
|
2020-05-19 20:28:57 +00:00
|
|
|
},
|
|
|
|
Path {
|
2020-09-01 18:03:50 +00:00
|
|
|
points: Vec<Pos2>,
|
|
|
|
/// If true, connect the first and last of the points together.
|
|
|
|
/// This is required if `fill != TRANSPARENT`.
|
2020-05-19 20:28:57 +00:00
|
|
|
closed: bool,
|
2021-05-20 20:14:08 +00:00
|
|
|
/// Fill is only supported for convex polygons.
|
2021-01-02 16:02:18 +00:00
|
|
|
fill: Color32,
|
2020-09-01 21:54:21 +00:00
|
|
|
stroke: Stroke,
|
2020-05-19 20:28:57 +00:00
|
|
|
},
|
|
|
|
Rect {
|
|
|
|
rect: Rect,
|
2020-12-27 13:16:37 +00:00
|
|
|
/// How rounded the corners are. Use `0.0` for no rounding.
|
2020-05-19 20:28:57 +00:00
|
|
|
corner_radius: f32,
|
2021-01-02 16:02:18 +00:00
|
|
|
fill: Color32,
|
2020-09-01 21:54:21 +00:00
|
|
|
stroke: Stroke,
|
2020-05-19 20:28:57 +00:00
|
|
|
},
|
|
|
|
Text {
|
2021-03-29 19:24:09 +00:00
|
|
|
/// Top left corner of the first character..
|
2020-05-19 20:28:57 +00:00
|
|
|
pos: Pos2,
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
|
2021-03-29 19:24:09 +00:00
|
|
|
/// The layed out text.
|
2021-03-29 20:30:18 +00:00
|
|
|
galley: std::sync::Arc<Galley>,
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
|
|
|
|
/// Add this underline to the whole text.
|
|
|
|
/// You can also set an underline when creating the galley.
|
|
|
|
underline: Stroke,
|
|
|
|
|
|
|
|
/// If set, the text color in the galley will be ignored and replaced
|
|
|
|
/// with the given color.
|
|
|
|
/// This will NOT replace background color nor strikethrough/underline color.
|
|
|
|
override_text_color: Option<Color32>,
|
2020-05-19 20:28:57 +00:00
|
|
|
},
|
2021-01-25 20:23:24 +00:00
|
|
|
Mesh(Mesh),
|
2020-05-19 20:28:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-02 16:35:16 +00:00
|
|
|
/// ## Constructors
|
2021-01-10 10:43:01 +00:00
|
|
|
impl Shape {
|
2021-05-20 20:09:35 +00:00
|
|
|
/// A line between two points.
|
|
|
|
/// More efficient than calling [`Self::line`].
|
2020-09-13 07:28:54 +00:00
|
|
|
pub fn line_segment(points: [Pos2; 2], stroke: impl Into<Stroke>) -> Self {
|
|
|
|
Self::LineSegment {
|
|
|
|
points,
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 20:09:35 +00:00
|
|
|
/// A line through many points.
|
|
|
|
///
|
2021-07-06 18:15:04 +00:00
|
|
|
/// Use [`Self::line_segment`] instead if your line only connects two points.
|
2020-11-02 16:35:16 +00:00
|
|
|
pub fn line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Self {
|
|
|
|
Self::Path {
|
|
|
|
points,
|
|
|
|
closed: false,
|
|
|
|
fill: Default::default(),
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-20 20:09:35 +00:00
|
|
|
/// A line that closes back to the start point again.
|
2020-11-02 16:35:16 +00:00
|
|
|
pub fn closed_line(points: Vec<Pos2>, stroke: impl Into<Stroke>) -> Self {
|
|
|
|
Self::Path {
|
|
|
|
points,
|
|
|
|
closed: true,
|
|
|
|
fill: Default::default(),
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 18:15:04 +00:00
|
|
|
/// Turn a line into equally spaced dots.
|
|
|
|
pub fn dotted_line(
|
|
|
|
points: &[Pos2],
|
|
|
|
color: impl Into<Color32>,
|
|
|
|
spacing: f32,
|
|
|
|
radius: f32,
|
|
|
|
) -> Vec<Self> {
|
|
|
|
let mut shapes = Vec::new();
|
|
|
|
points_from_line(points, spacing, radius, color.into(), &mut shapes);
|
|
|
|
shapes
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Turn a line into dashes.
|
|
|
|
pub fn dashed_line(
|
|
|
|
points: &[Pos2],
|
|
|
|
stroke: impl Into<Stroke>,
|
|
|
|
dash_length: f32,
|
|
|
|
gap_length: f32,
|
|
|
|
) -> Vec<Self> {
|
|
|
|
let mut shapes = Vec::new();
|
|
|
|
dashes_from_line(points, stroke.into(), dash_length, gap_length, &mut shapes);
|
|
|
|
shapes
|
|
|
|
}
|
|
|
|
|
2021-05-20 20:14:08 +00:00
|
|
|
/// A convex polygon with a fill and optional stroke.
|
|
|
|
pub fn convex_polygon(
|
|
|
|
points: Vec<Pos2>,
|
|
|
|
fill: impl Into<Color32>,
|
|
|
|
stroke: impl Into<Stroke>,
|
|
|
|
) -> Self {
|
2020-11-02 16:35:16 +00:00
|
|
|
Self::Path {
|
|
|
|
points,
|
|
|
|
closed: true,
|
|
|
|
fill: fill.into(),
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-02 16:02:18 +00:00
|
|
|
pub fn circle_filled(center: Pos2, radius: f32, fill_color: impl Into<Color32>) -> Self {
|
2020-09-13 07:28:54 +00:00
|
|
|
Self::Circle {
|
|
|
|
center,
|
|
|
|
radius,
|
|
|
|
fill: fill_color.into(),
|
|
|
|
stroke: Default::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn circle_stroke(center: Pos2, radius: f32, stroke: impl Into<Stroke>) -> Self {
|
|
|
|
Self::Circle {
|
|
|
|
center,
|
|
|
|
radius,
|
|
|
|
fill: Default::default(),
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-02 16:02:18 +00:00
|
|
|
pub fn rect_filled(rect: Rect, corner_radius: f32, fill_color: impl Into<Color32>) -> Self {
|
2020-09-13 07:28:54 +00:00
|
|
|
Self::Rect {
|
|
|
|
rect,
|
|
|
|
corner_radius,
|
|
|
|
fill: fill_color.into(),
|
|
|
|
stroke: Default::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn rect_stroke(rect: Rect, corner_radius: f32, stroke: impl Into<Stroke>) -> Self {
|
|
|
|
Self::Rect {
|
|
|
|
rect,
|
|
|
|
corner_radius,
|
|
|
|
fill: Default::default(),
|
|
|
|
stroke: stroke.into(),
|
|
|
|
}
|
|
|
|
}
|
2020-10-01 20:25:44 +00:00
|
|
|
|
2021-04-29 17:49:49 +00:00
|
|
|
#[allow(clippy::needless_pass_by_value)]
|
2020-10-01 20:25:44 +00:00
|
|
|
pub fn text(
|
|
|
|
fonts: &Fonts,
|
|
|
|
pos: Pos2,
|
2021-01-10 09:51:16 +00:00
|
|
|
anchor: Align2,
|
2021-04-29 17:49:49 +00:00
|
|
|
text: impl ToString,
|
2020-10-01 20:25:44 +00:00
|
|
|
text_style: TextStyle,
|
2021-01-02 16:02:18 +00:00
|
|
|
color: Color32,
|
2020-10-01 20:25:44 +00:00
|
|
|
) -> Self {
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
let galley = fonts.layout_no_wrap(text.to_string(), text_style, color);
|
2021-01-10 09:51:16 +00:00
|
|
|
let rect = anchor.anchor_rect(Rect::from_min_size(pos, galley.size));
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
Self::galley(rect.min, galley)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn galley(pos: Pos2, galley: std::sync::Arc<Galley>) -> Self {
|
2020-10-01 20:25:44 +00:00
|
|
|
Self::Text {
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
pos,
|
2020-10-01 20:25:44 +00:00
|
|
|
galley,
|
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.
This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.
One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.
## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).
Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.
All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 16:18:00 +00:00
|
|
|
override_text_color: None,
|
|
|
|
underline: Stroke::none(),
|
2020-10-01 20:25:44 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-02 16:35:16 +00:00
|
|
|
}
|
2020-10-21 09:04:22 +00:00
|
|
|
|
2021-07-06 18:15:04 +00:00
|
|
|
/// Creates equally spaced filled circles from a line.
|
|
|
|
fn points_from_line(
|
|
|
|
line: &[Pos2],
|
|
|
|
spacing: f32,
|
|
|
|
radius: f32,
|
|
|
|
color: Color32,
|
|
|
|
shapes: &mut Vec<Shape>,
|
|
|
|
) {
|
|
|
|
let mut position_on_segment = 0.0;
|
|
|
|
line.windows(2).for_each(|window| {
|
|
|
|
let start = window[0];
|
|
|
|
let end = window[1];
|
|
|
|
let vector = end - start;
|
|
|
|
let segment_length = vector.length();
|
|
|
|
while position_on_segment < segment_length {
|
|
|
|
let new_point = start + vector * (position_on_segment / segment_length);
|
|
|
|
shapes.push(Shape::circle_filled(new_point, radius, color));
|
|
|
|
position_on_segment += spacing;
|
|
|
|
}
|
|
|
|
position_on_segment -= segment_length;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates dashes from a line.
|
|
|
|
fn dashes_from_line(
|
|
|
|
line: &[Pos2],
|
|
|
|
stroke: Stroke,
|
|
|
|
dash_length: f32,
|
|
|
|
gap_length: f32,
|
|
|
|
shapes: &mut Vec<Shape>,
|
|
|
|
) {
|
|
|
|
let mut position_on_segment = 0.0;
|
|
|
|
let mut drawing_dash = false;
|
|
|
|
line.windows(2).for_each(|window| {
|
|
|
|
let start = window[0];
|
|
|
|
let end = window[1];
|
|
|
|
let vector = end - start;
|
|
|
|
let segment_length = vector.length();
|
|
|
|
while position_on_segment < segment_length {
|
|
|
|
let new_point = start + vector * (position_on_segment / segment_length);
|
|
|
|
if drawing_dash {
|
|
|
|
// This is the end point.
|
|
|
|
if let Shape::Path { points, .. } = shapes.last_mut().unwrap() {
|
|
|
|
points.push(new_point);
|
|
|
|
}
|
|
|
|
position_on_segment += gap_length;
|
|
|
|
} else {
|
|
|
|
// Start a new dash.
|
|
|
|
shapes.push(Shape::line(vec![new_point], stroke));
|
|
|
|
position_on_segment += dash_length;
|
|
|
|
}
|
|
|
|
drawing_dash = !drawing_dash;
|
|
|
|
}
|
|
|
|
// If the segment ends and the dash is not finished, add the segment's end point.
|
|
|
|
if drawing_dash {
|
|
|
|
if let Shape::Path { points, .. } = shapes.last_mut().unwrap() {
|
|
|
|
points.push(end);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
position_on_segment -= segment_length;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-02 16:35:16 +00:00
|
|
|
/// ## Operations
|
2021-01-10 10:43:01 +00:00
|
|
|
impl Shape {
|
2021-01-25 20:23:24 +00:00
|
|
|
pub fn mesh(mesh: Mesh) -> Self {
|
2021-05-17 20:34:29 +00:00
|
|
|
crate::epaint_assert!(mesh.is_valid());
|
2021-01-25 20:23:24 +00:00
|
|
|
Self::Mesh(mesh)
|
|
|
|
}
|
|
|
|
|
2021-04-01 20:10:34 +00:00
|
|
|
#[inline(always)]
|
2020-10-21 09:09:42 +00:00
|
|
|
pub fn texture_id(&self) -> super::TextureId {
|
2021-01-25 20:23:24 +00:00
|
|
|
if let Shape::Mesh(mesh) = self {
|
|
|
|
mesh.texture_id
|
2020-10-21 09:09:42 +00:00
|
|
|
} else {
|
|
|
|
super::TextureId::Egui
|
|
|
|
}
|
|
|
|
}
|
2020-11-02 16:41:52 +00:00
|
|
|
|
|
|
|
/// Translate location by this much, in-place
|
|
|
|
pub fn translate(&mut self, delta: Vec2) {
|
|
|
|
match self {
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::Noop => {}
|
|
|
|
Shape::Vec(shapes) => {
|
|
|
|
for shape in shapes {
|
|
|
|
shape.translate(delta);
|
2020-12-29 00:13:14 +00:00
|
|
|
}
|
|
|
|
}
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::Circle { center, .. } => {
|
2020-11-02 16:41:52 +00:00
|
|
|
*center += delta;
|
|
|
|
}
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::LineSegment { points, .. } => {
|
2020-11-02 16:41:52 +00:00
|
|
|
for p in points {
|
|
|
|
*p += delta;
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::Path { points, .. } => {
|
2020-11-02 16:41:52 +00:00
|
|
|
for p in points {
|
|
|
|
*p += delta;
|
|
|
|
}
|
|
|
|
}
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::Rect { rect, .. } => {
|
2020-11-02 16:41:52 +00:00
|
|
|
*rect = rect.translate(delta);
|
|
|
|
}
|
2021-01-10 10:43:01 +00:00
|
|
|
Shape::Text { pos, .. } => {
|
2020-11-02 16:41:52 +00:00
|
|
|
*pos += delta;
|
|
|
|
}
|
2021-01-25 20:23:24 +00:00
|
|
|
Shape::Mesh(mesh) => {
|
|
|
|
mesh.translate(delta);
|
2020-11-02 16:41:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-13 07:28:54 +00:00
|
|
|
}
|