[Bf-blender-cvs] [d9fddf32791] greasepencil-object: GPencil: Avoid SVG attributes when not needed

Antonio Vazquez noreply at git.blender.org
Fri Jul 31 19:47:18 CEST 2020


Commit: d9fddf32791c2a4e24b3f0f6477e225118831974
Author: Antonio Vazquez
Date:   Fri Jul 31 19:39:30 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBd9fddf32791c2a4e24b3f0f6477e225118831974

GPencil: Avoid SVG attributes when not needed

===================================================================

M	source/blender/io/gpencil/intern/gpencil_io_svg.cc

===================================================================

diff --git a/source/blender/io/gpencil/intern/gpencil_io_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
index a36cdf265fa..1fbedc64901 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -274,10 +274,12 @@ void GpencilExporterSVG::export_stroke_path(pugi::xml_node gpl_node, const bool
     linearrgb_to_srgb_v3_v3(col, col);
     stroke_hex = rgb_to_hex(col);
   }
-  gps_node.append_attribute("stroke").set_value(stroke_hex.c_str());
   gps_node.append_attribute("fill").set_value(stroke_hex.c_str());
 
-  gps_node.append_attribute("stroke-width").set_value("1.0");
+  if (gp_style_is_stroke()) {
+    gps_node.append_attribute("stroke").set_value(stroke_hex.c_str());
+    gps_node.append_attribute("stroke-width").set_value("1.0");
+  }
 
   std::string txt = "M";
   for (int i = 0; i < gps->totpoints; i++) {
@@ -334,8 +336,9 @@ void GpencilExporterSVG::export_stroke_polyline(pugi::xml_node gpl_node, const b
 
   color_string_set(gps_node, is_fill);
 
-  float thickness = is_fill ? 1.0f : radius;
-  gps_node.append_attribute("stroke-width").set_value(thickness);
+  if (gp_style_is_stroke() && !is_fill) {
+    gps_node.append_attribute("stroke-width").set_value(radius);
+  }
 
   std::string txt;
   for (int i = 0; i < gps->totpoints; i++) {
@@ -366,12 +369,15 @@ void GpencilExporterSVG::color_string_set(pugi::xml_node gps_node, const bool is
     std::string stroke_hex = rgb_to_hex(col);
     gps_node.append_attribute("fill").set_value(stroke_hex.c_str());
     gps_node.append_attribute("stroke").set_value("none");
+    gps_node.append_attribute("fill-opacity").set_value(fill_color[3] * gpl->opacity);
   }
   else {
     interp_v3_v3v3(col, stroke_color, gpl->tintcolor, gpl->tintcolor[3]);
     linearrgb_to_srgb_v3_v3(col, col);
     std::string stroke_hex = rgb_to_hex(col);
     gps_node.append_attribute("stroke").set_value(stroke_hex.c_str());
+    gps_node.append_attribute("stroke-opacity")
+        .set_value(stroke_color[3] * stroke_average_opacity() * gpl->opacity);
 
     if (gps->totpoints > 1) {
       gps_node.append_attribute("fill").set_value("none");
@@ -379,11 +385,9 @@ void GpencilExporterSVG::color_string_set(pugi::xml_node gps_node, const bool is
     }
     else {
       gps_node.append_attribute("fill").set_value(stroke_hex.c_str());
+      gps_node.append_attribute("fill-opacity").set_value(fill_color[3] * gpl->opacity);
     }
   }
-  gps_node.append_attribute("stroke-opacity")
-      .set_value(stroke_color[3] * stroke_average_opacity() * gpl->opacity);
-  gps_node.append_attribute("fill-opacity").set_value(fill_color[3] * gpl->opacity);
 }
 
 }  // namespace gpencil



More information about the Bf-blender-cvs mailing list