feat: render interactive manuscript from Endor through generic graphics
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
use crate::geometry::{Point, Rect};
|
||||
use crate::text::TextStyle;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
/// 设备绘制使用的 RGBA 字节通道,区别于源代码的颜色文本。
|
||||
pub struct Color {
|
||||
pub red: u8,
|
||||
@@ -38,6 +38,15 @@ impl Color {
|
||||
#[derive(Clone, Debug)]
|
||||
/// 原生画布最终顺序执行的绘制原语,已经使用对应设备比例。
|
||||
pub enum DrawCommand {
|
||||
/// Immutable RGBA image mapped from its local rectangle by rotation.
|
||||
Image {
|
||||
image: std::sync::Arc<crate::render::image::Image>,
|
||||
origin: Point,
|
||||
rect: Rect,
|
||||
angle: f32,
|
||||
opacity: f32,
|
||||
tint: Option<Color>,
|
||||
},
|
||||
Scene3D {
|
||||
rect: Rect,
|
||||
view: std::sync::Arc<crate::scene3d::View>,
|
||||
@@ -82,7 +91,7 @@ impl DrawCommand {
|
||||
rect.x += delta.x;
|
||||
rect.y += delta.y;
|
||||
}
|
||||
Self::Text { origin, .. } => {
|
||||
Self::Text { origin, .. } | Self::Image { origin, .. } => {
|
||||
origin.x += delta.x;
|
||||
origin.y += delta.y;
|
||||
}
|
||||
@@ -123,6 +132,15 @@ impl DisplayList {
|
||||
*width *= scale;
|
||||
Some(rect)
|
||||
}
|
||||
DrawCommand::Image { origin, rect, .. } => {
|
||||
origin.x *= scale;
|
||||
origin.y *= scale;
|
||||
rect.x *= scale;
|
||||
rect.y *= scale;
|
||||
rect.width *= scale;
|
||||
rect.height *= scale;
|
||||
None
|
||||
}
|
||||
DrawCommand::Text { origin, style, .. } => {
|
||||
origin.x *= scale;
|
||||
origin.y *= scale;
|
||||
@@ -156,7 +174,7 @@ impl DisplayList {
|
||||
rect.x += delta.x;
|
||||
rect.y += delta.y;
|
||||
}
|
||||
DrawCommand::Text { origin, .. } => {
|
||||
DrawCommand::Text { origin, .. } | DrawCommand::Image { origin, .. } => {
|
||||
origin.x += delta.x;
|
||||
origin.y += delta.y;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user