本文整理汇总了Java中android.graphics.PathMeasure.getPosTan方法的典型用法代码示例。如果您正苦于以下问题:Java PathMeasure.getPosTan方法的具体用法?Java PathMeasure.getPosTan怎么用?Java PathMeasure.getPosTan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.PathMeasure
的用法示例。
在下文中一共展示了PathMeasure.getPosTan方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PathInterpolatorGingerbread
import android.graphics.PathMeasure; //导入方法依赖的package包/类
public PathInterpolatorGingerbread(Path path) {
final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);
final float pathLength = pathMeasure.getLength();
final int numPoints = (int) (pathLength / PRECISION) + 1;
mX = new float[numPoints];
mY = new float[numPoints];
final float[] position = new float[2];
for (int i = 0; i < numPoints; ++i) {
final float distance = (i * pathLength) / (numPoints - 1);
pathMeasure.getPosTan(distance, position, null /* tangent */);
mX[i] = position[0];
mY[i] = position[1];
}
}
示例2: matchVertsToPath
import android.graphics.PathMeasure; //导入方法依赖的package包/类
public void matchVertsToPath(Path path, float bottomCoord, float extraOffset) {
PathMeasure pm = new PathMeasure(path, false);
for (int i = 0; i < staticVerts.length / 2; i++) {
float yIndexValue = staticVerts[i * 2 + 1];
float xIndexValue = staticVerts[i * 2];
float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
percentOffsetX2 += pathOffsetPercent;
pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);
if (yIndexValue == 0) {
setXY(drawingVerts, i, coords[0], coords2[1]);
} else {
float desiredYCoord = bottomCoord;
setXY(drawingVerts, i, coords[0], desiredYCoord);
}
}
}
示例3: matchVertsToPath
import android.graphics.PathMeasure; //导入方法依赖的package包/类
public void matchVertsToPath(Path path, float extraOffset) {
PathMeasure pm = new PathMeasure(path, false);
int index = 0;
for (int i = 0; i < staticVerts.length / 2; i++) {
float yIndexValue = staticVerts[i * 2 + 1];
float xIndexValue = staticVerts[i * 2];
float percentOffsetX = (0.000001f + xIndexValue) / bitmap.getWidth();
float percentOffsetX2 = (0.000001f + xIndexValue) / (bitmap.getWidth() + extraOffset);
percentOffsetX2 += pathOffsetPercent;
pm.getPosTan(pm.getLength() * (1f - percentOffsetX), coords, null);
pm.getPosTan(pm.getLength() * (1f - percentOffsetX2), coords2, null);
if (yIndexValue == 0) {
setXY(drawingVerts, i, coords[0], coords2[1] + verticalOffset);
} else {
float desiredYCoord = Math.max(coords2[1], coords2[1] + easedFoamCoords[Math.min(easedFoamCoords.length - 1, index)]);
setXY(drawingVerts, i, coords[0], desiredYCoord + verticalOffset);
index += 1;
}
}
}
示例4: getValue
import android.graphics.PathMeasure; //导入方法依赖的package包/类
@Override public PointF getValue(Keyframe<PointF> keyframe, float keyframeProgress) {
PathKeyframe pathKeyframe = (PathKeyframe) keyframe;
Path path = pathKeyframe.getPath();
if (path == null) {
return keyframe.startValue;
}
if (pathMeasureKeyframe != pathKeyframe) {
pathMeasure = new PathMeasure(path, false);
pathMeasureKeyframe = pathKeyframe;
}
pathMeasure.getPosTan(keyframeProgress * pathMeasure.getLength(), pos, null);
point.set(pos[0], pos[1]);
return point;
}
示例5: setPos
import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
* 用来给每一个button设置一个中心点
*
* @param orbit 一个特定角度的path
*/
private void setPos(Path orbit) {
PathMeasure measure = new PathMeasure(orbit, false);
TextLableView tv;
for (int i = 0; i < mButtons.size(); i++) {
PopupButton pp = mButtons.get(i);
tv = kvs.get(pp);
float[] coords = new float[]{0f, 0f};
int length = (int) ((i) * measure.getLength() / mButtons.size());
measure.getPosTan(length, coords, null);
int px = (int) coords[0] - pp.getMeasuredWidth() / 2;
int py = (int) coords[1] - pp.getMeasuredHeight() / 2;
int tvx = (int) coords[0] - tv.getMeasuredWidth() / 2;
tv.x = tvx;
tv.y = py - 60;
pp.x = px;
pp.y = py;
}
}
示例6: PathInterpolatorDonut
import android.graphics.PathMeasure; //导入方法依赖的package包/类
public PathInterpolatorDonut(Path path) {
final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);
final float pathLength = pathMeasure.getLength();
final int numPoints = (int) (pathLength / PRECISION) + 1;
mX = new float[numPoints];
mY = new float[numPoints];
final float[] position = new float[2];
for (int i = 0; i < numPoints; ++i) {
final float distance = (i * pathLength) / (numPoints - 1);
pathMeasure.getPosTan(distance, position, null /* tangent */);
mX[i] = position[0];
mY[i] = position[1];
}
}
示例7: PathInterpolatorBase
import android.graphics.PathMeasure; //导入方法依赖的package包/类
public PathInterpolatorBase(Path path) {
final PathMeasure pathMeasure = new PathMeasure(path, false /* forceClosed */);
final float pathLength = pathMeasure.getLength();
final int numPoints = (int) (pathLength / PRECISION) + 1;
mX = new float[numPoints];
mY = new float[numPoints];
final float[] position = new float[2];
for (int i = 0; i < numPoints; ++i) {
final float distance = (i * pathLength) / (numPoints - 1);
pathMeasure.getPosTan(distance, position, null /* tangent */);
mX[i] = position[0];
mY[i] = position[1];
}
}
示例8: calculateItemPositions
import android.graphics.PathMeasure; //导入方法依赖的package包/类
private Point calculateItemPositions(Integer startAngle, Integer endAngle) {
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 || subMenuButtons.size() <= 1) {
divisor = subMenuButtons.size();
} else {
divisor = subMenuButtons.size() - 1;
}
// Measure the path in order to find points that have the same distance between each other
for (int i = 0; i < subMenuButtons.size(); i++) {
SubButton currentSubButton = subMenuButtons.get(i);
float[] coordinates = new float[]{0f, 0f};
int factor = animationType == AnimationType.RADIAL ? 0 : i;
measure.getPosTan(factor * measure.getLength() / divisor, coordinates, null);
currentSubButton.setX((int) coordinates[0] - currentSubButton.getWidth() / 2);
currentSubButton.setY((int) coordinates[1] - currentSubButton.getHeight() / 2);
}
return center;
}
示例9: initPath
import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
* 初始化 Path
*/
private void initPath() {
mSearchPath = new Path();
mCirclePath = new Path();
mMeasure = new PathMeasure();
RectF oval1 = new RectF(-50, -50, 50, 50);
mSearchPath.addArc(oval1, 45, 359.9f); // 放大镜的圆框
RectF oval2 = new RectF(-100, -100, 100, 100);
mCirclePath.addArc(oval2, 45, 359.9f); // 搜索的圆圈
float[] pos = new float[2];
mMeasure.setPath(mCirclePath, false);
mMeasure.getPosTan(0, pos, null); // 放大镜手柄的末端
mSearchPath.lineTo(pos[0], pos[1]); // 放大镜的手柄
}
示例10: drawRingProgress
import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
* 绘制外层圆环进度和小圆点
*/
private void drawRingProgress(Canvas canvas) {
Path path = new Path();
path.addArc(mMiddleProgressRect, mStartAngle, mCurrentAngle);
PathMeasure pathMeasure = new PathMeasure(path, false);
pathMeasure.getPosTan(pathMeasure.getLength() * 1, pos, tan);
matrix.reset();
matrix.postTranslate(pos[0] - bitmap.getWidth() / 2, pos[1] - bitmap.getHeight() / 2);
canvas.drawPath(path, mArcProgressPaint);
//起始角度不为0时候才进行绘制小圆点
if (mCurrentAngle == 0) {
return;
}
canvas.drawBitmap(bitmap, matrix, mBitmapPaint);
mBitmapPaint.setColor(Color.WHITE);
canvas.drawCircle(pos[0], pos[1], 8, mBitmapPaint);
}
示例11: warpStraightLines
import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
* Make sure it can be seen in "FILL" mode
*/
private void warpStraightLines() {
PathMeasure pmTemp = new PathMeasure();
for (int i = 0; i < mConfig.complexity; i++) {
if(lineRifts[i].isStraight())
{
pmTemp.setPath(lineRifts[i], false);
lineRifts[i].setStartLength(pmTemp.getLength() / 2);
float[] pos = new float[2];
pmTemp.getPosTan(pmTemp.getLength() / 2, pos, null);
int xRandom = (int) (pos[0] + Utils.nextInt(-Utils.dp2px(1), Utils.dp2px(1)));
int yRandom = (int) (pos[1] + Utils.nextInt(-Utils.dp2px(1), Utils.dp2px(1)));
lineRifts[i].reset();
lineRifts[i].moveTo(0,0);
lineRifts[i].lineTo(xRandom,yRandom);
lineRifts[i].lineToEnd();
}
}
}
示例12: getPoints
import android.graphics.PathMeasure; //导入方法依赖的package包/类
protected PathPoints[] getPoints(Path path, int size) {
//Size of 100 indicates that, 100 points
// would be extracted from the path
PathPoints[] pointArray = new PathPoints[size];
PathMeasure pm = new PathMeasure(path, false);
float length = pm.getLength();
float distance = 0f;
float speed = length / size;
int counter = 0;
float[] aCoordinates = new float[2];
while ((distance < length) && (counter < size)) {
pm.getPosTan(distance, aCoordinates, null);
pointArray[counter] = new PathPoints(aCoordinates[0], aCoordinates[1]);
counter++;
distance = distance + speed;
}
return pointArray;
}
示例13: calculateMenuItemPosition
import android.graphics.PathMeasure; //导入方法依赖的package包/类
/**
* calculate and set position to menu items
*/
private void calculateMenuItemPosition() {
float itemRadius = (expandedRadius + collapsedRadius) / 2, f;
RectF area = new RectF(
center.x - itemRadius,
center.y - itemRadius,
center.x + itemRadius,
center.y + itemRadius);
Path path = new Path();
path.addArc(area, (float) fromAngle, (float) (toAngle - fromAngle));
PathMeasure measure = new PathMeasure(path, false);
float len = measure.getLength();
int divisor = getChildCount();
float divider = len / divisor;
for (int i = 0; i < getChildCount(); i++) {
float[] coords = new float[2];
measure.getPosTan(i * divider + divider * .5f, coords, null);
FilterMenu.Item item = (FilterMenu.Item) getChildAt(i).getTag();
item.setX((int) coords[0] - item.getView().getMeasuredWidth() / 2);
item.setY((int) coords[1] - item.getView().getMeasuredHeight() / 2);
}
}
示例14: draw
import android.graphics.PathMeasure; //导入方法依赖的package包/类
void draw(Canvas canvas, Paint paint, int color, float size, Path path) {
PathMeasure mPathMeasure = new PathMeasure();
float[] mPosition = new float[2];
float[] mTan = new float[2];
mPathMeasure.setPath(path, false);
paint.setAntiAlias(true);
paint.setColor(color);
paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
Bitmap brush;
// done this way because of a bug in
// Bitmap.createScaledBitmap(getBrush(),(int) size,(int) size,true);
brush = createScaledBitmap(getBrush(), (int) size, (int) size, true);
float len = mPathMeasure.getLength();
float s2 = size / 2;
float step = s2 / 8;
for (float i = 0; i < len; i += step) {
mPathMeasure.getPosTan(i, mPosition, mTan);
// canvas.drawCircle(pos[0], pos[1], size, paint);
canvas.drawBitmap(brush, mPosition[0] - s2, mPosition[1] - s2, paint);
}
}
示例15: draw
import android.graphics.PathMeasure; //导入方法依赖的package包/类
@Override
public void draw(ActionButtonDataHolder dataHolder, Canvas canvas, boolean isSelected) {
MeasureHolder holder = measureHolder.get(dataHolder);
if (holder == null) {
Matrix scaleMatrix = new Matrix();
RectF rectF = new RectF();
Path line = new Path();
line.moveTo(dataHolder.getDownPosition().x, dataHolder.getDownPosition().y);
line.lineTo(dataHolder.getPosition().x, dataHolder.getPosition().y);
line.computeBounds(rectF, true);
scaleMatrix.setScale(getMetrics().nudgeFactor, getMetrics().nudgeFactor, rectF.centerX(), rectF.centerY());
line.transform(scaleMatrix);
PathMeasure measure = new PathMeasure(line, false);
float[] labelPosition = new float[2];
holder = new MeasureHolder(measure, 80 * dataHolder.getIndex(), labelPosition);
measure.getPosTan(measure.getLength(), labelPosition, null);
measureHolder.put(dataHolder, holder);
}
renderer.draw(holder, dataHolder, canvas, isSelected, holder.path);
labelRenderer.draw(dataHolder, canvas, isSelected, holder.labelPosition);
}