# GLV Paint A very simple draw and save program

**URL:** https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669
**Category:** Gallery
**Created:** [July 11, 2019, 4:38pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669 "2019-07-11T16:38:14Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [November 30, 2019, 9:33pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/5 "2019-11-30T21:33:02Z")

</div>

Updated GLV Paint

Thanks for all the support!

![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d4a225716fdfd5d39cf2071de89774df3dc37695.png)

```auto
// 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

```

---

_[View the full topic](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669)._
