GLV Paint A very simple draw and save program

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