forked from 1b-agent/opencadstudio-upstream
fix(color): only colour 7 swaps with the background; true colours draw as authored
Every near-white colour turned black on a light background (and near-black white on a dark one), including true colours. A 255,255,255 solid used as a white mask became a black block. Now only colour 7 swaps: true colours and ACI 255 resolve a hair off pure white/black and keep their value on screen and in plots. Discussion #1500 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac2a1e1166
commit
60f35e2b1d
7 files changed
+83
-30
No files matched your search
+15
-3
@@ -719,7 +719,11 @@ fn append_pdf_page(
|
||||
// Near-white and near-yellow (viewport active border) → dark grey for print
|
||||
// (only when no CTB override was applied).
|
||||
if !color_overridden {
|
||||
let is_light = r > 0.80 && g > 0.80 && b > 0.80;
|
||||
// An authored white (not colour 7) plots as drawn, like on screen.
|
||||
let is_light = r > 0.80
|
||||
&& g > 0.80
|
||||
&& b > 0.80
|
||||
&& !crate::scene::convert::tess_util::is_authored_white([r, g, b]);
|
||||
let is_yellow = r > 0.80 && g > 0.70 && b < 0.30;
|
||||
let is_cyan = r < 0.30 && g > 0.70 && b > 0.70;
|
||||
if is_light || is_yellow {
|
||||
@@ -1301,7 +1305,11 @@ fn emit_hatch(
|
||||
&& hatch.aci != 0
|
||||
&& !(hatch.aci == 7 && matches!(hatch.pattern, HatchPattern::Solid))
|
||||
{
|
||||
let is_light = r > 0.80 && g > 0.80 && b > 0.80;
|
||||
// An authored white (not colour 7) plots as drawn, like on screen.
|
||||
let is_light = r > 0.80
|
||||
&& g > 0.80
|
||||
&& b > 0.80
|
||||
&& !crate::scene::convert::tess_util::is_authored_white([r, g, b]);
|
||||
let is_yellow = r > 0.80 && g > 0.70 && b < 0.30;
|
||||
let is_cyan = r < 0.30 && g > 0.70 && b > 0.70;
|
||||
if is_light || is_yellow {
|
||||
@@ -1482,7 +1490,11 @@ fn glyph_world_xy(v: &crate::scene::pipeline::text_gpu::TextVertex) -> [f64; 2]
|
||||
/// near-white / near-yellow (colour-7-on-white) → black, near-cyan → dark blue.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn adapt_text_color([r, g, b]: [f32; 3]) -> [f32; 3] {
|
||||
let is_light = r > 0.80 && g > 0.80 && b > 0.80;
|
||||
// An authored white (not colour 7) plots as drawn, like on screen.
|
||||
let is_light = r > 0.80
|
||||
&& g > 0.80
|
||||
&& b > 0.80
|
||||
&& !crate::scene::convert::tess_util::is_authored_white([r, g, b]);
|
||||
let is_yellow = r > 0.80 && g > 0.70 && b < 0.30;
|
||||
let is_cyan = r < 0.30 && g > 0.70 && b > 0.70;
|
||||
if is_light || is_yellow {
|
||||
|
||||
Reference in new issue
Block a user