Esempio n. 1
0
  /** @param value */
  private void calculateEffect(final double value) {
    final float mapToggleX =
        (float) SpringUtil.mapValueFromRangeToRange(value, 0, 1, spotMinX, spotMaxX);
    spotX = mapToggleX;

    float mapOffLineWidth =
        (float) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, 10, spotSize);

    offLineWidth = mapOffLineWidth;

    final int fb = Color.blue(onColor);
    final int fr = Color.red(onColor);
    final int fg = Color.green(onColor);

    final int tb = Color.blue(offBorderColor);
    final int tr = Color.red(offBorderColor);
    final int tg = Color.green(offBorderColor);

    int sb = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fb, tb);
    int sr = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fr, tr);
    int sg = (int) SpringUtil.mapValueFromRangeToRange(1 - value, 0, 1, fg, tg);

    sb = clamp(sb, 0, 255);
    sr = clamp(sr, 0, 255);
    sg = clamp(sg, 0, 255);

    borderColor = Color.rgb(sr, sg, sb);

    postInvalidate();
  }
 @Override
 public void onSpringUpdate(Spring spring) {
   mProperty.set(
       mTarget,
       (float)
           SpringUtil.mapValueFromRangeToRange(
               spring.getCurrentValue(),
               0,
               1,
               rootItem.getX() + mTarget.getMeasuredWidth() / 4,
               (float)
                   (rootItem.getX()
                       + mTarget.getMeasuredWidth() / 4
                       + ring * Math.cos(offset * arc))));
 }