File size: 1,820 Bytes
c2a5d87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class BrushPoint{
  
    constructor(name, dist, piPosition) {
      this.name = name;
      this.dist = dist;
      this.piPosition = piPosition
      
      this.px;
      this.py;
      this.ppx;
      this.ppy;
      this.sx;
      this.sy;
      this.pointerX;
      this.pointerY;
    }
    
    // -----------------------------------------
    // -----------------------------------------
    
    calcPointCoordinates(mouseX, mouseY, angle, pressure){
      this.pointerX = mouseX + (this.dist * pressure) * cos(angle + this.piPosition);
      this.pointerY = mouseY + (this.dist * pressure) * sin(angle + this.piPosition);
      //console.log('class: ' + this.pointerX + ' ' + this.pointerY)
    }
    
    // -----------------------------------------
    // -----------------------------------------
    
    resetPointOrigin(){
      this.sx = this.pointerX;
      this.sy = this.pointerY;
      this.px = this.pointerX;
      this.py = this.pointerY;
      this.ppx = this.pointerX;
      this.ppy = this.pointerY;
      //console.log(this.sx, this.sy, this.px, this.py, this.ppx, this.ppy)
    }
    
    // -----------------------------------------
    // -----------------------------------------
    
    shiftPointVertex(){
      this.sx = this.ppx;
      this.sy = this.ppy;
      this.ppx = this.px;
      this.ppy = this.py;
      this.px = this.pointerX;  
      this.py = this.pointerY;
    }
    
    // -----------------------------------------
    // -----------------------------------------
    
    pushPoints(point){
      point.x1.push(this.sx)
        point.y1.push(this.sy)
        point.x2.push(this.ppx)
        point.y2.push(this.ppy)
        point.x3.push(this.px)
        point.y3.push(this.py)
        point.x4.push(this.pointerX)
        point.y4.push(this.pointerY)
    }
    
  }