mirror of
https://github.com/storytold/wordcraft.git
synced 2026-11-13 11:54:48 +00:00
* Shapes: a solid fill keeps its transparency A shape's fill colour can carry a:alpha, its opacity. WordCraft dropped it, so a translucent white wash laid over a picture was drawn opaque and hid the picture. The transparency is now read into the shape, drawn on screen and in the PDF, and written back. * Fix #1600 freeform and soft-edge fill opacity * #1600: wrap canonical caret sampler signature * #1600: format canonical integration * #1600: assert canonical DOCX alpha round-trip * #1600: document canonical shape opacity API * Adapt alpha fixture to rectangle render bounds * docs: one file-format-parity row for soft-edge fill opacity, status line --------- Co-authored-by: Brandon Thomas <echelon@gmail.com>
25 lines
997 B
Rust
25 lines
997 B
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn a_translucent_shape_fill_is_drawn_translucent() {
|
|
let mut d = Document::from_text("Wash");
|
|
let wash = InlineObject::Shape {
|
|
kind: wordcraft_doc::para::ShapeKind::Rectangle,
|
|
w: 100.0,
|
|
h: 50.0,
|
|
fill: Some(wordcraft_doc::fill::Fill::Solid { color: wordcraft_doc::props::Rgb::WHITE, transparency: 69.0 }),
|
|
stroke: None,
|
|
stroke_width: 0.0,
|
|
float: Default::default(),
|
|
story: None,
|
|
freeform: None,
|
|
effects: Default::default(),
|
|
extra: Default::default(),
|
|
};
|
|
d.insert_object(&Pos::body(0, 0), wash, &Default::default()).unwrap();
|
|
let draws = flat(display::page_display(&d, &lay(&d).pages[0], &Default::default()));
|
|
let alpha =
|
|
draws.iter().find_map(|x| if let display::Draw::Shape { fill: Some(display::Paint::Solid(_, alpha)), .. } = x { Some(*alpha) } else { None });
|
|
assert!(alpha.is_some_and(|a| (a - 0.31).abs() < 0.001), "fill opacity {alpha:?}");
|
|
}
|