mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-01 06:16:46 -06:00
fix(engine): new text is readable on the frame it is drawn in (#362)
The colour of new text in the app was chosen from the page alone, so on a dark page text drawn in a white frame (a new frame's default) was white and invisible. readable_text_fills now looks at what the text is drawn on: the nearest layer from its parent out whose top visible fill is a mostly opaque solid colour, else the page. The Text tool and text.create / node.create pass the text's parent. The two tests that asserted the page-only rule in a frame now expect black text in a white frame; new cases cover dark, unfilled, nested, faint and stacked fills, and the Text tool.
This commit is contained in:
@@ -242,7 +242,7 @@ pub fn create(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let doc = ds.doc_mut();
|
||||
let nid = doc.alloc_id();
|
||||
let mut node = if base == "Section" { Node::new_section(nid, name, w, h) } else { Node::new(nid, kind, name, w, h) };
|
||||
if app_text && let Some(fills) = crate::tools::readable_text_fills(doc, doc.page_of(parent).unwrap_or(page)) {
|
||||
if app_text && let Some(fills) = crate::tools::readable_text_fills(doc, parent) {
|
||||
node.fills = fills;
|
||||
}
|
||||
node.transform = space.inverse() * figcraft_geom::Affine::translate((x + offset.0, y + offset.1));
|
||||
|
||||
Reference in New Issue
Block a user