コード例 #1
0
 /**
  * Roll over the Repeller
  *
  * @param mx
  * @param my
  */
 void rollover(int mx, int my) {
   float d = PApplet.dist(mx, my, getLoc().x, getLoc().y);
   if (d < radius) {
     rollover = true;
   } else {
     rollover = false;
   }
 }
コード例 #2
0
 /**
  * for mouse interaction
  *
  * @param mx
  * @param my
  */
 public void clicked(int mx, int my) {
   float d = PApplet.dist(mx, my, getLoc().x, getLoc().y);
   if (d < radius) {
     dragging = true;
     this.drag.x = getLoc().x - mx;
     this.drag.y = getLoc().y - my;
   }
 }
コード例 #3
0
 /*
  * (non-Javadoc)
  *
  * @see controlP5.Controller#mousePressed()
  */
 public void mousePressed() {
   float x = _myParent.absolutePosition().x() + position().x() + _myRadius;
   float y = _myParent.absolutePosition().y() + position().y() + _myRadius;
   if (PApplet.dist(x, y, _myControlWindow.mouseX, _myControlWindow.mouseY) < _myRadius) {
     isActive = true;
     if (PApplet.dist(x, y, _myControlWindow.mouseX, _myControlWindow.mouseY) > _myRadius / 2) {
       myAngle =
           (PApplet.atan2(_myControlWindow.mouseY - y, _myControlWindow.mouseX - x) - startAngle);
       if (myAngle < 0) {
         myAngle = TWO_PI + myAngle;
       }
       if (isLimited) {
         myAngle %= TWO_PI;
       }
       currentValue = PApplet.map(myAngle, 0, range, 0, 1);
       setInternalValue(currentValue);
     }
   }
 }
コード例 #4
0
 @Override
 public float getQuality(Cursor in) {
   if (in.curId == 0 && in.currentPoint != null) { // we're the first cursor id
     float avgdist = 0;
     float count = 0;
     for (Cursor c : in.manager.cursors) {
       if (c != null && c.curId != 0 && c.currentPoint != null) {
         count = count + 1;
         avgdist +=
             PApplet.dist(
                 in.currentPoint.x, in.currentPoint.y, c.currentPoint.x, c.currentPoint.y);
       }
     }
     return avgdist == 0 ? Float.NEGATIVE_INFINITY : avgdist / count / Lazy.height;
   }
   return Float.NEGATIVE_INFINITY;
 }
コード例 #5
0
ファイル: Tooltip.java プロジェクト: poqudrof/Skatolo
 private boolean moved() {
   return PApplet.abs(
           PApplet.dist(
               previousPosition.x, previousPosition.y, currentPosition.x, currentPosition.y))
       > 1;
 }
コード例 #6
0
 private boolean moved() {
   return PApplet.abs(
           PApplet.dist(
               previousPosition[0], previousPosition[1], currentPosition[0], currentPosition[1]))
       > 1;
 }