how to save a drawing out to a csv file
in
Programming Questions
•
2 years ago
hi every1 im drawing a character with a drawing app that i made and was wandering how i could save my character to a csv file???im not to sure how to do this?? these are my codes and not too sure where to put it or use it...
// Color
color BG = color(32);
color Red = color(255,13,13);
color Blue = color(24,22,240);
color Green = color(51,229,52);
color Purple = color(116,41,240);
color Yellow = color(255,244,31);
color Orange = color(255,157,52);
color White = color(255);
color Grey = color(175);
color Black = color(0);
color pickedColor;
//Switching between modes
static final int NONE = 0;
static final int RECTANGLE = 1;
static final int CIRCLE = 2;
static final int TRIANGLE = 3;
//Store current mode
int myDrawMode = NONE;
//Palette Dimension
int paletteWidth = 125;
int paletteHeight = 150;
import controlP5.*;
ControlP5 controlP5;
ListBox l;
int cnt = 0;
void setup(){
size(500,500);
background(BG); // suppose to put in void draw but that screws up my paint app.....
smooth();
frameRate(30);
controlP5 = new ControlP5(this);
l = controlP5.addListBox("myList",130,20, 260,120);
l.setItemHeight(15);
l.setBarHeight(15);
l.captionLabel().toUpperCase(true);
l.captionLabel().set("Instructions");
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3; // the +/- sign
for(int i=0;i<1;i++) {
l.addItem("Press 1,2,3 to change draw modes and 4 to restart "+i,i);
}
l.setColorActive(color(0,10,255,128));
l.setColorActive(color(0,0,255,128));
}
void draw(){
renderObjects();
//Draw background of toolbar
fill(White);
rect (-1, -1, paletteWidth, paletteHeight);
//Draw color selections
stroke(0);
strokeWeight(2);
fill(Red);
ellipse (20,20, 25, 25);
fill(Blue);
ellipse (60, 20, 25, 25);
fill(Green);
ellipse (100, 20, 25, 25);
fill(Purple);
ellipse (20, 60, 25, 25);
fill(Yellow);
ellipse (60, 60, 25, 25);
fill(Orange);
ellipse (100, 60, 25, 25);
fill(Black);
ellipse (20, 100, 25, 25);
fill (White);
ellipse (60, 100, 25, 25);
fill (Grey);
ellipse (100, 100, 25, 25);
//Different Modes
if(mousePressed) {
switch(myDrawMode) {
case(RECTANGLE):
fill(pickedColor);
rect(mouseX, mouseY, 20,20);
break;
case(CIRCLE):
fill(pickedColor);
ellipse(mouseX, mouseY, 20,20);
break;
case(TRIANGLE):
fill(pickedColor);
triangle(mouseX-10, mouseY+10, mouseX, mouseY-10,mouseX+10, mouseY+10);
break;
}
}
}
void chooseColor(){
pickedColor = get(mouseX, mouseY);
}
void mousePressed()
{
if (mouseX < paletteWidth)
{
if (mouseY < paletteHeight)
{
chooseColor();
}
else
{
draw();
}
}
}
void keyPressed() {
// draw mode accordingly.
switch(key) {
case('0'): myDrawMode = NONE; break;
case('1'): myDrawMode = RECTANGLE; break;
case('2'): myDrawMode = CIRCLE; break;
case('3'): myDrawMode = TRIANGLE; break;
case('4'): background(BG); break;
}
save("Drawing_app.png");
}
// Color
color BG = color(32);
color Red = color(255,13,13);
color Blue = color(24,22,240);
color Green = color(51,229,52);
color Purple = color(116,41,240);
color Yellow = color(255,244,31);
color Orange = color(255,157,52);
color White = color(255);
color Grey = color(175);
color Black = color(0);
color pickedColor;
//Switching between modes
static final int NONE = 0;
static final int RECTANGLE = 1;
static final int CIRCLE = 2;
static final int TRIANGLE = 3;
//Store current mode
int myDrawMode = NONE;
//Palette Dimension
int paletteWidth = 125;
int paletteHeight = 150;
import controlP5.*;
ControlP5 controlP5;
ListBox l;
int cnt = 0;
void setup(){
size(500,500);
background(BG); // suppose to put in void draw but that screws up my paint app.....
smooth();
frameRate(30);
controlP5 = new ControlP5(this);
l = controlP5.addListBox("myList",130,20, 260,120);
l.setItemHeight(15);
l.setBarHeight(15);
l.captionLabel().toUpperCase(true);
l.captionLabel().set("Instructions");
l.captionLabel().style().marginTop = 3;
l.valueLabel().style().marginTop = 3; // the +/- sign
for(int i=0;i<1;i++) {
l.addItem("Press 1,2,3 to change draw modes and 4 to restart "+i,i);
}
l.setColorActive(color(0,10,255,128));
l.setColorActive(color(0,0,255,128));
}
void draw(){
renderObjects();
//Draw background of toolbar
fill(White);
rect (-1, -1, paletteWidth, paletteHeight);
//Draw color selections
stroke(0);
strokeWeight(2);
fill(Red);
ellipse (20,20, 25, 25);
fill(Blue);
ellipse (60, 20, 25, 25);
fill(Green);
ellipse (100, 20, 25, 25);
fill(Purple);
ellipse (20, 60, 25, 25);
fill(Yellow);
ellipse (60, 60, 25, 25);
fill(Orange);
ellipse (100, 60, 25, 25);
fill(Black);
ellipse (20, 100, 25, 25);
fill (White);
ellipse (60, 100, 25, 25);
fill (Grey);
ellipse (100, 100, 25, 25);
//Different Modes
if(mousePressed) {
switch(myDrawMode) {
case(RECTANGLE):
fill(pickedColor);
rect(mouseX, mouseY, 20,20);
break;
case(CIRCLE):
fill(pickedColor);
ellipse(mouseX, mouseY, 20,20);
break;
case(TRIANGLE):
fill(pickedColor);
triangle(mouseX-10, mouseY+10, mouseX, mouseY-10,mouseX+10, mouseY+10);
break;
}
}
}
void chooseColor(){
pickedColor = get(mouseX, mouseY);
}
void mousePressed()
{
if (mouseX < paletteWidth)
{
if (mouseY < paletteHeight)
{
chooseColor();
}
else
{
draw();
}
}
}
void keyPressed() {
// draw mode accordingly.
switch(key) {
case('0'): myDrawMode = NONE; break;
case('1'): myDrawMode = RECTANGLE; break;
case('2'): myDrawMode = CIRCLE; break;
case('3'): myDrawMode = TRIANGLE; break;
case('4'): background(BG); break;
}
save("Drawing_app.png");
}
1