I've written a sketch (with some help) that can run on a folder full of SVG, manipulate them and then produce gif files of the manipulations. The only problem I'm having appears to lie with Geomerative. It appears to try to load the next file but doesn't display it on screen. Is there a way to unload one file in order to load another? Code is below. It requires
Geomerative and
GifAnimation
import gifAnimation.*; import geomerative.*;
RShape shp ; RShape polyshp;
int filecount = 0; //for number of files int filecounter = 0; //to read through the next file
String[] svgfile; //for array of files String directory; //directory of files
//create first gif file gifExport = new GifMaker(this, svgfile[filecounter]+"_destroyed"+".gif"); gifExport.setRepeat(0); // make it an "endless" animation gifExport.setTransparent(28, 255, 26); // greenscreen effect
//set pointer to next svg file filecounter++; } }
void draw() { // Green screen background(28, 255, 26);
// We decided the separation between the polygon points dependent of the mouseX float pointSeparation = map(constrain(frameCount+175, 175, width-175), 175, width-175, 5, 275);
// We create the polygonized version RG.setPolygonizer(RG.UNIFORMLENGTH); RG.setPolygonizerLength(pointSeparation);
polyshp = RG.polygonize(shp); RG.shape(polyshp);
// sometimes the first frame from the previous gif is displayed // so offset recording by 2 frames if (frameCount > 2) { gifExport.setDelay(1); gifExport.addFrame(); }
//after 92 frames get next file if there is one if (frameCount == 20 && filecounter < filecount) { filename = directory + '\\' + svgfile[filecounter]; println(filename);
//load new shape into screen this is the bit I cant get working shp = RG.loadShape(filename); shp = RG.centerIn(shp, g, svgborder); shp.translate(width/2, height/2);
//open up next gif file gifExport = new GifMaker(this, svgfile[filecounter]+"_destroyed"+".gif"); gifExport.setRepeat(0); // make it an "endless" animation gifExport.setTransparent(28, 255, 26); // greenscreen effect
//reset framecount frameCount=0; //move pointer to next svg file filecounter++; } else { println("Files Processed"); }
// We decided the separation between the polygon points dependent of the mouseX float pointSeparation = map(constrain(frameCount+100, 100, width-100), 100, width-100, 5, 200);
// We create the polygonized version RG.setPolygonizer(RG.UNIFORMLENGTH); RG.setPolygonizerLength(pointSeparation);
polyshp = RG.polygonize(shp); RG.shape(polyshp);
greenScreen();
}
Currently I'm having to open each file individually and then decide whtn to stop it but I'd like the script to run and then select a new file after 20 seconds or so. The files currently have random names.
I'm familiar with how to do this in bash (for file in *.svg do...) but can something similar be accomplished in Processing?
I'm trying to create a Processing sketch that can read the text from a file (preferably a .txt file) and then randomise the order of the sentences. So far I've succeeded in loading the text into an array but I've not found a way to recognise sentences instead. Can anyone advise how you'd do this?
I eventually want it to be able to recognise paragraphs and such, but baby steps ;-)
I'm trying to create a random date generator (borrowed some code from
here) that generates dates in the future but I'm encountering a few problems. With my current code (below) the random dates sometimes are in the past or have the value "00". IS there a way to get around this, perhaps with using day() seconds() etc?
I'm loading an svg (though could be an image) into processing and centering it onto the screen (600x600). As I've made my graphic small enough to fit the screen I have no problems but eventually I want to be able to load any svg of any size and have it automatically fit to the size of the screen (proportionally), probably with a bit of a border. Is there any way to do this? I've tried scale() but it doesn't seem to have an option to scale to screen size
I'm trying to accomplish something like this but in Processing
http://www.dinkypage.com/76566 I know that Processing is able to use PShape to load an SVG but are there any specific functions to modify the nodes and node handles?