[Bf-blender-cvs] [3c2d405cc57] greasepencil-object: GPencil: Scale strokes to Potrace lib units
Antonio Vazquez
noreply at git.blender.org
Thu Aug 20 16:37:34 CEST 2020
Commit: 3c2d405cc5751f18fc8024929f8c2ce537f06ac5
Author: Antonio Vazquez
Date: Thu Aug 20 16:37:07 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB3c2d405cc5751f18fc8024929f8c2ce537f06ac5
GPencil: Scale strokes to Potrace lib units
After doing a lot of testing, it looks the library is using a factor base on the VGA resolution and aspect ratio.
The formula was obtained experimenting and gets a very good result, but it could be a totally different approach if we find what logic is used by Potrace.
===================================================================
M source/blender/editors/gpencil/gpencil_trace_ops.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil/gpencil_trace_ops.c
index 4cac41bc4e1..8f6123d33b8 100644
--- a/source/blender/editors/gpencil/gpencil_trace_ops.c
+++ b/source/blender/editors/gpencil/gpencil_trace_ops.c
@@ -125,8 +125,10 @@ static bool gpencil_trace_image(
offset[1] = ibuf->y / 2;
/* Scale correction for Potrace. */
- const float scale_potrace = scale * (640.0f / (float)ibuf->x) *
- ((float)ibuf->x / (float)ibuf->y);
+ float scale_potrace = scale * (640.0f / (float)ibuf->x) * ((float)ibuf->x / (float)ibuf->y);
+ if (ibuf->x > ibuf->y) {
+ scale_potrace *= (float)ibuf->y / (float)ibuf->x;
+ }
ED_gpencil_trace_data_to_strokes(
bmain, st, ob, gpf, offset, scale_potrace, sample, resolution, thickness);
More information about the Bf-blender-cvs
mailing list