GLV Paint A very simple draw and save program

A very simple draw and save program that I am sharing as an example.

// https://processing.org/tutorials/
// https://processing.org/reference/

// https://processing.org/reference/saveFrame_.html
// https://processing.org/reference/PImage.html
// https://processing.org/reference/image_.html
// https://processing.org/reference/get_.html
// https://processing.org/reference/loadImage_.html

// https://processing.org/reference/width.html
// https://processing.org/reference/height.html

// https://processing.org/tutorials/interactivity/
// https://processing.org/reference/mouseX.html
// https://processing.org/reference/mouseY.html
// https://processing.org/reference/keyPressed_.html
// https://processing.org/reference/mousePressed_.html

PImage img;

void setup()
  {
  size(200, 100);
  }

void draw()
  {
  //  background(204);
  stroke(0);
  strokeWeight(1);
  line(width/2, 0, width/2, height);
  
  stroke(100, 10, 128);
  strokeWeight(8);
  if (mousePressed && mouseX < width/2 && pmouseX < width/2)
    line(mouseX, mouseY, pmouseX, pmouseY);  
  }
  
void  keyPressed()
    {
    if (key == 's')  
//      saveFrame("chromosone.png");
      img = get(0, 0, 100, 100);
      img.save("chromosone.png");
    
    if (key == 'b')
      background(204);
    
    if (key == 'p')
      {
      img = loadImage("chromosone.png");
      image(img, 100, 0);
      }
    }

chromosone

chromosone

2 Likes

You should allow ppl to provide the name to the file to save. Some ideas:

  • Create a 2nd sketch and design the input form there (hard way)
  • Use a Java widget, an input box (Easier way)

Kf

chromosone
made possible by GLV’s Photoshop++

1 Like

That made me laugh out loud!

I like the choice of colour!

:sunny:

1 Like

Updated GLV Paint

Thanks for all the support!

image

// GLV Paint
// Version 0.01
// 2019-11-30

// Changes:
// Major bug that caused a "NullPointerException " now fixed.
// Major update to comments.
// Intuitive interface; key letter matches first letter of function. 
// Ergonomic postioning for 3 finger control with left hand or right hand!
// Can now change color with mouse wheel or keypad!
// A 125% increase in drawing area!
// Saved image now has a name that makes sense! Saves to "image.png"
// More updates in future.
// And it was all made possible with Processing!
// :)

PImage img;
float col;
boolean dispCol;

void setup()
  {
  size(300, 150);
  colorMode(HSB, 100, 100, 100);
  background(0, 0, 80);
  }

void draw()
  {
  //background(204);
  
  if (dispCol)
    {  
    noStroke();
    fill(col, 100, 100);
    circle(150+150/2, 150/2, 50);
    }
  
  stroke(0, 0, 0);
  strokeWeight(2);
  line(width/2, 0, width/2, height);
  
  stroke(col, 100, 100);
  strokeWeight(8);
  if (mousePressed && mouseX < width/2 && pmouseX < width/2)
    {
    line(mouseX, mouseY, pmouseX, pmouseY); 
    }
  }
  
void  keyPressed()
    {
    if (key == 's')          // Saves image
      {
      img = get(0, 0, 150, 150);
      img.save("image.png");
      }
      
    if (key == 'c')          // Clears background
      {
      background(0, 0, 80);
      dispCol = false;
      }
      
    if (key == 'd')          // Displays save image
      {
      img = loadImage("image.png");
      image(img, 150, 0);
      dispCol = false;
      }

    if (key == '6')          // Hue ++
      {
      col += 3;
      if (col>100) col = 100;
      dispCol = true;
      }
    
    if (key == '4')          //Hue --
      {
      col -= 3;
      if (col< 0) col = 0;
      dispCol = true;
      }    
    }
    
void mouseWheel(MouseEvent event)
  {
  float e = event.getCount();
  println(e);    
  col += e;
  if (col > 100) col = 0;
  if (col < 0) col = 100;
  dispCol = true;
  }
  
  
//References:
// https://processing.org/tutorials/
// https://processing.org/reference/

// https://processing.org/reference/saveFrame_.html
// https://processing.org/reference/PImage.html
// https://processing.org/reference/image_.html
// https://processing.org/reference/get_.html
// https://processing.org/reference/loadImage_.html

// https://processing.org/reference/width.html
// https://processing.org/reference/height.html

// https://processing.org/tutorials/interactivity/
// https://processing.org/reference/mouseX.html
// https://processing.org/reference/mouseY.html
//https://processing.org/reference/mouseWheel_.html
// https://processing.org/reference/mousePressed_.html
// https://processing.org/reference/keyPressed_.html

// https://processing.org/reference/color_.html
// https://processing.org/reference/colorMode_.html
1 Like

Thank you so much for updating GLV paint, was really looking forward to it. Loved the 125% increase in the drawing area, works perfect for my screen.

Hope you guys like my drawing of a breakdancing frog

breakdancing%20frog

4 Likes

It is this kind of support from the community that will keep this project alive.

That black line is a bug for sure.
You can look forward to a Version 0.02 update in the future!

:slight_smile:

4 Likes

I came for the code but stayed for the comedy. :slightly_smiling_face:

Nice one you guys! LOL

:nerd_face:

3 Likes