i need my .tga file to have only a square draw with a transparent background. but once i remove the line of code that draws the background on my draw function, the tiler saver behaves in a strange way…
can you try it and see what could be a possible solution?
thanks in advance!
here is my code :
1. press 't' to export the .tga file.
2. i'm drawing the background and the rectangle on the lines 23-26
3. most part of the code is related with the class that creates the .tga file
aTileSaver tiler;
boolean savingPNG;
boolean letsSaveIt = false;
String location;
void setup() {
size(500, 500, P3D);
noStroke();
tiler=new aTileSaver(this);
location = null;
}
public void draw() {
if (tiler==null) return; // Not initialized
// call aTileSaver.pre() to prepare frame and setup camera if it exists.
tiler.pre();
background(0, 50, 0);
lights();
fill(255, 150, 0, 220);
rect(width/2, height/2, 90, 90);
// call aTileSaver.post() to update tiles if tiler is active
tiler.post();
if (letsSaveIt == true) {
tiler.init("Simple"+nf(frameCount, 3), 3);
letsSaveIt = false;
}
}
// Saves tiled imaged when 't' is pressed
public void keyPressed() {
if (key=='t') {
selectFolder("Select a folder to process:", "folderSelected");
}
}
class aTileSaver {
public boolean isTiling=false, done=true;
public boolean doSavePreview=true;
PApplet p;
float FOV=60; // initial field of view
float cameraZ, width, height;
int tileNum=10, tileNumSq; // number of tiles
int tileImgCnt, tileX, tileY;
boolean firstFrame=false, secondFrame=false;
String tileFilename, tileFileExt=".tga";
//String tileFilename, tileFileExt=".png";
PImage tileImg;
float perc, percMilestone;
boolean savingPNG = false;
// The constructor takes a PApplet reference to your sketch.
public aTileSaver(PApplet _p) {
p=_p;
}
public void gettingLocation(){
selectFolder("Select a folder to process:", "folderSelected");
}
// If init() is called without specifying number of tiles, getMaxTiles()
// will be called to estimate number of tiles according to free memory.
public void init(String _filename) {
init(_filename, getMaxTiles(p.width));
}
// Initialize using a filename to output to and number of tiles to use.
public void init(String _filename, int _num) {
tileFilename=_filename;
tileNum=_num;
tileNumSq=(tileNum*tileNum);
width=p.width;
height=p.height;
cameraZ=(height/2.0f)/p.tan(p.PI*FOV/360.0f);
p.println("aTileSaver: "+tileNumSq+" tiles and Resolution: "+(p.width*tileNum)+"x"+(p.height*tileNum));
// remove extension from filename
if (!new java.io.File(tileFilename).isAbsolute())
tileFilename=p.dataPath(tileFilename);
tileFilename=noExt(tileFilename);
p.createPath(tileFilename);
// save preview
p.g.save(location + "/myPreview.png");
// set up off-screen buffer for saving tiled images
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?
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?
i've been looking in the forum for thread related with this and i found it. but none of the responses were able to help me.
i would like to export a .svg file by using the geomerative library but the example i've found, i guess is made for an older version of processing. what should i change in this code in way to get it working on processing 2.0?
import processing.xml.*;
import processing.opengl.*;
import geomerative.*;
size(800, 600, P2D);
smooth();
// VERY IMPORTANT: Allways initialize the library before using it
I'm getting compass values from a CSV witch vary between 0 - 360.
What I want to do is to draw a a rectangle for each of the CSV entry (no problem with that) and draw some lines inside of the rectangles according the value of the angles.
For instance, if my CSV gives me the value of 45, I want my rectangle to be fill with oblique lines.
Something like this:
Can you give me some tips about it? which approach should be the best to get this result?
i hope someone can help me with this tiny piece of code.
my aim is to draw an ellipse at middle of the screen, trace a oblique line between the border of the canvas and the ellipse and then repeat the process by drawing another ellipse a bit further and tracing another oblique line...
this is my code until now.. can u tell me what am i doing wrong?
I'm making a small school project where I'm suposed to create some visual feedback to a wisthle input.
What the sketch does until now is create a few 'branches' (I think I can call them this way...) according with the volume of the whistle.
What I want to do now is turn each of these branches an independent 'object'. I want all of them to have a small float movement. I don't know if I made myself clear, sorry...
So, my questions are: What it's the best way to do it? Do I need to create an array or something?