diff --git a/.checkstyle b/.checkstyle
index 34ed486..428926e 100644
--- a/.checkstyle
+++ b/.checkstyle
@@ -1,7 +1,7 @@
-
+
diff --git a/.classpath b/.classpath
index 5c16154..a18b558 100644
--- a/.classpath
+++ b/.classpath
@@ -21,12 +21,17 @@
+
+
+
+
+
-
+
diff --git a/CheckStyle.xml b/CheckStyle.xml
index d68aedd..d8fa07b 100755
--- a/CheckStyle.xml
+++ b/CheckStyle.xml
@@ -1,14 +1,14 @@
-
+
+-.
+-.
diff --git a/CleanUp.xml b/CleanUp.xml
index 6cf4cba..7765a4e 100644
--- a/CleanUp.xml
+++ b/CleanUp.xml
@@ -1,106 +1,106 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
diff --git a/Formatter.xml b/Formatter.xml
index 18e9720..100e998 100644
--- a/Formatter.xml
+++ b/Formatter.xml
@@ -1,390 +1,390 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
diff --git a/TestExternworddown.svg b/TestExternworddown.svg
new file mode 100644
index 0000000..765cd7e
--- /dev/null
+++ b/TestExternworddown.svg
@@ -0,0 +1,66 @@
+
+| *
- // * * * | *
- // * . | . * . . . . . . . . * *
- // * . | . * | *
- // * A . | . B * | *
- // . * . | *
- // . * * . * * * * * * * * * * * * *
- // * *
- // * *
- for (long idPevious=itListPoint.size()-1, idCurrent=0, idNext=1;
- idCurrent < long(itListPoint.size());
- idPevious = idCurrent++, idNext++) {
- if (idNext == long(itListPoint.size())) {
- idNext = 0;
- }
- if ( itListPoint[idCurrent].this.type == esvg::render::Point::type::join
- || itListPoint[idCurrent].this.type == esvg::render::Point::type::interpolation) {
- if (idPevious < 0 ) {
- Log.error("an error occure a previous ID is < 0.... ");
- continue;
- }
- if (idNext >= long(itListPoint.size())) {
- Log.error("an error occure a next ID is >= nbPoint len .... ");
- continue;
- }
- //Log.debug("JOIN : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext);
- //Log.debug("JOIN : val : prev/curr/next : " << itListPoint[idPevious].this.pos << "/" << itListPoint[idCurrent].this.pos << "/" << itListPoint[idNext].this.pos);
- Vector2f vecA = itListPoint[idCurrent].this.pos - itListPoint[idPevious].this.pos;
- //Log.debug("JOIN : vecA : " << vecA);
- vecA.safeNormalize();
- Vector2f vecB = itListPoint[idNext].this.pos - itListPoint[idCurrent].this.pos;
- //Log.debug("JOIN : vecB : " << vecB);
- vecB.safeNormalize();
- Vector2f vecC = vecA - vecB;
- //Log.debug("JOIN : vecC : " << vecC);
- if (vecC == Vector2f(0.0f, 0.0f)) {
- // special case: 1 line ...
- itListPoint[idCurrent].this.miterAxe = Vector2f(vecA.y(), vecA.x());
- } else {
- vecC.safeNormalize();
- itListPoint[idCurrent].this.miterAxe = vecC;
- }
- itListPoint[idCurrent].this.posPrevious = itListPoint[idPevious].this.pos;
- itListPoint[idCurrent].this.posNext = itListPoint[idNext].this.pos;
- vecB = itListPoint[idNext].this.pos - itListPoint[idCurrent].this.pos;
- vecB.safeNormalize();
- itListPoint[idCurrent].this.orthoAxeNext = Vector2f(vecB.y(), -vecB.x());
- vecB = itListPoint[idCurrent].this.pos - itListPoint[idPevious].this.pos;
- vecB.safeNormalize();
- itListPoint[idCurrent].this.orthoAxePrevious = Vector2f(vecB.y(), -vecB.x());
- //Log.debug("JOIN : miterAxe " << itListPoint[idCurrent].this.miterAxe);
- } else if (itListPoint[idCurrent].this.type == esvg::render::Point::type::start) {
- itListPoint[idCurrent].this.posNext = itListPoint[idNext].this.pos;
- Vector2f vecB = itListPoint[idNext].this.pos - itListPoint[idCurrent].this.pos;
- vecB.safeNormalize();
- itListPoint[idCurrent].this.miterAxe = Vector2f(vecB.y(), -vecB.x());
- itListPoint[idCurrent].this.orthoAxePrevious = itListPoint[idCurrent].this.miterAxe;
- itListPoint[idCurrent].this.orthoAxeNext = itListPoint[idCurrent].this.miterAxe;
- } else if (itListPoint[idCurrent].this.type == esvg::render::Point::type::stop) {
- if (idPevious < 0 ) {
- Log.error("an error occure a previous ID is < 0.... ");
- continue;
- }
- itListPoint[idCurrent].this.posPrevious = itListPoint[idPevious].this.pos;
- Vector2f vecA = itListPoint[idCurrent].this.pos - itListPoint[idPevious].this.pos;
- vecA.safeNormalize();
- itListPoint[idCurrent].this.miterAxe = Vector2f(vecA.y(), -vecA.x());
- itListPoint[idCurrent].this.orthoAxePrevious = itListPoint[idCurrent].this.miterAxe;
- itListPoint[idCurrent].this.orthoAxeNext = itListPoint[idCurrent].this.miterAxe;
- } else {
- Log.todo("Unsupported type of point ....");
- }
- }
- // create segment list:
- boolean haveStartLine = false;
- Vector2f leftPoint(0,0);
- Vector2f rightPoint(0,0);
- if (itListPoint.size() > 0) {
- if (itListPoint.front().this.type == esvg::render::Point::type::join) {
- const esvg::render::Point& it = itListPoint.back();
- // Calculate the perpendiculary axis ...
- leftPoint = itListPoint.back().this.pos
- + itListPoint.back().this.orthoAxePrevious*_width*0.5f;
- rightPoint = itListPoint.back().this.pos
- - itListPoint.back().this.orthoAxePrevious*_width*0.5f;
- // cyclic path...
- if (it.this.type == esvg::render::Point::type::interpolation) {
- leftPoint = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- rightPoint = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- } else if (it.this.type == esvg::render::Point::type::join) {
- // Calculate the perpendiculary axis ...
- leftPoint = it.this.pos
- + it.this.orthoAxePrevious*_width*0.5f;
- rightPoint = it.this.pos
- - it.this.orthoAxePrevious*_width*0.5f;
- // project on the miter Axis ...
- switch (_join) {
- case esvg::join_miter:
- {
- Vector2f left = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- Vector2f right = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- // Check the miter limit:
- float limitRight = (left - it.this.pos).length() / _width * 2.0f;
- float limitLeft = (right - it.this.pos).length() / _width * 2.0f;
- Log.verbose(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit);
- if ( limitRight <= _miterLimit
- && limitLeft <= _miterLimit) {
- leftPoint = left;
- rightPoint = right;
- break;
- } else {
- // BEVEL the miter point ...
- }
- }
- case esvg::join_round:
- case esvg::join_bevel:
- {
- Vector2f axePrevious = (it.this.pos-it.this.posPrevious).safeNormalize();
- Vector2f axeNext = (it.this.posNext - it.this.pos).safeNormalize();
- float cross = axePrevious.cross(axeNext);
- if (cross > 0.0f) {
- rightPoint = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- leftPoint = it.this.pos
- + it.this.orthoAxeNext*_width*0.5f;
- } else {
- leftPoint = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- rightPoint = it.this.pos
- - it.this.orthoAxeNext*_width*0.5f;
- }
- break;
- }
- }
- } else {
- Log.error("Start list point with a join, but last lement is not a join");
- }
- }
- }
- for (auto &it : itListPoint) {
- switch (it.this.type) {
- case esvg::render::Point::type::single:
- // just do nothing ....
- Log.verbose("Find Single " << it.this.pos);
- break;
- case esvg::render::Point::type::start:
- Log.verbose("Find Start " << it.this.pos);
- if (haveStartLine == true) {
- // close previous :
- Log.warning(" find a non close path ...");
- addSegment(leftPoint, rightPoint);
- }
- haveStartLine = true;
- startStopPoint(leftPoint, rightPoint, it, _cap, _width, true);
- break;
- case esvg::render::Point::type::stop:
- Log.verbose("Find Stop " << it.this.pos);
- if (haveStartLine == false) {
- Log.warning("find close path without start part ...");
- break;
- }
- haveStartLine = false;
- startStopPoint(leftPoint, rightPoint, it, _cap, _width, false);
- break;
- case esvg::render::Point::type::interpolation:
- {
- Log.verbose("Find interpolation " << it.this.pos);
- Vector2f left = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- Vector2f right = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- //Draw from previous point:
- addSegment(leftPoint, left);
- Log.verbose(" segment :" << leftPoint << " -> " << left);
- addSegment(right, rightPoint);
- Log.verbose(" segment :" << right << " -> " << rightPoint);
- leftPoint = left;
- rightPoint = right;
- }
- break;
- case esvg::render::Point::type::join:
- Log.verbose("Find join " << it.this.pos);
- switch (_join) {
- case esvg::join_miter:
- {
- Vector2f left = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- Vector2f right = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- // Check the miter limit:
- float limitRight = (left - it.this.pos).length() / _width * 2.0f;
- float limitLeft = (right - it.this.pos).length() / _width * 2.0f;
- Log.verbose(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit);
- if ( limitRight <= _miterLimit
- && limitLeft <= _miterLimit) {
- //Draw from previous point:
- addSegment(leftPoint, left);
- Log.verbose(" segment :" << leftPoint << " -> " << left);
- addSegment(right, rightPoint);
- Log.verbose(" segment :" << right << " -> " << rightPoint);
- leftPoint = left;
- rightPoint = right;
- break;
- } else {
- // We do a bevel join ...
- Log.verbose(" Find miter Limit ... ==> create BEVEL");
- }
- }
- case esvg::join_round:
- case esvg::join_bevel:
- {
- Vector2f axePrevious = (it.this.pos-it.this.posPrevious).safeNormalize();
- Vector2f axeNext = (it.this.posNext - it.this.pos).safeNormalize();
- float cross = axePrevious.cross(axeNext);
- if (cross > 0.0f) {
- Vector2f right = getIntersect(rightPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- Vector2f left1 = it.this.pos
- + it.this.orthoAxePrevious*_width*0.5f;
- Vector2f left2 = it.this.pos
- + it.this.orthoAxeNext*_width*0.5f;
- //Draw from previous point:
- addSegment(leftPoint, left1);
- Log.verbose(" segment :" << leftPoint << " -> " << left1);
- if (_join != esvg::join_round) {
- // Miter and bevel:
- addSegment(left1, left2);
- Log.verbose(" segment :" << left1 << " -> " << left2);
- }else {
- createSegmentListStroke(left1,
- left2,
- it.this.pos,
- _width,
- false);
- }
- addSegment(right, rightPoint);
- Log.verbose(" segment :" << right << " -> " << rightPoint);
- leftPoint = left2;
- rightPoint = right;
- } else {
- Vector2f left = getIntersect(leftPoint, it.this.pos-it.this.posPrevious, it.this.pos, it.this.miterAxe);
- Vector2f right1 = it.this.pos
- - it.this.orthoAxePrevious*_width*0.5f;
- Vector2f right2 = it.this.pos
- - it.this.orthoAxeNext*_width*0.5f;//Draw from previous point:
- addSegment(leftPoint, left);
- Log.verbose(" segment :" << leftPoint << " -> " << left);
- addSegment(right1, rightPoint);
- Log.verbose(" segment :" << right1 << " -> " << rightPoint);
- if (_join != esvg::join_round) {
- // Miter and bevel:
- addSegment(right2, right1);
- Log.verbose(" segment :" << right2 << " -> " << right1);
- } else {
- createSegmentListStroke(right1,
- right2,
- it.this.pos,
- _width,
- true);
- }
- leftPoint = left;
- rightPoint = right2;
- }
- }
- break;
- }
- break;
- }
- }
- }
-}
-
-void esvg::render::SegmentList::startStopPoint(Vector2f& _leftPoint,
- Vector2f& _rightPoint,
- const esvg::render::Point& _point,
- enum esvg::cap _cap,
- float _width,
- boolean _isStart) {
- switch (_cap) {
- case esvg::cap_butt:
- {
- Vector2f left = _point.this.pos
- + _point.this.miterAxe*_width*0.5f;
- Vector2f right = _point.this.pos
- - _point.this.miterAxe*_width*0.5f;
- if (_isStart == false) {
- //Draw from previous point:
- addSegment(_leftPoint, left);
- Log.verbose(" segment :" << _leftPoint << " -> " << left);
- addSegment(right, _rightPoint);
- Log.verbose(" segment :" << right << " -> " << _rightPoint);
- }
- _leftPoint = left;
- _rightPoint = right;
- }
- if (_isStart == false) {
- addSegment(_leftPoint, _rightPoint);
- Log.verbose(" segment :" << _leftPoint << " -> " << _rightPoint);
- } else {
- addSegment(_rightPoint, _leftPoint);
- Log.verbose(" segment :" << _rightPoint << " -> " << _leftPoint);
- }
- break;
- case esvg::cap_round:
- {
- if (_isStart == false) {
- Vector2f left = _point.this.pos
- + _point.this.miterAxe*_width*0.5f;
- Vector2f right = _point.this.pos
- - _point.this.miterAxe*_width*0.5f;
- if (_isStart == false) {
- //Draw from previous point:
- addSegment(_leftPoint, left);
- Log.verbose(" segment :" << _leftPoint << " -> " << left);
- addSegment(right, _rightPoint);
- Log.verbose(" segment :" << right << " -> " << _rightPoint);
- }
- _leftPoint = left;
- _rightPoint = right;
- }
- int nbDot = int(_width);
- if (nbDot <= 2) {
- nbDot = 2;
- }
- float baseAngle = M_PI/float(nbDot);
- float iii;
- _leftPoint = _point.this.pos
- + _point.this.miterAxe*_width*0.5f;
- _rightPoint = _point.this.pos
- - _point.this.miterAxe*_width*0.5f;
- createSegmentListStroke(_leftPoint,
- _rightPoint,
- _point.this.pos,
- _width,
- _isStart);
- }
- break;
- case esvg::cap_square:
- {
- Vector2f nextAxe;
- if (_isStart == true) {
- nextAxe = _point.this.posNext - _point.this.pos;
- } else {
- nextAxe = _point.this.posPrevious - _point.this.pos;
- }
- Vector2f left = _point.this.pos
- + _point.this.miterAxe*_width*0.5f;
- Vector2f right = _point.this.pos
- - _point.this.miterAxe*_width*0.5f;
- mat2x3 tmpMat = etk::mat2x3Translate(nextAxe.safeNormalize()*_width*-0.5f);
- left = tmpMat*left;
- right = tmpMat*right;
- if (_isStart == false) {
- if (_isStart == false) {
- //Draw from previous point:
- addSegment(_leftPoint, left);
- Log.verbose(" segment :" << _leftPoint << " -> " << left);
- addSegment(right, _rightPoint);
- Log.verbose(" segment :" << right << " -> " << _rightPoint);
- }
- }
- _leftPoint = left;
- _rightPoint = right;
- if (_isStart == false) {
- addSegment(_leftPoint, _rightPoint);
- Log.verbose(" segment :" << _leftPoint << " -> " << _rightPoint);
- } else {
- addSegment(_rightPoint, _leftPoint);
- Log.verbose(" segment :" << _rightPoint << " -> " << _leftPoint);
- }
- Log.verbose(" segment :" << _leftPoint << " -> " << _rightPoint);
- }
- break;
- default:
- Log.error(" Undefined CAP TYPE");
- break;
- }
-}
-
-void esvg::render::SegmentList::applyMatrix(const mat2x3& _transformationMatrix) {
- for (auto &it : this.data) {
- it.applyMatrix(_transformationMatrix);
- }
-}
-
diff --git a/src/org/atriasoft/esvg/render/SegmentList.java b/src/org/atriasoft/esvg/render/SegmentList.java
index c47058c..9a0e3c1 100644
--- a/src/org/atriasoft/esvg/render/SegmentList.java
+++ b/src/org/atriasoft/esvg/render/SegmentList.java
@@ -1,49 +1,457 @@
package org.atriasoft.esvg.render;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.atriasoft.etk.math.Vector2f;
+import org.atriasoft.etk.util.Pair;
+import org.atriasoft.etk.math.FMath;
+import org.atriasoft.etk.math.Matrix2x3f;
+import org.atriasoft.esvg.CapMode;
+import org.atriasoft.esvg.JoinMode;
+import org.atriasoft.esvg.internal.Log;
+
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
-#pragma once
-#include#include#include#include#include#include
-
-namespace esvg{namespace render{
-class SegmentList {
- public:
- List this.data;
- public:
- SegmentList();#ifdef DEBUG
-
- void addSegment(const Vector2f& _pos0, const Vector2f& _pos1);
- #endif
-
- void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1);
-
- void addSegment(const esvg::render::Point& _pos0, const esvg::render::Point& _pos1, boolean _disableHorizontal);
-
- void createSegmentList(const esvg::render::PointList& _listPoint);
-
- void createSegmentListStroke(esvg::render::PointList& _listPoint,
- float _width,
- enum esvg::cap _cap,
- enum esvg::join _join,
- float _miterLimit);
- private:
- void startStopPoint(Vector2f& _leftPoint,
- Vector2f& _rightPoint,
- const esvg::render::Point& _point,
- enum esvg::cap _cap,
- float _width,
- boolean _isStart);
- void createSegmentListStroke(const Vector2f& _point1,
- const Vector2f& _point2,
- const Vector2f& _center,
- float _width,
- boolean _isStart);
- public:
- Pair getViewPort();
- void applyMatrix(const mat2x3& _transformationMatrix);
- };
+public class SegmentList {
+ static Vector2f getIntersect(final Vector2f point1, final Vector2f vect1, final Vector2f point2, final Vector2f vect2) {
+ float diviseur = vect1.x() * vect2.y() - vect1.y() * vect2.x();
+ if (diviseur != 0.0f) {
+ float mmm = (vect1.x() * point1.y() - vect1.x() * point2.y() - vect1.y() * point1.x() + vect1.y() * point2.x()) / diviseur;
+ return point2.add(vect2.multiply(mmm));
+ }
+ Log.error("Get divider / 0.0f");
+ return point2;
}
+
+ public List data = new ArrayList<>();
+
+ public SegmentList() {}
+
+ public void addSegment(final Point pos0, final Point pos1) {
+ // Skip horizontal Segments
+ if (pos0.pos.y() == pos1.pos.y()) {
+ // remove /0 operation
+ return;
+ }
+ this.data.add(new Segment(pos0.pos, pos1.pos));
+ }
+
+ public void addSegment(final Point pos0, final Point pos1, final boolean disableHorizontal) {
+ // Skip horizontal Segments
+ if (disableHorizontal && pos0.pos.y() == pos1.pos.y()) {
+ // remove /0 operation
+ return;
+ }
+ this.data.add(new Segment(pos0.pos, pos1.pos));
+ }
+
+ // TODO is it really needed...
+ void addSegment(final Vector2f pos0, final Vector2f pos1) {
+ this.data.add(new Segment(pos0, pos1));
+ }
+
+ public void applyMatrix(final Matrix2x3f transformationMatrix) {
+ for (Segment it : this.data) {
+ it.applyMatrix(transformationMatrix);
+ }
+ }
+
+ public void createSegmentList(final PointList listPoint) {
+ for (List it : listPoint.data) {
+ // Build Segments
+ for (int iii = 0, jjj = it.size() - 1; iii < it.size(); jjj = iii++) {
+ addSegment(it.get(jjj), it.get(iii));
+ }
+ }
+ }
+
+ public void createSegmentListStroke(final PointList listPoint, final float width, final CapMode cap, final JoinMode join, final float miterLimit) {
+ for (List itListPoint : listPoint.data) {
+ // generate for every point all the orthogonal elements
+ //
+ // normal edge * end path
+ // (mitter) * | * * * * * * * * * * * * * *
+ // * |<--*----this | *
+ // * | * this -.| *
+ // * * * | *
+ // * . | . * . . . . . . . . * *
+ // * . | . * | *
+ // * A . | . B * | *
+ // . * . | *
+ // . * * . * * * * * * * * * * * * *
+ // * *
+ // * *
+ for (int idPevious = itListPoint.size() - 1, idCurrent = 0, idNext = 1; idCurrent < itListPoint.size(); idPevious = idCurrent++, idNext++) {
+ if (idNext == itListPoint.size()) {
+ idNext = 0;
+ }
+ if (itListPoint.get(idCurrent).type == PointType.join || itListPoint.get(idCurrent).type == PointType.interpolation) {
+ if (idPevious < 0) {
+ Log.error("an error occure a previous ID is < 0.... ");
+ continue;
+ }
+ if (idNext >= itListPoint.size()) {
+ Log.error("an error occure a next ID is >= nbPoint len .... ");
+ continue;
+ }
+ //Log.debug("JOIN : id : prev/curr/next : " + idPevious + "/" + idCurrent + "/" + idNext);
+ //Log.debug("JOIN : val : prev/curr/next : " + itListPoint.get(idPevious).pos + "/" + itListPoint.get(idCurrent).pos + "/" + itListPoint.get(idNext).pos);
+ Vector2f vecA = itListPoint.get(idCurrent).pos.less(itListPoint.get(idPevious).pos);
+ //Log.debug("JOIN : vecA : " + vecA);
+ vecA.safeNormalize();
+ Vector2f vecB = itListPoint.get(idNext).pos.less(itListPoint.get(idCurrent).pos);
+ //Log.debug("JOIN : vecB : " + vecB);
+ vecB.safeNormalize();
+ Vector2f vecC = vecA.less(vecB);
+ //Log.debug("JOIN : vecC : " + vecC);
+ if (vecC.isZero()) {
+ // special case: 1 line ...
+ itListPoint.get(idCurrent).miterAxe = new Vector2f(vecA.y(), vecA.x());
+ } else {
+ vecC.safeNormalize();
+ itListPoint.get(idCurrent).miterAxe = vecC;
+ }
+ itListPoint.get(idCurrent).posPrevious = itListPoint.get(idPevious).pos;
+ itListPoint.get(idCurrent).posNext = itListPoint.get(idNext).pos;
+ vecB = itListPoint.get(idNext).pos.less(itListPoint.get(idCurrent).pos);
+ vecB.safeNormalize();
+ itListPoint.get(idCurrent).orthoAxeNext = new Vector2f(vecB.y(), -vecB.x());
+ vecB = itListPoint.get(idCurrent).pos.less(itListPoint.get(idPevious).pos);
+ vecB.safeNormalize();
+ itListPoint.get(idCurrent).orthoAxePrevious = new Vector2f(vecB.y(), -vecB.x());
+ //Log.debug("JOIN : miterAxe " + itListPoint.get(idCurrent).miterAxe);
+ } else if (itListPoint.get(idCurrent).type == PointType.start) {
+ itListPoint.get(idCurrent).posNext = itListPoint.get(idNext).pos;
+ Vector2f vecB = itListPoint.get(idNext).pos.less(itListPoint.get(idCurrent).pos);
+ vecB.safeNormalize();
+ itListPoint.get(idCurrent).miterAxe = new Vector2f(vecB.y(), -vecB.x());
+ itListPoint.get(idCurrent).orthoAxePrevious = itListPoint.get(idCurrent).miterAxe;
+ itListPoint.get(idCurrent).orthoAxeNext = itListPoint.get(idCurrent).miterAxe;
+ } else if (itListPoint.get(idCurrent).type == PointType.stop) {
+ if (idPevious < 0) {
+ Log.error("an error occure a previous ID is < 0.... ");
+ continue;
+ }
+ itListPoint.get(idCurrent).posPrevious = itListPoint.get(idPevious).pos;
+ Vector2f vecA = itListPoint.get(idCurrent).pos.less(itListPoint.get(idPevious).pos);
+ vecA.safeNormalize();
+ itListPoint.get(idCurrent).miterAxe = new Vector2f(vecA.y(), -vecA.x());
+ itListPoint.get(idCurrent).orthoAxePrevious = itListPoint.get(idCurrent).miterAxe;
+ itListPoint.get(idCurrent).orthoAxeNext = itListPoint.get(idCurrent).miterAxe;
+ } else {
+ Log.todo("Unsupported type of point ....");
+ }
+ }
+ // create segment list:
+ boolean haveStartLine = false;
+
+ Vector2f leftPoint = Vector2f.ZERO;
+
+ Vector2f rightPoint = Vector2f.ZERO;
+ if (itListPoint.size() > 0) {
+ if (itListPoint.get(0).type == PointType.join) {
+ Point it = itListPoint.get(itListPoint.size() - 1);
+ // Calculate the perpendiculary axis ...
+ leftPoint = it.pos.add(it.orthoAxePrevious.multiply(width * 0.5f));
+ rightPoint = it.pos.less(it.orthoAxePrevious.multiply(width * 0.5f));
+ // cyclic path...
+ if (it.type == PointType.interpolation) {
+ leftPoint = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ rightPoint = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ } else if (it.type == PointType.join) {
+ // Calculate the perpendiculary axis ...
+ leftPoint = it.pos.add(it.orthoAxePrevious.multiply(width * 0.5f));
+ rightPoint = it.pos.less(it.orthoAxePrevious.multiply(width * 0.5f));
+ // project on the miter Axis ...
+ switch (join) {
+ case MITER: {
+ Vector2f left = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ Vector2f right = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ // Check the miter limit:
+ float limitRight = (left.less(it.pos)).length() / width * 2.0f;
+ float limitLeft = (right.less(it.pos)).length() / width * 2.0f;
+ Log.verbose(" miter Limit: " + limitRight + " " + limitLeft + " <= " + miterLimit);
+ if (limitRight <= miterLimit && limitLeft <= miterLimit) {
+ leftPoint = left;
+ rightPoint = right;
+ break;
+ }
+ }
+ case ROUND:
+ case BEVEL: {
+ Vector2f axePrevious = (it.pos.less(it.posPrevious)).safeNormalize();
+ Vector2f axeNext = (it.posNext.less(it.pos)).safeNormalize();
+ float cross = axePrevious.cross(axeNext);
+ if (cross > 0.0f) {
+ rightPoint = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ leftPoint = it.pos.add(it.orthoAxeNext.multiply(width * 0.5f));
+ } else {
+ leftPoint = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ rightPoint = it.pos.less(it.orthoAxeNext.multiply(width * 0.5f));
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ } else {
+ Log.error("Start list point with a join, but last lement is not a join");
+ }
+ }
+ }
+ for (Point it : itListPoint) {
+ switch (it.type) {
+ case single:
+ // just do nothing ....
+ Log.verbose("Find Single " + it.pos);
+ break;
+ case start:
+ Log.verbose("Find Start " + it.pos);
+ if (haveStartLine) {
+ // close previous :
+ Log.warning(" find a non close path ...");
+ addSegment(leftPoint, rightPoint);
+ }
+ haveStartLine = true;
+ startStopPoint(leftPoint, rightPoint, it, cap, width, true);
+ break;
+ case stop:
+ Log.verbose("Find Stop " + it.pos);
+ if (!haveStartLine) {
+ Log.warning("find close path without start part ...");
+ break;
+ }
+ haveStartLine = false;
+ startStopPoint(leftPoint, rightPoint, it, cap, width, false);
+ break;
+ case interpolation: {
+ Log.verbose("Find interpolation " + it.pos);
+ Vector2f left = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ Vector2f right = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ leftPoint = left;
+ rightPoint = right;
+ }
+ break;
+ case join:
+ Log.verbose("Find join " + it.pos);
+ switch (join) {
+ case MITER: {
+ Vector2f left = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ Vector2f right = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ // Check the miter limit:
+ float limitRight = left.less(it.pos).length() / width * 2.0f;
+ float limitLeft = right.less(it.pos).length() / width * 2.0f;
+ Log.verbose(" miter Limit: " + limitRight + " " + limitLeft + " <= " + miterLimit);
+ if (limitRight <= miterLimit && limitLeft <= miterLimit) {
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ leftPoint = left;
+ rightPoint = right;
+ break;
+ }
+ Log.verbose(" Find miter Limit ... ==> create BEVEL");
+ }
+ case ROUND:
+ case BEVEL: {
+ Vector2f axePrevious = (it.pos.less(it.posPrevious)).safeNormalize();
+ Vector2f axeNext = (it.posNext.less(it.pos)).safeNormalize();
+ float cross = axePrevious.cross(axeNext);
+ if (cross > 0.0f) {
+ Vector2f right = SegmentList.getIntersect(rightPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ Vector2f left1 = it.pos.add(it.orthoAxePrevious.multiply(width * 0.5f));
+ Vector2f left2 = it.pos.add(it.orthoAxeNext.multiply(width * 0.5f));
+ //Draw from previous point:
+ addSegment(leftPoint, left1);
+ Log.verbose(" segment :" + leftPoint + " . " + left1);
+ if (join != JoinMode.ROUND) {
+ // Miter and bevel:
+ addSegment(left1, left2);
+ Log.verbose(" segment :" + left1 + " . " + left2);
+ } else {
+ createSegmentListStroke(left1, left2, it.pos, width, false);
+ }
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ leftPoint = left2;
+ rightPoint = right;
+ } else {
+ Vector2f left = SegmentList.getIntersect(leftPoint, it.pos.less(it.posPrevious), it.pos, it.miterAxe);
+ Vector2f right1 = it.pos.less(it.orthoAxePrevious.multiply(width * 0.5f));
+ Vector2f right2 = it.pos.less(it.orthoAxeNext.multiply(width * 0.5f));
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right1, rightPoint);
+ Log.verbose(" segment :" + right1 + " . " + rightPoint);
+ if (join != JoinMode.ROUND) {
+ // Miter and bevel:
+ addSegment(right2, right1);
+ Log.verbose(" segment :" + right2 + " . " + right1);
+ } else {
+ createSegmentListStroke(right1, right2, it.pos, width, true);
+ }
+ leftPoint = left;
+ rightPoint = right2;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ }
+
+ private void createSegmentListStroke(final Vector2f point1, final Vector2f point2, final Vector2f center, final float width, final boolean isStart) {
+ int nbDot = (int) width;
+ if (nbDot <= 2) {
+ nbDot = 2;
+ }
+ float angleToDraw = FMath.acos((point1.less(center)).safeNormalize().dot((point2.less(center)).safeNormalize()));
+ float baseAngle = angleToDraw / nbDot;
+ float iii;
+ Vector2f axe = (point1.less(center)).safeNormalize();
+
+ Vector2f ppp1 = point1;
+
+ Vector2f ppp2 = point2;
+ for (iii = baseAngle; iii < angleToDraw; iii += baseAngle) {
+ Matrix2x3f tmpMat = Matrix2x3f.IDENTITY;
+ if (isStart) {
+ tmpMat = Matrix2x3f.createRotate(-iii);
+ } else {
+ tmpMat = Matrix2x3f.createRotate(iii);
+ }
+ Vector2f axeRotate = tmpMat.multiply(axe);
+ ppp2 = center.add(axeRotate.multiply(width * 0.5f));
+ if (isStart) {
+ addSegment(ppp2, ppp1);
+ Log.verbose(" segment :" + ppp2 + " . " + ppp1);
+ } else {
+ addSegment(ppp1, ppp2);
+ Log.verbose(" segment :" + ppp1 + " . " + ppp2);
+ }
+ ppp1 = ppp2;
+ }
+ if (isStart) {
+ addSegment(point2, ppp1);
+ Log.verbose(" segment :" + point2 + " . " + ppp1);
+ } else {
+ addSegment(ppp1, point2);
+ Log.verbose(" segment :" + ppp1 + " . " + point2);
+ }
+ }
+
+ public Pair getViewPort() {
+
+ Pair out = new Pair<>(Vector2f.MAX_VALUE, Vector2f.MIN_VALUE);
+ for (Segment it : this.data) {
+ out = new Pair<>(Vector2f.min(out.first, it.p0, it.p1), Vector2f.max(out.second, it.p0, it.p1));
+ }
+ return out;
+ }
+
+ private void startStopPoint(Vector2f leftPoint, Vector2f rightPoint, final Point point, final CapMode cap, final float width, final boolean isStart) {
+ switch (cap) {
+ case BUTT: {
+ Vector2f left = point.pos.add(point.miterAxe.multiply(width * 0.5f));
+ Vector2f right = point.pos.less(point.miterAxe.multiply(width * 0.5f));
+ if (!isStart) {
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ }
+ leftPoint = left;
+ rightPoint = right;
+ }
+ if (!isStart) {
+ addSegment(leftPoint, rightPoint);
+ Log.verbose(" segment :" + leftPoint + " . " + rightPoint);
+ } else {
+ addSegment(rightPoint, leftPoint);
+ Log.verbose(" segment :" + rightPoint + " . " + leftPoint);
+ }
+ break;
+ case ROUND: {
+ if (!isStart) {
+ Vector2f left = point.pos.add(point.miterAxe.multiply(width * 0.5f));
+ Vector2f right = point.pos.less(point.miterAxe.multiply(width * 0.5f));
+ if (!isStart) {
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ }
+ leftPoint = left;
+ rightPoint = right;
+ }
+ int nbDot = (int) width;
+ if (nbDot <= 2) {
+ nbDot = 2;
+ }
+ leftPoint = point.pos.add(point.miterAxe.multiply(width * 0.5f));
+ rightPoint = point.pos.less(point.miterAxe.multiply(width * 0.5f));
+ createSegmentListStroke(leftPoint, rightPoint, point.pos, width, isStart);
+ }
+ break;
+ case SQUARE: {
+ Vector2f nextAxe;
+ if (isStart) {
+ nextAxe = point.posNext.less(point.pos);
+ } else {
+ nextAxe = point.posPrevious.less(point.pos);
+ }
+ Vector2f left = point.pos.add(point.miterAxe.multiply(width * 0.5f));
+ Vector2f right = point.pos.less(point.miterAxe.multiply(width * 0.5f));
+ Matrix2x3f tmpMat = Matrix2x3f.createTranslate(nextAxe.safeNormalize().multiply(width * -0.5f));
+ left = tmpMat.multiply(left);
+ right = tmpMat.multiply(right);
+ if (!isStart) {
+ if (!isStart) {
+ //Draw from previous point:
+ addSegment(leftPoint, left);
+ Log.verbose(" segment :" + leftPoint + " . " + left);
+ addSegment(right, rightPoint);
+ Log.verbose(" segment :" + right + " . " + rightPoint);
+ }
+ }
+ leftPoint = left;
+ rightPoint = right;
+ if (!isStart) {
+ addSegment(leftPoint, rightPoint);
+ Log.verbose(" segment :" + leftPoint + " . " + rightPoint);
+ } else {
+ addSegment(rightPoint, leftPoint);
+ Log.verbose(" segment :" + rightPoint + " . " + leftPoint);
+ }
+ Log.verbose(" segment :" + leftPoint + " . " + rightPoint);
+ }
+ break;
+ default:
+ Log.error(" Undefined CAP TYPE");
+ break;
+ }
+ }
+
}
diff --git a/src/org/atriasoft/esvg/render/Weight.cpp b/src/org/atriasoft/esvg/render/Weight.cpp
deleted file mode 100644
index e2f049d..0000000
--- a/src/org/atriasoft/esvg/render/Weight.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/** @file
- * @author Edouard DUPIN
- * @copyright 2011, Edouard DUPIN, all right reserved
- * @license MPL v2.0 (see license file)
- */
-
-#include
-#include
-#include
-
-esvg::render::Weight::Weight() :
- this.size(0,0) {
-
-}
-
-esvg::render::Weight::Weight(const Vector2i& _size) :
- this.size(_size) {
- resize(_size);
-}
-
-esvg::render::Weight::~Weight() {
-
-}
-
-void esvg::render::Weight::resize(const Vector2i& _size) {
- this.size = _size;
- float tmp(0);
- this.data.resize(this.size.x()*this.size.y(), tmp);
- if ((uint)this.size.x()*this.size.y() > this.data.size()) {
- Log.warning("Wrong weigth buffer size ...");
- return;
- }
-}
-
-const Vector2i& esvg::render::Weight::getSize() const {
- return this.size;
-}
-
-int esvg::render::Weight::getWidth() const {
- return this.size.x();
-}
-
-int esvg::render::Weight::getHeight() const {
- return this.size.y();
-}
-
-void esvg::render::Weight::clear(float _fill) {
- for (int iii=0; iii=0 && _pos.x()=0 && _pos.y()=0 && _pos.x()=0 && _pos.y()=0
- && _posY=0
- && _posY& _e1, const Pair& _e2) {
- return _e1.first < _e2.first;
-}
-
-
-void esvg::render::Weight::generate(Vector2i _size, int _subSamplingCount, const esvg::render::SegmentList& _listSegment) {
- resize(_size);
- // for each lines:
- for (int yyy=0; yyy<_size.y(); ++yyy) {
- Log.verbose("Weighting ... " << yyy << " / " << _size.y());
- // Reduce the number of lines in the subsampling parsing:
- List availlableSegmentPixel;
- for (auto &it : _listSegment.this.data) {
- if ( it.p0.y() < float(yyy+1)
- && it.p1.y() > float(yyy)) {
- availlableSegmentPixel.pushBack(it);
- }
- }
- if (availlableSegmentPixel.size() == 0) {
- continue;
- }
- Log.verbose(" Find Basic segments " << availlableSegmentPixel.size());
- // This represent the pondaration on the subSampling
- float deltaSize = 1.0f/_subSamplingCount;
- for (int kkk=0; kkk<_subSamplingCount ; ++kkk) {
- Log.verbose(" Scanline ... " << kkk << " / " << _subSamplingCount);
- Scanline scanline(_size.x());
- //find all the segment that cross the middle of the line of the center of the pixel line:
- float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk;
- List availlableSegment;
- // find in the subList ...
- for (auto &it : availlableSegmentPixel) {
- if ( it.p0.y() <= subSamplingCenterPos
- && it.p1.y() > subSamplingCenterPos) {
- // check if we not get 2 identical lines:
- if ( availlableSegment.size() > 0
- && availlableSegment.back().p1 == it.p0
- && availlableSegment.back().direction == it.direction) {
- // we not add this point in this case to prevent double count of the same point.
- } else {
- availlableSegment.pushBack(it);
- }
- }
- }
- Log.verbose(" Availlable Segment " << availlableSegment.size());
- if (availlableSegment.size() == 0) {
- continue;
- }
- for (auto &it : availlableSegment) {
- Log.verbose(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction);
- }
- // x position, angle
- List> listPosition;
- for (auto &it : availlableSegment) {
- Vector2f delta = it.p0 - it.p1;
- // x = coefficent*y+bbb;
- float coefficient = delta.x()/delta.y();
- float bbb = it.p0.x() - coefficient*it.p0.y();
- float xpos = coefficient * subSamplingCenterPos + bbb;
- listPosition.pushBack(Pair(xpos, it.direction));
- }
- Log.verbose(" List position " << listPosition.size());
- // now we order position of the xPosition:
- etk::algorithm::quickSort(listPosition, sortXPosFunction);
- // move through all element in the point:
- int lastState = 0;
- float currentValue = 0.0f;
- int lastPos = -1;
- int currentPos = -1;
- float lastX = 0.0f;
- // * | \---------------/ |
- // * current pos
- // * pos ...
- // TODO : Code the Odd/even and non-zero ...
- for (auto &it : listPosition) {
- if (currentPos != int(it.first)) {
- // fill to the new pos -1:
- #if __CPP_VERSION__ >= 2011 && !defined(__TARGET_OS__MacOs) && !defined(__TARGET_OS__IOs)
- float endValue = float(etk::min(1,etk::abs(lastState))) * deltaSize;
- #else
- float endValue = float(etk::min(1,abs(lastState))) * deltaSize;
- #endif
- for (int iii=currentPos+1; iii fill if to the end with full value ... 2.0
- if (lastState != 0) {
- // just past the last state to the end of the image ...
- Log.error("end of Path whith no end ... " << currentPos << " -> " << _size.x());
- for (int xxx=currentPos; xxx<_size.x(); ++xxx) {
- scanline.set(xxx, 100.0);
- }
- }
- append(yyy, scanline);
- }
- }
-}
diff --git a/src/org/atriasoft/esvg/render/Weight.java b/src/org/atriasoft/esvg/render/Weight.java
index b5999bf..d56ec35 100644
--- a/src/org/atriasoft/esvg/render/Weight.java
+++ b/src/org/atriasoft/esvg/render/Weight.java
@@ -1,47 +1,183 @@
package org.atriasoft.esvg.render;
-/** @file
- * @author Edouard DUPIN
- * @copyright 2011, Edouard DUPIN, all right reserved
- * @license MPL v2.0 (see license file)
- */
-#pragma once
-#include#include#include#include
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
-namespace esvg{namespace render{
-class Weight {
- private:
- Vector2i this.size;
- List this.data;
- public:
- // constructor :
- Weight();
+import org.atriasoft.esvg.internal.Log;
+import org.atriasoft.etk.math.FMath;
+import org.atriasoft.etk.math.Vector2f;
+import org.atriasoft.etk.math.Vector2i;
+import org.atriasoft.etk.util.Pair;
+
+public class Weight {
+ private float[][] data = null;
+ private Vector2i size;
- Weight(const Vector2i& _size);
- // destructor
- ~Weight();
- // -----------------------------------------------
- // -- basic tools :
- // -----------------------------------------------
- public:
+ // constructor :
+ public Weight() {
+ this.size = Vector2i.ZERO;
+ }
- void resize(const Vector2i& _size);
- const Vector2i& getSize() const;
+ public Weight(final Vector2i size) {
+ this.size = size;
+ resize(size);
+ }
- int getWidth() const;
+ public void append(final int posY, final Scanline data) {
+ if (posY >= 0 && posY < this.size.y()) {
+ for (int xxx = 0; xxx < this.size.x(); ++xxx) {
+ this.data[posY][xxx] += data.get(xxx);
+ }
+ }
+ }
- int getHeight() const;
+ public void clear(final float fill) {
+ Arrays.fill(this.data, fill);
+ }
- void clear(float _fill);
+ public void generate(final Vector2i size, final int subSamplingCount, final SegmentList listSegment) {
+ resize(size);
+ // for each lines:
+ for (int yyy = 0; yyy < size.y(); ++yyy) {
+ Log.verbose("Weighting ... " + yyy + " / " + size.y());
+ // Reduce the number of lines in the subsampling parsing:
+ List availlableSegmentPixel = new ArrayList();
+ for (Segment it : listSegment.data) {
+ if (it.p0.y() < yyy + 1 && it.p1.y() > (yyy)) {
+ availlableSegmentPixel.add(it);
+ }
+ }
+ if (availlableSegmentPixel.size() == 0) {
+ continue;
+ }
+ Log.verbose(" Find Basic segments " + availlableSegmentPixel.size());
+ // This represent the pondaration on the subSampling
+ float deltaSize = 1.0f / subSamplingCount;
+ for (int kkk = 0; kkk < subSamplingCount; ++kkk) {
+ Log.verbose(" Scanline ... " + kkk + " / " + subSamplingCount);
+ Scanline scanline = new Scanline(size.x());
+ //find all the segment that cross the middle of the line of the center of the pixel line:
+ float subSamplingCenterPos = yyy + deltaSize * 0.5f + deltaSize * kkk;
+ List availlableSegment = new ArrayList<>();
+ // find in the subList ...
+ for (Segment it : availlableSegmentPixel) {
+ if (it.p0.y() <= subSamplingCenterPos && it.p1.y() > subSamplingCenterPos) {
+ // check if we not get 2 identical lines:
+ if (availlableSegment.size() > 0 && availlableSegment.get(availlableSegment.size() - 1).p1 == it.p0
+ && availlableSegment.get(availlableSegment.size() - 1).direction == it.direction) {
+ // we not add this point in this case to prevent double count of the same point.
+ } else {
+ availlableSegment.add(it);
+ }
+ }
+ }
+ Log.verbose(" Availlable Segment " + availlableSegment.size());
+ if (availlableSegment.size() == 0) {
+ continue;
+ }
+ for (Segment it : availlableSegment) {
+ Log.verbose(" Availlable Segment " + it.p0 + " . " + it.p1 + " dir=" + it.direction);
+ }
+ // x position, angle
+ List> listPosition = new ArrayList<>();
+ for (Segment it : availlableSegment) {
+ Vector2f delta = it.p0.less(it.p1);
+ // x = coefficent*y+bbb;
+ float coefficient = delta.x() / delta.y();
+ float bbb = it.p0.x() - coefficient * it.p0.y();
+ float xpos = coefficient * subSamplingCenterPos + bbb;
+ listPosition.add(new Pair(xpos, it.direction));
+ }
+ Log.verbose(" List position " + listPosition.size());
+ // now we order position of the xPosition:
+ Collections.sort(listPosition, (e1, e2) -> ((int) (e2.first - e1.first)));
+
+ // move through all element in the point:
+ int lastState = 0;
+ float currentValue = 0.0f;
+ int currentPos = -1;
+ // * | \---------------/ |
+ // * current pos
+ // * pos ...
+ // TODO Code the Odd/even and non-zero ...
+ for (Pair it : listPosition) {
+ if (currentPos != it.first.intValue()) {
+ // fill to the new pos -1:
+ float endValue = FMath.min(1.0f, FMath.abs(lastState)) * deltaSize;
+ for (int iii = currentPos + 1; iii < it.first.intValue(); ++iii) {
+ scanline.set(iii, endValue);
+ }
+ currentPos = it.first.intValue();
+ currentValue = endValue;
+ }
+ int oldState = lastState;
+ lastState += it.second;
+ if (oldState == 0) {
+ // nothing to draw before ...
+ float ratio = 1.0f - (it.first - it.first.intValue());
+ currentValue += ratio * deltaSize;
+ } else if (lastState == 0) {
+ // something new to draw ...
+ float ratio = 1.0f - (it.first - it.first.intValue());
+ currentValue -= ratio * deltaSize;
+ } else {
+ // nothing to do ...
+ }
+
+ if (currentPos == it.first.intValue()) {
+ scanline.set(currentPos, currentValue);
+ }
+ }
+ // if the counter is not at 0 ==> fill if to the end with full value ... 2.0
+ if (lastState != 0) {
+ // just past the last state to the end of the image ...
+ Log.error("end of Path whith no end ... " + currentPos + " . " + size.x());
+ for (int xxx = currentPos; xxx < size.x(); ++xxx) {
+ scanline.set(xxx, 100.0f);
+ }
+ }
+ append(yyy, scanline);
+ }
+ }
+ }
- float get(const Vector2i& _pos) const;
+ public float get(final Vector2i pos) {
+ return this.data[pos.y()][pos.x()];
+ }
- void set(const Vector2i& _pos, float _newColor);
+ public int getHeight() {
+ return this.size.y();
+ }
- void set(final int _posY, const esvg::render::Scanline& _data);
+ public Vector2i getSize() {
+ return this.size;
+ }
- void append(final int _posY, const esvg::render::Scanline& _data);
+ public int getWidth() {
+ return this.size.x();
+ }
- void generate(final Vector2i _size, final int _subSamplingCount, const esvg::render::SegmentList& _listSegment);
- };
-}}
+ // -----------------------------------------------
+ // -- basic tools :
+ // -----------------------------------------------
+ public void resize(final Vector2i size) {
+ this.size = size;
+ this.data = new float[this.size.y()][this.size.x()];
+ clear(0);
+ }
+
+ public void set(final int posY, final Scanline data) {
+ if (posY >= 0 && posY < this.size.y()) {
+ for (int xxx = 0; xxx < this.size.x(); ++xxx) {
+ this.data[posY][xxx] = data.get(xxx);
+ }
+ }
+ }
+
+ public void set(final Vector2i pos, final float newColor) {
+ this.data[pos.y()][pos.x()] = newColor;
+ }
+
+}
diff --git a/src/org/atriasoft/esvg/spreadMethod.cpp b/src/org/atriasoft/esvg/spreadMethod.cpp
deleted file mode 100644
index bd97c1a..0000000
--- a/src/org/atriasoft/esvg/spreadMethod.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/** @file
- * @author Edouard DUPIN
- * @copyright 2011, Edouard DUPIN, all right reserved
- * @license MPL v2.0 (see license file)
- */
-
-#include
-#include
-
-static const char* values[] = {
- "pad",
- "reflect",
- "repeat"
-};
-
-etk::Stream& esvg::operator <<(etk::Stream& _os, enum esvg::spreadMethod _obj) {
- _os << values[_obj];
- return _os;
-}
-
diff --git a/test/src/test/atriasoft/esvg/ConfigTest.java b/test/src/test/atriasoft/esvg/ConfigTest.java
new file mode 100644
index 0000000..6d5cc27
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/ConfigTest.java
@@ -0,0 +1,7 @@
+package test.atriasoft.esvg;
+
+public class ConfigTest {
+ public static final boolean VISUAL_DEBUG = false;
+
+ private ConfigTest() {}
+}
diff --git a/test/src/test/atriasoft/esvg/TestCap.java b/test/src/test/atriasoft/esvg/TestCap.java
new file mode 100644
index 0000000..ad05491
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestCap.java
@@ -0,0 +1,139 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestCap {
+ @Test
+ public void testTestCapButt() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapbutt.svg"), data);
+ doc.generateAnImage(new Uri("TestCapbutt.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapButtDiag1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapbuttDiag1.svg"), data);
+ doc.generateAnImage(new Uri("TestCapbuttDiag1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapButtDiag2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapbuttDiag2.svg"), data);
+ doc.generateAnImage(new Uri("TestCapbuttDiag2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapButtVert() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapbuttVert.svg"), data);
+ doc.generateAnImage(new Uri("TestCapbuttVert.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapRound() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapround.svg"), data);
+ doc.generateAnImage(new Uri("TestCapround.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapRoundDiag1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCaproundDiag1.svg"), data);
+ doc.generateAnImage(new Uri("TestCaproundDiag1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapRoundDiag2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCaproundDiag2.svg"), data);
+ doc.generateAnImage(new Uri("TestCaproundDiag2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapRoundVert() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCaproundVert.svg"), data);
+ doc.generateAnImage(new Uri("TestCaproundVert.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapSquare() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapsquare.svg"), data);
+ doc.generateAnImage(new Uri("TestCapsquare.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapSquareDiag1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapsquareDiag1.svg"), data);
+ doc.generateAnImage(new Uri("TestCapsquareDiag1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapSquareDiag2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapsquareDiag2.svg"), data);
+ doc.generateAnImage(new Uri("TestCapsquareDiag2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCapSquareVert() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCapsquareVert.svg"), data);
+ doc.generateAnImage(new Uri("TestCapsquareVert.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
diff --git a/test/src/test/atriasoft/esvg/TestCircle.java b/test/src/test/atriasoft/esvg/TestCircle.java
new file mode 100644
index 0000000..47e2285
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestCircle.java
@@ -0,0 +1,36 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestCircle {
+
+ @Test
+ public void testTestCircleFill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCirclefill.svg"), data);
+ doc.generateAnImage(new Uri("TestCirclefill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCircleFillandstroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCirclefillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestCirclefillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestCircleStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestCirclestroke.svg"), data);
+ doc.generateAnImage(new Uri("TestCirclestroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestColor.java b/test/src/test/atriasoft/esvg/TestColor.java
new file mode 100644
index 0000000..4b7e567
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestColor.java
@@ -0,0 +1,49 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestColor {
+ @Test
+ public void testTestColorBlending() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestColorblending.svg"), data);
+ doc.generateAnImage(new Uri("TestColorblending.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestColorBlendingandopacity() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestColorblendingandopacity.svg"), data);
+ doc.generateAnImage(new Uri("TestColorblendingandopacity.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestColorMultiplelayer() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestColormultiplelayer.svg"), data);
+ doc.generateAnImage(new Uri("TestColormultiplelayer.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestColorOpacity() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestColoropacity.svg"), data);
+ doc.generateAnImage(new Uri("TestColoropacity.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestEllipse.java b/test/src/test/atriasoft/esvg/TestEllipse.java
new file mode 100644
index 0000000..15b0432
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestEllipse.java
@@ -0,0 +1,37 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestEllipse {
+
+ @Test
+ public void testTestEllipseFill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestEllipsefill.svg"), data);
+ doc.generateAnImage(new Uri("TestEllipsefill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestEllipseFillAndStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestEllipsefillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestEllipsefillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestEllipseStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestEllipsestroke.svg"), data);
+ doc.generateAnImage(new Uri("TestEllipsestroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestGradientLinear.java b/test/src/test/atriasoft/esvg/TestGradientLinear.java
new file mode 100644
index 0000000..20e72fd
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestGradientLinear.java
@@ -0,0 +1,232 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestGradientLinear {
+ @Test
+ public void testTestGradientLinearDiag1() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag1.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag1Partiel() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag1Partiel.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag1Partiel.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag2() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag2.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag2Rotate0() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag2Rotate0.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag2Rotate0.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag2Rotate1() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag2Rotate1.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag2Rotate1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag2Rotate2() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag2Rotate2.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag2Rotate2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearDiag2scale() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLineardiag2scale.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLineardiag2scale.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearHorizontal() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearhorizontal.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearhorizontal.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearInternalHref() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearinternalHref.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearinternalHref.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitBoxspreadNone() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitBoxspreadNone.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitBoxspreadNone.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitBoxspreadPad() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitBoxspreadPad.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitBoxspreadPad.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitBoxspreadReflect() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitBoxspreadReflect.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitBoxspreadReflect.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitBoxspreadRepeat() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitBoxspreadRepeat.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitBoxspreadRepeat.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitUserspreadNone() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitUserspreadNone.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitUserspreadNone.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitUserspreadPad() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitUserspreadPad.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitUserspreadPad.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitUserspreadReflect() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitUserspreadReflect.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitUserspreadReflect.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearUnitUserspreadRepeate() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearunitUserspreadRepeate.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearunitUserspreadRepeate.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientLinearVertical() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientLinearvertical.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientLinearvertical.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
diff --git a/test/src/test/atriasoft/esvg/TestGradientRadial.java b/test/src/test/atriasoft/esvg/TestGradientRadial.java
new file mode 100644
index 0000000..61c1a5c
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestGradientRadial.java
@@ -0,0 +1,216 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestGradientRadial {
+ @Test
+ public void testTestGradientRadialCircle() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialcircle.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialcircle.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialFull() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialfull.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialfull.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialPartial() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialpartial.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialpartial.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitBoxspreadNone() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitBoxspreadNone.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitBoxspreadNone.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitBoxspreadPad() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitBoxspreadPad.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitBoxspreadPad.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitBoxspreadReflect() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitBoxspreadReflect.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitBoxspreadReflect.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitBoxspreadRepeat() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitBoxspreadRepeat.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitBoxspreadRepeat.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadNone() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadNone.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadNone.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadPad() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadPad.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadPad.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadPadunCenter() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadPadunCenter.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadPadunCenter.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadReflect() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadReflect.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadReflect.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadReflectunCenter() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadReflectunCenter.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadReflectunCenter.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadRepeat() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadRepeat.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadRepeat.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadRepeatout() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadRepeatout.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadRepeatout.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadRepeatunCenter() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadRepeatunCenter.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadRepeatunCenter.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestGradientRadialUnitUserspreadRepeatunCenter2() {
+ String data = "\n" + "\n";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestGradientRadialunitUserspreadRepeatunCenter2.svg"), data);
+ doc.generateAnImage(new Uri("TestGradientRadialunitUserspreadRepeatunCenter2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestJoin.java b/test/src/test/atriasoft/esvg/TestJoin.java
new file mode 100644
index 0000000..4c451fb
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestJoin.java
@@ -0,0 +1,335 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestJoin {
+ @Test
+ public void testTestJoinBevelCornerCasePath() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelCornerCasePath.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelCornerCasePath.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelLeft1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelLeft1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelLeft1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelLeft2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelLeft2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelLeft2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelLeft3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelLeft3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelLeft3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelLeft4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelLeft4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelLeft4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelRight1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelRight1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelRight1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelRight2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelRight2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelRight2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelRight3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelRight3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelRight3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinBevelRight4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinbevelRight4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinbevelRight4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterCornerCasePath() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterCornerCasePath.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterCornerCasePath.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterCornerCasePathLimit() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterCornerCasePathLimit.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterCornerCasePathLimit.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLeft1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLeft1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLeft1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLeft2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLeft2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLeft2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLeft3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLeft3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLeft3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ // ------------------------------------------------------ Round test -----------------------------------------------------
+
+ @Test
+ public void testTestJoinMiterLeft4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLeft4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLeft4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLimit1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLimit1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLimit1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLimit2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLimit2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLimit2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLimit3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLimit3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLimit3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterLimit4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterLimit4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterLimit4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterRight1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterRight1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterRight1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterRight2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterRight2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterRight2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterRight3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterRight3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterRight3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinMiterRight4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinmiterRight4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinmiterRight4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ // ------------------------------------------------------ Bevel test -----------------------------------------------------
+
+ @Test
+ public void testTestJoinRoundCornerCasePath() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundCornerCasePath.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundCornerCasePath.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundLeft1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundLeft1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundLeft1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundLeft2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundLeft2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundLeft2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundLeft3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundLeft3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundLeft3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundLeft4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundLeft4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundLeft4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundRight1() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundRight1.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundRight1.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundRight2() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundRight2.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundRight2.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundRight3() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundRight3.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundRight3.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestJoinRoundRight4() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestJoinroundRight4.svg"), data);
+ doc.generateAnImage(new Uri("TestJoinroundRight4.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
diff --git a/test/src/test/atriasoft/esvg/TestLine.java b/test/src/test/atriasoft/esvg/TestLine.java
new file mode 100644
index 0000000..c2eb618
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestLine.java
@@ -0,0 +1,17 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestLine {
+ @Test
+ public void testTestLineStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestLinestroke.svg"), data);
+ doc.generateAnImage(new Uri("TestLinestroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
diff --git a/test/src/test/atriasoft/esvg/TestPath.java b/test/src/test/atriasoft/esvg/TestPath.java
new file mode 100644
index 0000000..cd5502b
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestPath.java
@@ -0,0 +1,100 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestPath {
+ @Test
+ public void testTestPathArc() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPatharc.svg"), data);
+ doc.generateAnImage(new Uri("TestPatharc.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathBezierCurveTo() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathbezierCurveTo.svg"), data);
+ doc.generateAnImage(new Uri("TestPathbezierCurveTo.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathBezierSmoothCurveTo() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathbezierSmoothCurveTo.svg"), data);
+ doc.generateAnImage(new Uri("TestPathbezierSmoothCurveTo.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathCurveTo() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathcurveTo.svg"), data);
+ doc.generateAnImage(new Uri("TestPathcurveTo.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathEndpathbordercase() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathendpathbordercase.svg"), data);
+ doc.generateAnImage(new Uri("TestPathendpathbordercase.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathfill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathfill.svg"), data);
+ doc.generateAnImage(new Uri("TestPathfill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathFillandstroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathfillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPathfillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathSmoothCurveTo() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathsmoothCurveTo.svg"), data);
+ doc.generateAnImage(new Uri("TestPathsmoothCurveTo.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPathStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPathstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPathstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestPolygon.java b/test/src/test/atriasoft/esvg/TestPolygon.java
new file mode 100644
index 0000000..6da177e
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestPolygon.java
@@ -0,0 +1,36 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestPolygon {
+ @Test
+ public void testTestPolygonFill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolygonfill.svg"), data);
+ doc.generateAnImage(new Uri("TestPolygonfill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPolygonFillAndStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolygonfillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPolygonfillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPolygonStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolygonstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPolygonstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestPolyline.java b/test/src/test/atriasoft/esvg/TestPolyline.java
new file mode 100644
index 0000000..9683538
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestPolyline.java
@@ -0,0 +1,37 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestPolyline {
+ @Test
+ public void testTestPolyLineFill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolyLinefill.svg"), data);
+ doc.generateAnImage(new Uri("TestPolyLinefill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPolyLineFillAndStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolyLinefillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPolyLinefillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestPolyLineStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestPolyLinestroke.svg"), data);
+ doc.generateAnImage(new Uri("TestPolyLinestroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestRectangle.java b/test/src/test/atriasoft/esvg/TestRectangle.java
new file mode 100644
index 0000000..15feb10
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestRectangle.java
@@ -0,0 +1,66 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestRectangle {
+ @Test
+ public void testTestRectangleCornedfill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglecornedfill.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglecornedfill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestRectangleCornedfillandstroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglecornedfillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglecornedfillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestRectangleCornedstroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglecornedstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglecornedstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestRectangleFill() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglefill.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglefill.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestRectangleFillandstroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglefillandstroke.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglefillandstroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+
+ @Test
+ public void testTestRectangleStroke() {
+ String data = "" + "";
+ EsvgDocument doc = new EsvgDocument();
+ doc.parse(data);
+ Uri.writeAll(new Uri("TestRectanglestroke.svg"), data);
+ doc.generateAnImage(new Uri("TestRectanglestroke.bmp"), ConfigTest.VISUAL_DEBUG);
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/atriasoft/esvg/TestStyle.java b/test/src/test/atriasoft/esvg/TestStyle.java
new file mode 100644
index 0000000..9418334
--- /dev/null
+++ b/test/src/test/atriasoft/esvg/TestStyle.java
@@ -0,0 +1,123 @@
+package test.atriasoft.esvg;
+
+import org.atriasoft.esvg.EsvgDocument;
+import org.atriasoft.etk.Uri;
+import org.junit.jupiter.api.Test;
+
+class TestStyle {
+ @Test
+ public void testTestExternWorddown() {
+ String data = "\n" + "\n"
-"\n"
-"\n");
- esvg::Document doc;
- doc.parse(data);
- etk::uri::writeAll(etk::Path("TestExtern_worddown.svg"), data);
- doc.generateAnImage(etk::Path("TestExtern_worddown.bmp"), g_visualDebug);
-}
-
-