Fill the page background with pagecolor
This commit is contained in:
1 parent
4cb456743a
commit
1ab2a29bfa
6 files changed
+56
-5
No files matched your search
@@ -76,6 +76,8 @@ pub enum DisplayItem {
|
||||
height: i64,
|
||||
url: String,
|
||||
},
|
||||
/// Fill the whole page with a background colour (RGB).
|
||||
Background([u8; 3]),
|
||||
/// Switch the fill colour for following text (RGB).
|
||||
Fill([u8; 3]),
|
||||
Special(String),
|
||||
@@ -164,7 +166,7 @@ impl DisplayList {
|
||||
*x += dx;
|
||||
*y += dy;
|
||||
}
|
||||
DisplayItem::Fill(_) => {}
|
||||
DisplayItem::Fill(_) | DisplayItem::Background(_) => {}
|
||||
DisplayItem::Special(_) => {}
|
||||
}
|
||||
}
|
||||
@@ -180,6 +182,14 @@ impl DisplayList {
|
||||
let mut fill = [0u8, 0, 0];
|
||||
for item in &self.items {
|
||||
match item {
|
||||
DisplayItem::Background(color) => {
|
||||
let width = self.width as f64 / 65_536.0;
|
||||
let height = self.height as f64 / 65_536.0;
|
||||
out.push_str(&format!(
|
||||
"<rect x=\"0\" y=\"0\" width=\"{width:.3}\" height=\"{height:.3}\" fill=\"#{:02x}{:02x}{:02x}\"/>\n",
|
||||
color[0], color[1], color[2]
|
||||
));
|
||||
}
|
||||
DisplayItem::Fill(color) => fill = *color,
|
||||
DisplayItem::Text {
|
||||
x,
|
||||
|
||||
Reference in new issue
Block a user