drawing a line via array with interruption / skip numbers in an array
in
Programming Questions
•
2 years ago
Hi
I wanna make this very simple drawing tool without using mouseX, pmouseX, etc...
But how can i get an interruption when i stop drawing and than start again.
For example the array is at a value of 12 when i stop dragging the mouse, when i press again it should skip
number 13 in the array.
Do i need a return or a break funktion?
thanks!
I wanna make this very simple drawing tool without using mouseX, pmouseX, etc...
But how can i get an interruption when i stop drawing and than start again.
For example the array is at a value of 12 when i stop dragging the mouse, when i press again it should skip
number 13 in the array.
Do i need a return or a break funktion?
- int[] x = new int[0];
- int[] y = new int[0];
- int mx,my;
- boolean drag = false;
- void setup() {
- size(600, 600);
- }
- void draw() {
- background(255);
- rectMode(CENTER);
- noFill();
- mx = mouseX;
- my = mouseY;
- beginShape();
- for (int i = 0; i < x.length-1; i+=1) {
- line(x[i+1], y[i+1],x[i], y[i]);
- }
- endShape();
- if(drag){
- x = append(x, mx);
- y = append(y, my);
- }
- }
- void mousePressed(){
- drag = true;
- }
- void mouseReleased(){
- drag = false;
- }
thanks!
1