Introduce with_transformation to Renderer trait
This commit is contained in:
parent
a6e91d13d5
commit
f4d6648601
31 changed files with 161 additions and 118 deletions
|
|
@ -1,9 +1,11 @@
|
|||
use tiny_skia::Size;
|
||||
|
||||
use crate::core::{Background, Color, Gradient, Rectangle, Vector};
|
||||
use crate::core::{
|
||||
Background, Color, Gradient, Rectangle, Transformation, Vector,
|
||||
};
|
||||
use crate::graphics::backend;
|
||||
use crate::graphics::text;
|
||||
use crate::graphics::{Transformation, Viewport};
|
||||
use crate::graphics::Viewport;
|
||||
use crate::primitive::{self, Primitive};
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
|
@ -459,11 +461,12 @@ impl Backend {
|
|||
|
||||
self.text_pipeline.draw_paragraph(
|
||||
paragraph,
|
||||
*position * transformation,
|
||||
*position,
|
||||
*color,
|
||||
scale_factor * transformation.scale_factor(),
|
||||
scale_factor,
|
||||
pixels,
|
||||
clip_mask,
|
||||
transformation,
|
||||
);
|
||||
}
|
||||
Primitive::Editor {
|
||||
|
|
@ -484,11 +487,12 @@ impl Backend {
|
|||
|
||||
self.text_pipeline.draw_editor(
|
||||
editor,
|
||||
*position * transformation,
|
||||
*position,
|
||||
*color,
|
||||
scale_factor,
|
||||
pixels,
|
||||
clip_mask,
|
||||
transformation,
|
||||
);
|
||||
}
|
||||
Primitive::Text {
|
||||
|
|
@ -515,7 +519,7 @@ impl Backend {
|
|||
|
||||
self.text_pipeline.draw_cached(
|
||||
content,
|
||||
*bounds * transformation,
|
||||
*bounds,
|
||||
*color,
|
||||
*size,
|
||||
*line_height,
|
||||
|
|
@ -523,9 +527,10 @@ impl Backend {
|
|||
*horizontal_alignment,
|
||||
*vertical_alignment,
|
||||
*shaping,
|
||||
scale_factor * transformation.scale_factor(),
|
||||
scale_factor,
|
||||
pixels,
|
||||
clip_mask,
|
||||
transformation,
|
||||
);
|
||||
}
|
||||
Primitive::RawText(text::Raw {
|
||||
|
|
@ -550,11 +555,12 @@ impl Backend {
|
|||
|
||||
self.text_pipeline.draw_raw(
|
||||
&buffer,
|
||||
*position * transformation,
|
||||
*position,
|
||||
*color,
|
||||
scale_factor,
|
||||
pixels,
|
||||
clip_mask,
|
||||
transformation,
|
||||
);
|
||||
}
|
||||
#[cfg(feature = "image")]
|
||||
|
|
@ -769,13 +775,15 @@ fn into_color(color: Color) -> tiny_skia::Color {
|
|||
}
|
||||
|
||||
fn into_transform(transformation: Transformation) -> tiny_skia::Transform {
|
||||
let translation = transformation.translation();
|
||||
|
||||
tiny_skia::Transform {
|
||||
sx: transformation.scale_factor(),
|
||||
kx: 0.0,
|
||||
ky: 0.0,
|
||||
sy: transformation.scale_factor(),
|
||||
tx: transformation.translation_x(),
|
||||
ty: transformation.translation_y(),
|
||||
tx: translation.x,
|
||||
ty: translation.y,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue