本文整理了Java中android.graphics.Path.rewind()
方法的一些代码示例,展示了Path.rewind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.rewind()
方法的具体详情如下:
包路径:android.graphics.Path
类名称:Path
方法名:rewind
暂无
代码示例来源:origin: TeamNewPipe/NewPipe
private void setupMarquee(int width, int height) {
mMarqueeSize = (int) ((width * 10f) / 100f);// the size is 10% of the width
mMarqueeLine.rewind();
mMarqueeLine.moveTo(-mMarqueeSize, -mMarqueeSize);
mMarqueeLine.lineTo(-mMarqueeSize * 4, height + mMarqueeSize);
mMarqueeLine.close();
}
}
代码示例来源:origin: TangoAgency/material-intro-screen
private Path getRetreatingJoinPath() {
unselectedDotPath.rewind();
rectF.set(retreatingJoinX1, dotTopY, retreatingJoinX2, dotBottomY);
unselectedDotPath.addRoundRect(rectF, dotRadius, dotRadius, Path.Direction.CW);
return unselectedDotPath;
}
代码示例来源:origin: scwang90/SmartRefreshLayout
canvas.drawPath(mWavePath, mPaint);
if (!thisView.isInEditMode()) {
mWavePath.rewind();
mDropTangentPath.rewind();
mDropCirclePath.rewind();
代码示例来源:origin: steelkiwi/cropiwa
@Override
protected void drawGrid(Canvas canvas, RectF cropBounds, Paint paint) {
clipPath.rewind();
clipPath.addOval(cropBounds, Path.Direction.CW);
canvas.save(Canvas.CLIP_SAVE_FLAG);
canvas.clipPath(clipPath);
super.drawGrid(canvas, cropBounds, paint);
canvas.restore();
}
代码示例来源:origin: TangoAgency/material-intro-screen
private void drawUnselected(Canvas canvas) {
combinedUnselectedPath.rewind();
for (int page = 0; page < pageCount; page++) {
int nextXIndex;
if (page == pageCount - 1) {
nextXIndex = page;
} else {
nextXIndex = page + 1;
}
Path unselectedPath = getUnselectedPath(page,
dotCenterX[page],
dotCenterX[nextXIndex],
page == pageCount - 1 ? INVALID_FRACTION : joiningFractions[page],
dotRevealFractions[page]);
unselectedPath.addPath(combinedUnselectedPath);
combinedUnselectedPath.addPath(unselectedPath);
}
if (retreatingJoinX1 != INVALID_FRACTION) {
Path retreatingJoinPath = getRetreatingJoinPath();
combinedUnselectedPath.addPath(retreatingJoinPath);
}
canvas.drawPath(combinedUnselectedPath, unselectedPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
代码示例来源:origin: udacity/ud851-Exercises
/**
* This draw method abstracts out what is common between drawing all shapes
*
* @param canvas The canvas to draw on
* @param currentFreqAve The average frequency for the same, which determines the boost in size
* @param currentAngle The current angle around the center to draw the shape
*/
void draw(Canvas canvas, float currentFreqAve, double currentAngle) {
float currentSize = sMinSize + mMultiplier * currentFreqAve;
// Calculate where the shape is
float shapeCenterX = calcLocationInAnimationX(mShapeRadiusFromCenter, currentAngle);
float shapeCenterY = calcLocationInAnimationY(mShapeRadiusFromCenter, currentAngle);
// Calculate where the next point in the trail is
float trailX = calcLocationInAnimationX((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
float trailY = calcLocationInAnimationY((mShapeRadiusFromCenter + currentSize - sMinSize), currentAngle);
mTrailPath.rewind(); // clear the trail
mTrailList.add(new TrailPoint(trailX, trailY, currentAngle)); // add the new line segment
// Keep the trail size correct
while (currentAngle - mTrailList.peekFirst().theta > 2 * Math.PI) {
mTrailList.poll();
}
// Draw the trail
mTrailPath.moveTo(mTrailList.peekFirst().x, mTrailList.peekFirst().y);
for (TrailPoint trailPoint : mTrailList) {
mTrailPath.lineTo(trailPoint.x, trailPoint.y);
}
canvas.drawPath(mTrailPath, mTrailPaint);
// Call the abstract drawThisShape method, this must be defined for each shape.
drawThisShape(shapeCenterX, shapeCenterY, currentSize, canvas, mPaint);
}
内容来源于网络,如有侵权,请联系作者删除!