mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Make the Outline render mode draw with consistent stroke thickness at any viewport zoom (#3848)
* Remove dead code for now-retired SVG implementation * Implement viewport zoom compensation for thickness
This commit is contained in:
@@ -148,10 +148,6 @@ impl RenderExt for Stroke {
|
||||
if let Some(stroke_join_miter_limit) = stroke_join_miter_limit {
|
||||
let _ = write!(&mut attributes, r#" stroke-miterlimit="{stroke_join_miter_limit}""#);
|
||||
}
|
||||
// Add vector-effect attribute to make strokes non-scaling
|
||||
if self.non_scaling {
|
||||
let _ = write!(&mut attributes, r#" vector-effect="non-scaling-stroke""#);
|
||||
}
|
||||
if paint_order.is_some() {
|
||||
let _ = write!(&mut attributes, r#" style="paint-order: stroke;" "#);
|
||||
}
|
||||
|
||||
@@ -180,6 +180,8 @@ pub struct RenderParams {
|
||||
pub aligned_strokes: bool,
|
||||
pub override_paint_order: bool,
|
||||
pub artboard_background: Option<Color>,
|
||||
/// Viewport zoom level (document-space scale). Used to compute constant viewport-pixel stroke widths in Outline mode.
|
||||
pub viewport_zoom: f64,
|
||||
}
|
||||
|
||||
impl Hash for RenderParams {
|
||||
@@ -197,6 +199,7 @@ impl Hash for RenderParams {
|
||||
self.aligned_strokes.hash(state);
|
||||
self.override_paint_order.hash(state);
|
||||
self.artboard_background.hash(state);
|
||||
self.viewport_zoom.to_bits().hash(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1109,7 +1112,7 @@ impl Render for Table<Vector> {
|
||||
match render_params.render_mode {
|
||||
RenderMode::Outline => {
|
||||
let outline_stroke = kurbo::Stroke {
|
||||
width: LAYER_OUTLINE_STROKE_WEIGHT,
|
||||
width: LAYER_OUTLINE_STROKE_WEIGHT / if render_params.viewport_zoom > 0. { render_params.viewport_zoom } else { 1. },
|
||||
miter_limit: 4.,
|
||||
join: Join::Miter,
|
||||
start_cap: Cap::Butt,
|
||||
|
||||
Reference in New Issue
Block a user