feat(selection): highlight opacity and extra width (#1823)

Options > Selection gains "Selection highlight opacity" and "Selection
highlight extra width". Below full opacity the object's own colour
shows through the highlight. The selection overlay draws with its own
copy of the frame uniforms: transparency on, and every line widened by
the extra width. Drawings opened at startup now get the selection
colour settings too; they used to keep the defaults until a setting
changed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-16 01:07:23 +03:00
1 parent 977135fbbd
commit 38d81bf838
38 files changed
+247 -89

No files matched your search

+7 -1
View File
@@ -8,7 +8,7 @@ struct Uniforms {
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -63,7 +63,13 @@ struct VertexOut {
@location(9) @interpolate(flat) cap_ends: vec3<f32>,
}
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_hw(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
return resolve_hw_base(taper_ratio, world_hw, px_hw) + u.highlight_widen * 0.5;
}
fn resolve_hw_base(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
if taper_ratio > 0.0 {
return max((taper_ratio * world_hw) / u.world_per_pixel, 0.5);
}
+7 -1
View File
@@ -27,7 +27,7 @@ struct Uniforms {
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -87,7 +87,13 @@ struct VertexOut {
@location(9) @interpolate(flat) cap_ends: vec3<f32>,
}
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_hw(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
return resolve_hw_base(taper_ratio, world_hw, px_hw) + u.highlight_widen * 0.5;
}
fn resolve_hw_base(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
if taper_ratio > 0.0 {
return max((taper_ratio * world_hw) / u.world_per_pixel, 0.5);
}
+7 -1
View File
@@ -20,7 +20,7 @@ struct Uniforms {
// Relative-to-eye (double-single)
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -56,7 +56,13 @@ struct VertexOut {
@location(10) @interpolate(flat) is_world: f32,
}
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_px_hw(px_hw: f32) -> f32 {
return resolve_px_hw_base(px_hw) + u.highlight_widen * 0.5;
}
fn resolve_px_hw_base(px_hw: f32) -> f32 {
var display_hw = max(px_hw * u.lineweight_scale, 0.5);
if u.lineweight_scale < 0.0 {
let scale = -u.lineweight_scale;
+7 -1
View File
@@ -15,7 +15,7 @@ struct Uniforms {
// Relative-to-eye (double-single)
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -50,7 +50,13 @@ struct VertexOut {
@location(9) @interpolate(flat) end_param: f32,
}
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_hw(px_hw: f32) -> f32 {
return resolve_hw_base(px_hw) + u.highlight_widen * 0.5;
}
fn resolve_hw_base(px_hw: f32) -> f32 {
var display_hw = max(px_hw * u.lineweight_scale, 0.5);
if u.lineweight_scale < 0.0 {
let scale = -u.lineweight_scale;
+7 -1
View File
@@ -37,7 +37,7 @@ struct Uniforms {
// jitter on pan / zoom / rotate.
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -98,7 +98,13 @@ struct VertexOut {
// Half-width of one segment end: a tapered band's own end width wins, then a
// constant world-unit band, then the screen-pixel lineweight (LWDISPLAY off
// collapses to a hairline).
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_hw(taper: f32, world_hw: f32, px_hw: f32) -> f32 {
return resolve_hw_base(taper, world_hw, px_hw) + u.highlight_widen * 0.5;
}
fn resolve_hw_base(taper: f32, world_hw: f32, px_hw: f32) -> f32 {
if taper >= 0.0 { return max(taper / u.world_per_pixel, 0.5); }
if world_hw > 0.0 { return max(world_hw / u.world_per_pixel, 0.5); }
if world_hw < 0.0 { return max(-world_hw, 0.5); }
+7 -1
View File
@@ -15,7 +15,7 @@ struct Uniforms {
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
highlight_widen: f32,
eye_low: vec3<f32>,
_pad_el: f32,
}
@@ -79,7 +79,13 @@ struct VertexOut {
// Half-width of one segment end: a tapered band's own end width wins, then a
// constant world-unit band, then the screen-pixel lineweight (LWDISPLAY off
// collapses to a hairline).
// The selection pass widens highlighted lines by `highlight_widen` pixels;
// every other pass uploads zero.
fn resolve_hw(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
return resolve_hw_base(taper_ratio, world_hw, px_hw) + u.highlight_widen * 0.5;
}
fn resolve_hw_base(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
if taper_ratio > 0.0 {
return max((taper_ratio * world_hw) / u.world_per_pixel, 0.5);
}