My first working project!

This is my first working project. It’s a drawing tool that i used a little less then a week to make. It could be really nice if i could get some constructive criticism on it.
Here is the code:

// first tab
ArrayList<paint> p = new ArrayList<paint>();

colorc colorc;

weightc weightc;

int d=0;

boolean check=false;

int f=p.size();

void setup()
{
  fullScreen();
  noStroke();
  p.add(new paint());
  strokeWeight(10);
  colorc = new colorc();
  weightc = new weightc();
  d=1;
}

void draw()
{
  background(255);
  
  fill(0);
  
  stroke(0);
  
  for(int i=0; i<p.size(); i++)
  {
    paint part=p.get(i);
    
    part.display();
    part.update();
  }
  
  if(mouseX>301)
  {
  if(mousePressed&& (mouseButton==LEFT))
  {
    paint s=new paint();
    if(check == false)
    {
    p.get(p.size()-1).posX2=s.posX;
    p.get(p.size()-1).posY2=s.posY;
    }
    p.add(new paint());
    check = false;
    
  }else
  {
    check = true;
    p.get(p.size()-1).posX2=p.get(p.size()-1).posX;
    p.get(p.size()-1).posY2=p.get(p.size()-1).posY;
  }
  }
  
  if(p.size()!=1)
  {
  if(mousePressed&& (mouseButton==RIGHT))
  {
    p.remove(p.size()-1);
    delay(100);
  }
  }
  
  strokeWeight(10);
  rect(0,0,300,height);
  fill(bp,gp,rp);
  
  ellipse(150,height-200,100,100);
  fill(255);
  ellipse(150,150,t,t);
  fill(0);
  strokeWeight(t);
  
  weightc.display();
  weightc.update();
  
  colorc.display();
  colorc.update();
  
}

// second tab

float rp,gp,bp;

class colorc
{
  
  
  
  void update()
  {
    if(mousePressed)
    {
      if(dist(mouseX,mouseY,rp,height/2+100)<21)
      {
        rp=mouseX;
      }
      
      if(dist(mouseX,mouseY,gp,height/2)<21)
      {
        gp=mouseX;
      }
      
      if(dist(mouseX,mouseY,bp,height/2-100)<21)
      {
        bp=mouseX;
      }
    }
    
    if(rp>255)
    {
      rp=255; 
    }
    
    if(gp>255)
    {
      gp=255; 
    }
    
    if(bp>255)
    {
      bp=255; 
    }
  }
  
  void display()
  {
    strokeWeight(10);
    stroke(100);
    line(0,height/2+100,255,height/2+100);
    line(0,height/2,255,height/2);
    line(0,height/2-100,255,height/2-100);
    
    fill(255);
    textSize(20);
    text("Red:",20,height/2-150);
    
    text("Green:",20,height/2-50);
    
    text("Blue:",20,height/2+50);
    
    ellipse(rp,height/2+100,20,20);
    ellipse(gp,height/2,20,20);
    ellipse(bp,height/2-100,20,20);
    strokeWeight(t);
  }
  
}

// third tab

class paint
{
  boolean toolong=false;
  float posX=mouseX;
  float posY=mouseY;
  float posX2=mouseX;
  float posY2=mouseY;
  int c=0;
  int s=0;
  float r,g,b=0;
  float tp=0;
  
  void update()
  {
    
  }
  
  void display()
  {
    
    for(; c<1; c++)
    {
      r=rp;
      g=gp;
      b=bp;
      tp=t;
    }
    strokeWeight(tp);
    stroke(b,g,r);
    line(posX,posY,posX2,posY2);
    stroke(0);
  }
  
}

// fourth tab

float t=1;

class weightc
{
  
  
  
  void update()
  {
    if(mousePressed)
    {
    if(dist(mouseX,mouseY,t,height/2-200)<21)
    {
      t=mouseX;
    }
    } 
    if(t>254)
    {
      t=254; 
    }
    
    if(t<2)
    {
      t=2; 
    }
    
    
  }

  void display()
  {
    strokeWeight(10);
    stroke(100);
    line(0,height/2-200,255,height/2-200);
    
    fill(255);
    textSize(20);
    text("Pencil witdh",20,height/2-250);
    
    ellipse(t,height/2-200,20,20);
    strokeWeight(t);
  }

}

Thanks in advance :smiley:

3 Likes

Very nice work!

The pencil tool is very intuitive and work fine, but i would add a faster way to erase the canvas. Your solution of the rigth-click is good for undo but not for erase big areas. And about that, I would add a help text that explain very shortly how to use the tools.
It cost me to guess the option to undo!

Anyway, great work. :clap:

Another thing: Maybe this post belong to the Gallery category instead of Coding Questions.

2 Likes

Thanks a lot! The delete tool was just something that i forgot everything about as it was just a temperary fix for not being able to delete.
And yeah i should have moved it in the other catagory just was’nt sure :smile:

1 Like