Java Code Examples for android.graphics.Path#set()

The following examples show how to use android.graphics.Path#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AndroidAsyncView.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void drawPath(final Path p, final Stroke stroke) {
    final int alph = alpha;
    final int col = color;
    final Path path = new Path();
    path.set(p);
    final Stroke st = new Stroke();
    st.setStroke(stroke);
    pendingRenderingOperations.add(new AsyncOp(clip, clipP, clipIsPath) {
        @Override
        public void execute(AndroidGraphics underlying) {
            underlying.setAlpha(alph);
            underlying.setColor(col);
            underlying.drawPath(path, st);
        }
        public String toString() {
            return "drawPath";
        }
    });
}
 
Example 2
Source File: AndroidAsyncView.java    From CodenameOne with GNU General Public License v2.0 6 votes vote down vote up
public void fillPath(final Path p) {
    final int alph = alpha;
    final int col = color;
    final Path path = new Path();
    path.set(p);
    pendingRenderingOperations.add(new AsyncOp(clip, clipP, clipIsPath) {
        @Override
        public void execute(AndroidGraphics underlying) {
            underlying.setAlpha(alph);
            underlying.setColor(col);
            //underlying.setTransform(transform);
            underlying.fillPath(path);
        }
        public String toString() {
            return "fillPath";
        }
    });
}
 
Example 3
Source File: AndroidAsyncView.java    From CodenameOne with GNU General Public License v2.0 5 votes vote down vote up
public AsyncPaintPosition(Rectangle clip, Path clipP, boolean clipIsPath) {
    super(clip, clipP, clipIsPath);
    pendingClipIsPath = clipIsPath;


    if (clipIsPath) {
        pendingClipP = new Path();
        pendingClipP.set(this.clipPath);
    } else {
        pendingClipX = clipX;
        pendingClipY = clipY;
        pendingClipW = clipW;
        pendingClipH= clipH;
    }
}
 
Example 4
Source File: GestureOverlayView.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public Path getGesturePath(Path path) {
    path.set(mPath);
    return path;
}
 
Example 5
Source File: Utils.java    From atlas with Apache License 2.0 4 votes vote down vote up
static void applyTrimPathIfNeeded(Path path, @Nullable TrimPathContent trimPath) {
  if (trimPath == null) {
    return;
  }

  pathMeasure.setPath(path, false);

  float length = pathMeasure.getLength();
  float start = length * trimPath.getStart().getValue() / 100f;
  float end = length * trimPath.getEnd().getValue() / 100f;
  float newStart = Math.min(start, end);
  float newEnd = Math.max(start, end);

  float offset = trimPath.getOffset().getValue() / 360f * length;
  newStart += offset;
  newEnd += offset;

  // If the trim path has rotated around the path, we need to shift it back.
  if (newStart > length && newEnd > length) {
    newStart %= length;
    newEnd %= length;
  }
  if (newStart > newEnd) {
    newStart -= length;
  }

  tempPath.reset();
  pathMeasure.getSegment(
      newStart,
      newEnd,
      tempPath,
      true);

  if (newEnd > length) {
    tempPath2.reset();
    pathMeasure.getSegment(
        0,
        newEnd % length,
        tempPath2,
        true);
    tempPath.addPath(tempPath2);
  } else if (newStart < 0) {
    tempPath2.reset();
    pathMeasure.getSegment(
        length + newStart,
        length,
        tempPath2,
        true);
    tempPath.addPath(tempPath2);
  }
  path.set(tempPath);
}
 
Example 6
Source File: Utils.java    From lottie-android with Apache License 2.0 4 votes vote down vote up
public static void applyTrimPathIfNeeded(
    Path path, float startValue, float endValue, float offsetValue) {
  L.beginSection("applyTrimPathIfNeeded");
  pathMeasure.setPath(path, false);

  float length = pathMeasure.getLength();
  if (startValue == 1f && endValue == 0f) {
    L.endSection("applyTrimPathIfNeeded");
    return;
  }
  if (length < 1f || Math.abs(endValue - startValue - 1) < .01) {
    L.endSection("applyTrimPathIfNeeded");
    return;
  }
  float start = length * startValue;
  float end = length * endValue;
  float newStart = Math.min(start, end);
  float newEnd = Math.max(start, end);

  float offset = offsetValue * length;
  newStart += offset;
  newEnd += offset;

  // If the trim path has rotated around the path, we need to shift it back.
  if (newStart >= length && newEnd >= length) {
    newStart = MiscUtils.floorMod(newStart, length);
    newEnd = MiscUtils.floorMod(newEnd, length);
  }

  if (newStart < 0) {
    newStart = MiscUtils.floorMod(newStart, length);
  }
  if (newEnd < 0) {
    newEnd = MiscUtils.floorMod(newEnd, length);
  }

  // If the start and end are equals, return an empty path.
  if (newStart == newEnd) {
    path.reset();
    L.endSection("applyTrimPathIfNeeded");
    return;
  }

  if (newStart >= newEnd) {
    newStart -= length;
  }

  tempPath.reset();
  pathMeasure.getSegment(
      newStart,
      newEnd,
      tempPath,
      true);

  if (newEnd > length) {
    tempPath2.reset();
    pathMeasure.getSegment(
        0,
        newEnd % length,
        tempPath2,
        true);
    tempPath.addPath(tempPath2);
  } else if (newStart < 0) {
    tempPath2.reset();
    pathMeasure.getSegment(
        length + newStart,
        length,
        tempPath2,
        true);
    tempPath.addPath(tempPath2);
  }
  path.set(tempPath);
  L.endSection("applyTrimPathIfNeeded");
}
 
Example 7
Source File: ObjectPool.java    From pixate-freestyle-android with Apache License 2.0 4 votes vote down vote up
public void initializeInstance(Path toInitialize, Path initializerObject) {
    toInitialize.set(initializerObject);
}