[DEV] commit all with new insland
This commit is contained in:
parent
5b4ec4ded3
commit
a69546fa61
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.atriasoft.esvg.internal.Log;
|
import org.atriasoft.esvg.internal.Log;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
import org.atriasoft.etk.Dimension;
|
import org.atriasoft.etk.Dimension2f;
|
||||||
import org.atriasoft.etk.Distance;
|
import org.atriasoft.etk.Distance;
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
import org.atriasoft.etk.math.Matrix2x3f;
|
import org.atriasoft.etk.math.Matrix2x3f;
|
||||||
@ -24,8 +24,8 @@ import org.atriasoft.exml.model.XmlNode;
|
|||||||
public class LinearGradient extends Base {
|
public class LinearGradient extends Base {
|
||||||
private final List<Pair<Float, Color>> data = new ArrayList<>(); //!< gradient position x1 y1
|
private final List<Pair<Float, Color>> data = new ArrayList<>(); //!< gradient position x1 y1
|
||||||
private String href = ""; //!< gradient position x2 y2
|
private String href = ""; //!< gradient position x2 y2
|
||||||
private Dimension pos1 = new Dimension(new Vector2f(50, 50), Distance.POURCENT);
|
private Dimension2f pos1 = new Dimension2f(new Vector2f(50, 50), Distance.POURCENT);
|
||||||
private Dimension pos2 = new Dimension(new Vector2f(50, 50), Distance.POURCENT);
|
private Dimension2f pos2 = new Dimension2f(new Vector2f(50, 50), Distance.POURCENT);
|
||||||
|
|
||||||
public SpreadMethod spread = SpreadMethod.PAD; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
public SpreadMethod spread = SpreadMethod.PAD; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||||
|
|
||||||
@ -71,11 +71,11 @@ public class LinearGradient extends Base {
|
|||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getPosition1() {
|
public Dimension2f getPosition1() {
|
||||||
return this.pos1;
|
return this.pos1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getPosition2() {
|
public Dimension2f getPosition2() {
|
||||||
return this.pos2;
|
return this.pos2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,12 +100,12 @@ public class LinearGradient extends Base {
|
|||||||
String contentX = element.getAttribute("x1", "");
|
String contentX = element.getAttribute("x1", "");
|
||||||
String contentY = element.getAttribute("y1", "");
|
String contentY = element.getAttribute("y1", "");
|
||||||
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
||||||
this.pos1 = Dimension.valueOf(contentX, contentY);
|
this.pos1 = Dimension2f.valueOf(contentX, contentY);
|
||||||
}
|
}
|
||||||
contentX = element.getAttribute("x2", "");
|
contentX = element.getAttribute("x2", "");
|
||||||
contentY = element.getAttribute("y2", "");
|
contentY = element.getAttribute("y2", "");
|
||||||
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
||||||
this.pos2 = Dimension.valueOf(contentX, contentY);
|
this.pos2 = Dimension2f.valueOf(contentX, contentY);
|
||||||
}
|
}
|
||||||
contentX = element.getAttribute("gradientUnits", "");
|
contentX = element.getAttribute("gradientUnits", "");
|
||||||
if (contentX.equals("userSpaceOnUse")) {
|
if (contentX.equals("userSpaceOnUse")) {
|
||||||
@ -162,7 +162,7 @@ public class LinearGradient extends Base {
|
|||||||
stopColor = stopColor.withA(opacity);
|
stopColor = stopColor.withA(opacity);
|
||||||
Log.verbose(" opacity : '" + content + "' == > " + stopColor);
|
Log.verbose(" opacity : '" + content + "' == > " + stopColor);
|
||||||
}
|
}
|
||||||
this.data.add(new Pair<Float, Color>(offset, stopColor));
|
this.data.add(new Pair<>(offset, stopColor));
|
||||||
} else {
|
} else {
|
||||||
Log.error(" node not suported : '" + child.getValue() + "' must be [stop]");
|
Log.error(" node not suported : '" + child.getValue() + "' must be [stop]");
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.atriasoft.esvg.internal.Log;
|
import org.atriasoft.esvg.internal.Log;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
import org.atriasoft.etk.util.Dynamic;
|
import org.atriasoft.etk.Dimension1f;
|
||||||
import org.atriasoft.etk.util.Pair;
|
import org.atriasoft.etk.Dimension2f;
|
||||||
import org.atriasoft.exml.model.XmlElement;
|
|
||||||
import org.atriasoft.exml.model.XmlNode;
|
|
||||||
import org.atriasoft.etk.Dimension;
|
|
||||||
import org.atriasoft.etk.Dimension1D;
|
|
||||||
import org.atriasoft.etk.Distance;
|
import org.atriasoft.etk.Distance;
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
import org.atriasoft.etk.math.Matrix2x3f;
|
import org.atriasoft.etk.math.Matrix2x3f;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
|
import org.atriasoft.etk.util.Dynamic;
|
||||||
|
import org.atriasoft.etk.util.Pair;
|
||||||
|
import org.atriasoft.exml.model.XmlElement;
|
||||||
|
import org.atriasoft.exml.model.XmlNode;
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
* @author Edouard DUPIN
|
* @author Edouard DUPIN
|
||||||
@ -22,11 +22,11 @@ import org.atriasoft.etk.math.Vector2f;
|
|||||||
* @license MPL v2.0 (see license file)
|
* @license MPL v2.0 (see license file)
|
||||||
*/
|
*/
|
||||||
public class RadialGradient extends Base {
|
public class RadialGradient extends Base {
|
||||||
private Dimension center = new Dimension(new Vector2f(50, 50), Distance.POURCENT); //!< gradient position cx cy
|
private Dimension2f center = new Dimension2f(new Vector2f(50, 50), Distance.POURCENT); //!< gradient position cx cy
|
||||||
private final List<Pair<Float, Color>> data = new ArrayList<>(); //!< incompatible with href
|
private final List<Pair<Float, Color>> data = new ArrayList<>(); //!< incompatible with href
|
||||||
private Dimension focal = new Dimension(new Vector2f(50, 50), Distance.POURCENT); //!< gradient Focal fx fy
|
private Dimension2f focal = new Dimension2f(new Vector2f(50, 50), Distance.POURCENT); //!< gradient Focal fx fy
|
||||||
private String href = ""; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
private String href = ""; //!< in case of using a single gradient in multiple gradient, the gradient is store in an other element...
|
||||||
private Dimension1D radius = new Dimension1D(50, Distance.POURCENT); //!< Radius of the gradient
|
private Dimension1f radius = new Dimension1f(50, Distance.POURCENT); //!< Radius of the gradient
|
||||||
public SpreadMethod spread = SpreadMethod.PAD;
|
public SpreadMethod spread = SpreadMethod.PAD;
|
||||||
public GradientUnits unit = GradientUnits.GRADIENT_UNITS_OBJECT_BOUNDING_BOX;
|
public GradientUnits unit = GradientUnits.GRADIENT_UNITS_OBJECT_BOUNDING_BOX;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ public class RadialGradient extends Base {
|
|||||||
Log.verbose(spacingDist(level) + "DRAW esvg::RadialGradient");
|
Log.verbose(spacingDist(level) + "DRAW esvg::RadialGradient");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getCenter() {
|
public Dimension2f getCenter() {
|
||||||
return this.center;
|
return this.center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,11 +73,11 @@ public class RadialGradient extends Base {
|
|||||||
return this.data;
|
return this.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension getFocal() {
|
public Dimension2f getFocal() {
|
||||||
return this.focal;
|
return this.focal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dimension1D getRadius() {
|
public Dimension1f getRadius() {
|
||||||
return this.radius;
|
return this.radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,16 +101,16 @@ public class RadialGradient extends Base {
|
|||||||
String contentX = element.getAttribute("cx", "");
|
String contentX = element.getAttribute("cx", "");
|
||||||
String contentY = element.getAttribute("cy", "");
|
String contentY = element.getAttribute("cy", "");
|
||||||
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
||||||
this.center = Dimension.valueOf(contentX, contentY);
|
this.center = Dimension2f.valueOf(contentX, contentY);
|
||||||
}
|
}
|
||||||
contentX = element.getAttribute("r", "");
|
contentX = element.getAttribute("r", "");
|
||||||
if (contentX != "") {
|
if (contentX != "") {
|
||||||
this.radius = Dimension1D.valueOf(contentX);
|
this.radius = Dimension1f.valueOf(contentX);
|
||||||
}
|
}
|
||||||
contentX = element.getAttribute("fx", "");
|
contentX = element.getAttribute("fx", "");
|
||||||
contentY = element.getAttribute("fy", "");
|
contentY = element.getAttribute("fy", "");
|
||||||
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
if (!contentX.isEmpty() && !contentY.isEmpty()) {
|
||||||
this.focal = Dimension.valueOf(contentX, contentY);
|
this.focal = Dimension2f.valueOf(contentX, contentY);
|
||||||
}
|
}
|
||||||
contentX = element.getAttribute("gradientUnits", "");
|
contentX = element.getAttribute("gradientUnits", "");
|
||||||
if (contentX.equals("userSpaceOnUse")) {
|
if (contentX.equals("userSpaceOnUse")) {
|
||||||
@ -167,7 +167,7 @@ public class RadialGradient extends Base {
|
|||||||
stopColor = stopColor.withA(opacity);
|
stopColor = stopColor.withA(opacity);
|
||||||
Log.verbose(" opacity : '" + content + "' == > " + stopColor);
|
Log.verbose(" opacity : '" + content + "' == > " + stopColor);
|
||||||
}
|
}
|
||||||
this.data.add(new Pair<Float, Color>(offset, stopColor));
|
this.data.add(new Pair<>(offset, stopColor));
|
||||||
} else {
|
} else {
|
||||||
Log.error("node not suported : '" + child.getValue() + "' must be [stop]");
|
Log.error("node not suported : '" + child.getValue() + "' must be [stop]");
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,21 @@ package org.atriasoft.esvg.render;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.atriasoft.esvg.SpreadMethod;
|
|
||||||
import org.atriasoft.esvg.Base;
|
import org.atriasoft.esvg.Base;
|
||||||
import org.atriasoft.esvg.EsvgDocument;
|
import org.atriasoft.esvg.EsvgDocument;
|
||||||
import org.atriasoft.esvg.GradientUnits;
|
import org.atriasoft.esvg.GradientUnits;
|
||||||
import org.atriasoft.esvg.LinearGradient;
|
import org.atriasoft.esvg.LinearGradient;
|
||||||
import org.atriasoft.esvg.RadialGradient;
|
import org.atriasoft.esvg.RadialGradient;
|
||||||
|
import org.atriasoft.esvg.SpreadMethod;
|
||||||
import org.atriasoft.esvg.internal.Log;
|
import org.atriasoft.esvg.internal.Log;
|
||||||
import org.atriasoft.etk.Color;
|
import org.atriasoft.etk.Color;
|
||||||
import org.atriasoft.etk.Dimension;
|
import org.atriasoft.etk.Dimension1f;
|
||||||
import org.atriasoft.etk.Dimension1D;
|
import org.atriasoft.etk.Dimension2f;
|
||||||
import org.atriasoft.etk.Distance;
|
import org.atriasoft.etk.Distance;
|
||||||
import org.atriasoft.etk.math.FMath;
|
import org.atriasoft.etk.math.FMath;
|
||||||
|
import org.atriasoft.etk.math.Matrix2x3f;
|
||||||
import org.atriasoft.etk.math.Vector2f;
|
import org.atriasoft.etk.math.Vector2f;
|
||||||
import org.atriasoft.etk.math.Vector2i;
|
import org.atriasoft.etk.math.Vector2i;
|
||||||
import org.atriasoft.etk.math.Matrix2x3f;
|
|
||||||
import org.atriasoft.etk.util.Pair;
|
import org.atriasoft.etk.util.Pair;
|
||||||
|
|
||||||
public class DynamicColorSpecial implements DynamicColor {
|
public class DynamicColorSpecial implements DynamicColor {
|
||||||
@ -119,12 +119,12 @@ public class DynamicColorSpecial implements DynamicColor {
|
|||||||
Log.verbose(" viewport = {" + this.viewPort.first + "," + this.viewPort.second + "}");
|
Log.verbose(" viewport = {" + this.viewPort.first + "," + this.viewPort.second + "}");
|
||||||
Vector2f size = this.viewPort.second.less(this.viewPort.first);
|
Vector2f size = this.viewPort.second.less(this.viewPort.first);
|
||||||
|
|
||||||
Dimension dimPos1 = gradient.getPosition1();
|
Dimension2f dimPos1 = gradient.getPosition1();
|
||||||
this.pos1 = dimPos1.getPixel(size);
|
this.pos1 = dimPos1.getPixel(size);
|
||||||
if (dimPos1.getType() == Distance.POURCENT) {
|
if (dimPos1.getType() == Distance.POURCENT) {
|
||||||
this.pos1 = this.pos1.add(this.viewPort.first);
|
this.pos1 = this.pos1.add(this.viewPort.first);
|
||||||
}
|
}
|
||||||
Dimension dimPos2 = gradient.getPosition2();
|
Dimension2f dimPos2 = gradient.getPosition2();
|
||||||
this.pos2 = dimPos2.getPixel(size);
|
this.pos2 = dimPos2.getPixel(size);
|
||||||
if (dimPos2.getType() == Distance.POURCENT) {
|
if (dimPos2.getType() == Distance.POURCENT) {
|
||||||
this.pos2 = this.pos2.add(this.viewPort.first);
|
this.pos2 = this.pos2.add(this.viewPort.first);
|
||||||
@ -165,17 +165,17 @@ public class DynamicColorSpecial implements DynamicColor {
|
|||||||
Log.verbose(" viewport = {" + this.viewPort.first + "," + this.viewPort.second + "}");
|
Log.verbose(" viewport = {" + this.viewPort.first + "," + this.viewPort.second + "}");
|
||||||
Vector2f size = this.viewPort.second.less(this.viewPort.first);
|
Vector2f size = this.viewPort.second.less(this.viewPort.first);
|
||||||
|
|
||||||
Dimension dimCenter = gradient.getCenter();
|
Dimension2f dimCenter = gradient.getCenter();
|
||||||
Vector2f center = dimCenter.getPixel(size);
|
Vector2f center = dimCenter.getPixel(size);
|
||||||
if (dimCenter.getType() == Distance.POURCENT) {
|
if (dimCenter.getType() == Distance.POURCENT) {
|
||||||
center = center.add(this.viewPort.first);
|
center = center.add(this.viewPort.first);
|
||||||
}
|
}
|
||||||
Dimension dimFocal = gradient.getFocal();
|
Dimension2f dimFocal = gradient.getFocal();
|
||||||
Vector2f focal = dimFocal.getPixel(size);
|
Vector2f focal = dimFocal.getPixel(size);
|
||||||
if (dimFocal.getType() == Distance.POURCENT) {
|
if (dimFocal.getType() == Distance.POURCENT) {
|
||||||
focal = focal.add(this.viewPort.first);
|
focal = focal.add(this.viewPort.first);
|
||||||
}
|
}
|
||||||
Dimension1D dimRadius = gradient.getRadius();
|
Dimension1f dimRadius = gradient.getRadius();
|
||||||
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object)..
|
// in the basic vertion of the gradient the color is calculated with the ration in X and Y in the bonding box associated (it is rotate with the object)..
|
||||||
if (center == focal) {
|
if (center == focal) {
|
||||||
this.centerIsFocal = true;
|
this.centerIsFocal = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user