javafx-out.cpp revision f8eaa447bca02c775a06c0f7cce3ce8353161c86
/*
* A simple utility for exporting Inkscape svg Shapes as JavaFX paths.
*
* For information on the JavaFX file format, see:
*
* Authors:
* Bob Jamison <ishmal@inkscape.org>
*
* Copyright (C) 2008 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "javafx-out.h"
#include <inkscape.h>
#include <inkscape_version.h>
#include <sp-path.h>
#include <style.h>
#include <libnr/n-art-bpath.h>
#include <string>
#include <stdio.h>
#include <stdarg.h>
namespace Inkscape
{
namespace Extension
{
namespace Internal
{
//########################################################################
//# OUTPUT FORMATTING
//########################################################################
/**
* We want to control floating output format
*/
{
"%.8f", (gdouble)d);
return s;
}
/**
* Output data to the buffer, printf()-style
*/
{
}
/**
* Output the file header
*/
{
out("/*###################################################################\n");
out("### This JavaFX document was generated by Inkscape\n");
out("### http://www.inkscape.org\n");
out("#####################################################################\n");
out("### NOTES:\n");
out("### ============\n");
out("### JavaFX information can be found at\n");
out("### hhttps://openjfx.dev.java.net\n");
out("###\n");
out("### If you have any problems with this output, please see the\n");
out("### Inkscape project at http://www.inkscape.org, or visit\n");
out("### the #inkscape channel on irc.freenode.net . \n");
out("###\n");
out("###################################################################*/\n");
out("\n\n");
out("/*###################################################################\n");
out("## Exports in this file\n");
out("##==========================\n");
out("###################################################################*/\n");
out("\n\n");
out("import javafx.ui.UIElement;\n");
out("import javafx.ui.*;\n");
out("import javafx.ui.canvas.*;\n");
out("\n");
out("import java.lang.System;\n");
out("\n\n");
out("}\n");
out("\n\n");
out("Group\n");
out(" {\n");
out(" content:\n");
out(" [\n");
return true;
}
/**
* Output the file footer
*/
{
out(" ] // content\n");
out(" }; // Group\n");
out("\n\n\n\n");
out("Frame {\n");
out(" title: \"Test\"\n");
out(" width: 500\n");
out(" height: 500\n");
out(" onClose: function()\n");
out(" {\n");
out(" return System.exit( 0 );\n");
out(" }\n");
out(" visible: true\n");
out(" content: Canvas {\n");
out(" content: tux{}\n");
out(" }\n");
out("}\n");
out("/*###################################################################\n");
out("###################################################################*/\n");
out("\n\n");
return true;
}
/**
* Output the curve data to buffer
*/
{
using Geom::X;
using Geom::Y;
//### Get the Shape
return true;
return true;
nrShapes++;
out(" /*###################################################\n");
out(" ###################################################*/\n");
out(" Path \n");
out(" {\n");
/**
* Get the fill and stroke of the shape
*/
if (style)
{
/**
* Fill
*/
{
// see color.h for how to parse SPColor
unsigned int r = SP_RGBA32_R_U(rgba);
unsigned int g = SP_RGBA32_G_U(rgba);
unsigned int b = SP_RGBA32_B_U(rgba);
unsigned int a = SP_RGBA32_A_U(rgba);
out(" fill: rgba(0x%02x, 0x%02x, 0x%02x, 0x%02x)\n",
r, g, b, a);
}
/**
* Stroke
*/
/**
* TODO: stroke code here
*/
}
// convert the path to only lineto's and cubic curveto's:
//Count the NR_CURVETOs/LINETOs (including closing line segment)
guint segmentCount = 0;
segmentCount += 1;
}
out(" d:\n");
out(" [\n");
unsigned int segmentNr = 0;
/**
* For all Subpaths in the <path>
*/
{
out(" MoveTo {\n");
out(" absolute: true\n");
out(" },\n");
/**
* For all segments in the subpath
*/
{
//### LINE
{
out(" LineTo {\n");
out(" absolute: true\n");
out(" },\n");
nrNodes++;
}
//### BEZIER
{
out(" CurveTo {\n");
out(" absolute: true\n");
out(" },\n");
nrNodes++;
}
else
{
g_error ("logical error, because pathv_to_linear_and_cubic_beziers was used");
}
segmentNr++;
}
{
out(" ClosePath {},\n");
}
}
out(" ] // d\n");
out(" }, // Path\n");
out(" /*###################################################\n");
out(" ###################################################*/\n\n\n\n");
return true;
}
/**
* Output the curve data to buffer
*/
{
/**
* If the object is an Item, try processing it
*/
{
return false;
}
/**
* Descend into children
*/
{
return false;
}
return true;
}
/**
* Output the curve data to buffer
*/
{
double bignum = 1000000.0;
return false;
return true;
}
//########################################################################
//# M A I N O U T P U T
//########################################################################
/**
* Set values back to initial state
*/
void JavaFXOutput::reset()
{
nrNodes = 0;
nrSegments = 0;
nrShapes = 0;
}
/**
* Saves the <paths> of an Inkscape SVG file as JavaFX spline definitions
*/
{
reset();
if (pos > 0)
//###### SAVE IN POV FORMAT TO BUFFER
//# Lets do the curves first, to get the stats
return false;
return false;
return false;
//###### WRITE TO FILE
if (!f)
{
return false;
}
{
}
fclose(f);
return true;
}
//########################################################################
//# EXTENSION API
//########################################################################
#include "clear-n_.h"
/**
* API call to save document
*/
void
{
{
}
}
/**
* Make sure that we are in the database
*/
{
/* We don't need a Key
if (NULL == Inkscape::Extension::db.get(SP_MODULE_KEY_OUTPUT_JFX))
return FALSE;
*/
return true;
}
/**
* This is the definition of JavaFX output. This function just
* calls the extension system with the memory allocated XML that
* describes the data.
*/
void
JavaFXOutput::init()
{
"<id>org.inkscape.output.jfx</id>\n"
"<output>\n"
"<extension>.fx</extension>\n"
"<mimetype>text/x-javafx-script</mimetype>\n"
"</output>\n"
"</inkscape-extension>",
new JavaFXOutput());
}
} // namespace Internal
} // namespace Extension
} // namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :