use of android.graphics.PathMeasure in project LoadingDrawable by dinuscxj.
the class FishLoadingRenderer method computeRender.
@Override
protected void computeRender(float renderProgress) {
if (mRiverPath == null) {
return;
}
if (mRiverMeasure == null) {
mRiverMeasure = new PathMeasure(mRiverPath, false);
}
float fishProgress = FISH_INTERPOLATOR.getInterpolation(renderProgress);
mRiverMeasure.getPosTan(mRiverMeasure.getLength() * fishProgress, mFishHeadPos, null);
mFishRotateDegrees = calculateRotateDegrees(fishProgress);
}
use of android.graphics.PathMeasure in project LoadingDrawable by dinuscxj.
the class GuardLoadingRenderer method computeRender.
@Override
protected void computeRender(float renderProgress) {
if (renderProgress <= START_TRIM_DURATION_OFFSET) {
final float startTrimProgress = (renderProgress) / START_TRIM_DURATION_OFFSET;
mEndTrim = -MATERIAL_INTERPOLATOR.getInterpolation(startTrimProgress);
mRotation = START_TRIM_INIT_ROTATION + START_TRIM_MAX_ROTATION * MATERIAL_INTERPOLATOR.getInterpolation(startTrimProgress);
}
if (renderProgress <= WAVE_DURATION_OFFSET && renderProgress > START_TRIM_DURATION_OFFSET) {
final float waveProgress = (renderProgress - START_TRIM_DURATION_OFFSET) / (WAVE_DURATION_OFFSET - START_TRIM_DURATION_OFFSET);
mWaveProgress = ACCELERATE_INTERPOLATOR.getInterpolation(waveProgress);
}
if (renderProgress <= BALL_SKIP_DURATION_OFFSET && renderProgress > WAVE_DURATION_OFFSET) {
if (mPathMeasure == null) {
mPathMeasure = new PathMeasure(createSkipBallPath(), false);
}
final float ballSkipProgress = (renderProgress - WAVE_DURATION_OFFSET) / (BALL_SKIP_DURATION_OFFSET - WAVE_DURATION_OFFSET);
mPathMeasure.getPosTan(ballSkipProgress * mPathMeasure.getLength(), mCurrentPosition, null);
mWaveProgress = 1.0f;
}
if (renderProgress <= BALL_SCALE_DURATION_OFFSET && renderProgress > BALL_SKIP_DURATION_OFFSET) {
final float ballScaleProgress = (renderProgress - BALL_SKIP_DURATION_OFFSET) / (BALL_SCALE_DURATION_OFFSET - BALL_SKIP_DURATION_OFFSET);
if (ballScaleProgress < 0.5f) {
mScale = 1.0f + DECELERATE_INTERPOLATOR.getInterpolation(ballScaleProgress * 2.0f);
} else {
mScale = 2.0f - ACCELERATE_INTERPOLATOR.getInterpolation((ballScaleProgress - 0.5f) * 2.0f) * 2.0f;
}
}
if (renderProgress >= BALL_SCALE_DURATION_OFFSET) {
final float endTrimProgress = (renderProgress - BALL_SKIP_DURATION_OFFSET) / (END_TRIM_DURATION_OFFSET - BALL_SKIP_DURATION_OFFSET);
mEndTrim = -1 + MATERIAL_INTERPOLATOR.getInterpolation(endTrimProgress);
mRotation = END_TRIM_INIT_ROTATION + END_TRIM_MAX_ROTATION * MATERIAL_INTERPOLATOR.getInterpolation(endTrimProgress);
mScale = 1.0f;
mPathMeasure = null;
}
}
use of android.graphics.PathMeasure in project CircularFloatingActionMenu by oguzbilgener.
the class FloatingActionMenu method calculateItemPositions.
/**
* Calculates the desired positions of all items.
* @return getActionViewCenter()
*/
private Point calculateItemPositions() {
// Create an arc that starts from startAngle and ends at endAngle
// in an area that is as large as 4*radius^2
final Point center = getActionViewCenter();
RectF area = new RectF(center.x - radius, center.y - radius, center.x + radius, center.y + radius);
Path orbit = new Path();
orbit.addArc(area, startAngle, endAngle - startAngle);
PathMeasure measure = new PathMeasure(orbit, false);
// Prevent overlapping when it is a full circle
int divisor;
if (Math.abs(endAngle - startAngle) >= 360 || subActionItems.size() <= 1) {
divisor = subActionItems.size();
} else {
divisor = subActionItems.size() - 1;
}
// Measure this path, in order to find points that have the same distance between each other
for (int i = 0; i < subActionItems.size(); i++) {
float[] coords = new float[] { 0f, 0f };
measure.getPosTan((i) * measure.getLength() / divisor, coords, null);
// get the x and y values of these points and set them to each of sub action items.
subActionItems.get(i).x = (int) coords[0] - subActionItems.get(i).width / 2;
subActionItems.get(i).y = (int) coords[1] - subActionItems.get(i).height / 2;
}
return center;
}
use of android.graphics.PathMeasure in project MaterialProgressBar by DreaminginCodeZH.
the class ObjectAnimatorCompatBase method calculateXYValues.
private static void calculateXYValues(Path path, @Size(NUM_POINTS) float[] xValues, @Size(NUM_POINTS) float[] yValues) {
PathMeasure pathMeasure = new PathMeasure(path, false);
float pathLength = pathMeasure.getLength();
float[] position = new float[2];
for (int i = 0; i < NUM_POINTS; ++i) {
float distance = (i * pathLength) / (NUM_POINTS - 1);
pathMeasure.getPosTan(distance, position, null);
xValues[i] = position[0];
yValues[i] = position[1];
}
}
use of android.graphics.PathMeasure in project MaterialProgressBar by DreaminginCodeZH.
the class ObjectAnimatorCompatBase method calculateXYValues.
private static void calculateXYValues(Path path, @Size(NUM_POINTS) int[] xValues, @Size(NUM_POINTS) int[] yValues) {
PathMeasure pathMeasure = new PathMeasure(path, false);
float pathLength = pathMeasure.getLength();
float[] position = new float[2];
for (int i = 0; i < NUM_POINTS; ++i) {
float distance = (i * pathLength) / (NUM_POINTS - 1);
pathMeasure.getPosTan(distance, position, null);
xValues[i] = Math.round(position[0]);
yValues[i] = Math.round(position[1]);
}
}
Aggregations