# 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:** 8\
**Page:** 1

<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:** [July 11, 2019, 4:38pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/1 "2019-07-11T16:38:14Z")

</div>

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

```auto
// 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](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/2/2d55f929110a0fcede693a7a36a74d5ac1e48b64.png)

![chromosone](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/6/66e4fda1ce3ba7d5586ee48316cb1253b3876d92.png)

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [July 11, 2019, 6:27pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/2 "2019-07-11T18:27:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [July 11, 2019, 6:27pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/3 "2019-07-11T18:27:12Z")

</div>

![chromosone](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cb3a499bd1a39ea9c31c8d9d81767f0b3b0bea6e.png)  
_made possible by GLV’s Photoshop++_

---

<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:** [July 11, 2019, 6:38pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/4 "2019-07-11T18:38:08Z")

</div>

That made me laugh out loud!

I like the choice of colour!

☀

---

<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

```

---

<div class="post-metadata">

**Author:** ![Tiemen](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tiemen/32/5477_2.png) [@Tiemen](https://discourse.processing.org/u/Tiemen)\
**Post date:** [December 1, 2019, 11:14pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/6 "2019-12-01T23:14:55Z")

</div>

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.

 ![Screenshot%20(58)](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/f/f0d9f2856a5886d6c2eb2470e0c9e33c8208e0e1.png)

Hope you guys like my drawing of a breakdancing frog

![breakdancing%20frog](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/d/d3e50813e64162c253ab92954cee8442eac8220c.png)

---

<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:** [December 1, 2019, 11:21pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/7 "2019-12-01T23:21:28Z")

</div>

> [@Tiemen](#):
>
> 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.

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!

🙂

---

<div class="post-metadata">

**Author:** ![debxyz](https://avatars.discourse-cdn.com/v4/letter/d/58956e/32.png) [@debxyz](https://discourse.processing.org/u/debxyz)\
**Post date:** [October 26, 2022, 6:29pm UTC](https://discourse.processing.org/t/glv-paint-a-very-simple-draw-and-save-program/12669/8 "2022-10-26T18:29:25Z")

</div>

I came for the code but stayed for the comedy. 🙂

Nice one you guys! LOL

🤓
