[Bf-blender-cvs] [10e9be3cec2] greasepencil-object: GPencil: Basic path exported
Antonio Vazquez
noreply at git.blender.org
Sat Jul 25 16:33:28 CEST 2020
Commit: 10e9be3cec23fb36e700294f7d9fbd37384daf56
Author: Antonio Vazquez
Date: Fri Jul 24 22:41:36 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rB10e9be3cec23fb36e700294f7d9fbd37384daf56
GPencil: Basic path exported
Still pending perimter, materials and center in the document.
===================================================================
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 0bd689c2426..8e226331471 100644
--- a/source/blender/io/gpencil/intern/gpencil_io_svg.cc
+++ b/source/blender/io/gpencil/intern/gpencil_io_svg.cc
@@ -18,6 +18,7 @@
* \ingroup bgpencil
*/
#include <iostream>
+#include <string>
#include "BKE_context.h"
#include "BKE_gpencil.h"
@@ -126,6 +127,8 @@ bool GpencilExporterSVG::write(void)
/* Create document header and main svg node. */
void GpencilExporterSVG::create_document_header(void)
{
+ Scene *scene = CTX_data_scene(params.C);
+
/* Add a custom document declaration node */
pugi::xml_node decl = doc.prepend_child(pugi::node_declaration);
decl.append_attribute("version") = "1.0";
@@ -143,15 +146,18 @@ void GpencilExporterSVG::create_document_header(void)
main_node.append_attribute("version").set_value("1.0");
main_node.append_attribute("x").set_value("0px");
main_node.append_attribute("y").set_value("0px");
- main_node.append_attribute("width").set_value("841px");
- main_node.append_attribute("height").set_value("600px");
- main_node.append_attribute("viewBox").set_value("0 0 841 600");
+ main_node.append_attribute("width").set_value(std::to_string(scene->r.xsch).c_str());
+ main_node.append_attribute("height").set_value(std::to_string(scene->r.ysch).c_str());
+ std::string viewbox = "0 0 " + std::to_string(scene->r.xsch) + " " +
+ std::to_string(scene->r.ysch);
+ main_node.append_attribute("viewBox").set_value(viewbox.c_str());
}
/* Main layer loop. */
void GpencilExporterSVG::layers_loop(void)
{
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(params.C);
+ Scene *scene = CTX_data_scene(params.C);
Object *ob = params.ob;
bGPdata *gpd = (bGPdata *)ob->data;
@@ -173,15 +179,24 @@ void GpencilExporterSVG::layers_loop(void)
BKE_gpencil_parent_matrix_get(depsgraph, ob, gpl, diff_mat);
pugi::xml_node gps_node = gpl_node.append_child("path");
- gps_node.append_attribute("fill").set_value("#000000");
+ // gps_node.append_attribute("fill").set_value("#000000");
gps_node.append_attribute("stroke").set_value("#000000");
- gps_node.append_attribute("stroke-width").set_value("0.5");
-
+ gps_node.append_attribute("stroke-width").set_value("1.0");
+ std::string txt = "M";
for (int i = 0; i < gps->totpoints; i++) {
+ if (i > 0) {
+ txt.append("L");
+ }
bGPDspoint *pt = &gps->points[i];
int screen_co[2];
gpencil_3d_point_to_screen_space(region, diff_mat, &pt->x, screen_co);
+ /* Invert Y axis. */
+ int y = scene->r.ysch - screen_co[1];
+ txt.append(std::to_string(screen_co[0]) + "," + std::to_string(y));
}
+ /* Close patch (cyclic)*/
+ // txt.append("z");
+ gps_node.append_attribute("d").set_value(txt.c_str());
}
}
}
More information about the Bf-blender-cvs
mailing list