Hello,
I have a problem with coding I want to save a picture with SVG.
This is the code:
import processing.serial.*;
String serialPort = "COM4"; // the name of the USB port
int imageType = 1; // 0=svg, 1=png, 2=both
String filePath = "data/vale.svg"; // the SVG file path
String pngPath = "data/vale.png"; // png file path
double precision = 0.1; // precision for interpolating curves (smaller = finer)
float maxdim = 60; // maximum dimension in mm (either height or width)
boolean rotated = false; // true rotates 90 degrees: (maxy-y)->x, x->y
boolean sendIt = false; // true=sends the data, false=just draws to screen
boolean useHatches = true; // to generate hatches for filling
int hatchLevels = 4; // the number of hatch levels for grayscale
float hatchSlope = -1; // negative to slant up to the right
float hatchInterval = 0.02; // multiplied by maxdim to give interval in mm
int hatchThreshold = 127; // anything below this value will be hatched
int hatchThresholdMax = 200; // max of the range when using multiple hatches
float minHatchLength = 0.1; // don't draw too short hatches
ArrayList<Point> allpoints;
ArrayList<Integer> penMoves;
boolean penDown;
int vectorPointCount, vectorPenCount;
boolean workFinished, generatePoints;
PShape svgShape;
float maxx, maxy, minx, miny;
int pixWidth, pixHeight;
boolean hatchesReady;
Serial sPort;
void setup() {
size(400, 400);
allpoints = new ArrayList<Point>();
penMoves = new ArrayList<Integer>();
penDown = false;
workFinished = false;
generatePoints = true;
hatchesReady = false;
vectorPointCount = 0;
// In SVG mode, read the data file
// This is only done once, so it is in setup()
if(imageType == 0 || imageType == 2){
readData(filePath);
vectorPointCount = allpoints.size();
vectorPenCount = penMoves.size();
if (allpoints.size()==0) {
println("There was an error in the data file");
while(true);
}
}else{
// other mode must use hatches
useHatches = true;
// and the size needs to be found
minx = 0;
miny = 0;
PImage im = loadImage(pngPath);
if(im.width > im.height){
maxx = maxdim;
maxy = (im.height*maxdim)/im.width;
}else{
maxy = maxdim;
maxx = (im.width*maxdim)/im.height;
}
}
I want to post all coding,but my coding is very long about 44244 characters, body limited is 32000.
Thank you