problem with save() function // selecting a save folder
in
Programming Questions
•
4 months ago
hello.
i'm trying to save a .png in a specific location in my computer and the following code shows what i'm doing...
another question... if i run this sketch as a java applet in a website, will it run? what is the best option if want to implement something like this online? i was thinking in using processing.js, but in my original sketch i'm using libraries to create .pdf and also the controlp5 librarie... i've been told that isn't possible to use libraries in processing.js. so i'm not sure what will be the best option for me. any suggestions?
thanks guys.
i'm trying to save a .png in a specific location in my computer and the following code shows what i'm doing...
- PGraphics pg;
- void setup () {
- size(600, 600);
- pg = createGraphics(600, 600);
- }
- void draw() {
- pg.beginDraw();
- pg.fill(0, 255, 0);
- pg.rectMode(CENTER);
- pg.rect(width/2, height/2, 120, 120);
- pg.endDraw();
- image(pg,0, 0);
- }
- void keyReleased() {
- selectFolder("Select a folder to process:", "folderSelected");
- }
- void folderSelected(File selection) {
- if (selection == null) {
- println("Window was closed or the user hit cancel.");
- }
- else {
- String location = selection.getAbsolutePath();
- pg.save(location + "test.png");
- }
- }
if i change '
pg.save(location + "test.png");' for this ----> '
pg.save(/Users/myName/Desktop + "test.png");' it works perfectly...
so, is it possible to do specify a location to save my png?
so, is it possible to do specify a location to save my png?
another question... if i run this sketch as a java applet in a website, will it run? what is the best option if want to implement something like this online? i was thinking in using processing.js, but in my original sketch i'm using libraries to create .pdf and also the controlp5 librarie... i've been told that isn't possible to use libraries in processing.js. so i'm not sure what will be the best option for me. any suggestions?
thanks guys.
1