use of android.graphics.Path in project Signal-Android by WhisperSystems.
the class CanvasView method setup.
/**
* Common initialization.
*
* @param context
*/
private void setup(Context context) {
this.context = context;
this.pathLists.add(new Path());
this.paintLists.add(this.createPaint());
this.historyPointer++;
this.textPaint.setARGB(0, 255, 255, 255);
}
use of android.graphics.Path in project Signal-Android by WhisperSystems.
the class CanvasView method render.
public void render(Canvas canvas) {
if (this.canvas == null)
return;
float scaleX = 1.0F * canvas.getWidth() / this.canvas.getWidth();
float scaleY = 1.0F * canvas.getHeight() / this.canvas.getHeight();
Matrix matrix = new Matrix();
matrix.setScale(scaleX, scaleY);
for (int i = 0; i < this.historyPointer; i++) {
Path path = this.pathLists.get(i);
Paint paint = this.paintLists.get(i);
Path scaledPath = new Path();
path.transform(matrix, scaledPath);
Paint scaledPaint = new Paint(paint);
scaledPaint.setStrokeWidth(scaledPaint.getStrokeWidth() * scaleX);
canvas.drawPath(scaledPath, scaledPaint);
}
}
use of android.graphics.Path in project Signal-Android by WhisperSystems.
the class CanvasView method clear.
/**
* This method initializes canvas.
*
* @return
*/
public void clear() {
Path path = new Path();
path.moveTo(0F, 0F);
path.addRect(0F, 0F, 1000F, 1000F, Path.Direction.CCW);
path.close();
Paint paint = new Paint();
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.FILL);
if (this.historyPointer == this.pathLists.size()) {
this.pathLists.add(path);
this.paintLists.add(paint);
this.historyPointer++;
} else {
// On the way of Undo or Redo
this.pathLists.set(this.historyPointer, path);
this.paintLists.set(this.historyPointer, paint);
this.historyPointer++;
for (int i = this.historyPointer, size = this.paintLists.size(); i < size; i++) {
this.pathLists.remove(this.historyPointer);
this.paintLists.remove(this.historyPointer);
}
}
this.text = "";
// Clear
this.invalidate();
}
use of android.graphics.Path in project XRecyclerView by jianghejie.
the class JellyView method init.
private void init() {
if (isInEditMode()) {
return;
}
path = new Path();
paint = new Paint();
paint.setColor(getContext().getResources().getColor(android.R.color.holo_blue_bright));
paint.setAntiAlias(true);
}
use of android.graphics.Path in project LoadingView by ldoublem.
the class LVFunnyBar method onDraw.
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// canvas.translate(0,mHeight/2);
canvas.save();
float wspace = mWidth / 8f;
float hspace = mHeight / 8f;
Path p = new Path();
float leftLong = 0.1f;
float rightLong = 0.1f;
for (int i = 0; i < 3; i++) {
leftLong = mAnimatedValue * (1 + i / 4f);
if (leftLong > 1f)
leftLong = 1f;
float wlong = mWidth / 2 * leftLong - wspace / 2;
float hlong = mHeight / 2 * leftLong - hspace / 2;
if (wlong < wspace / 8 / 8 / 2) {
wlong = wspace / 8 / 8 / 2;
}
if (hlong < hspace / 8 / 8 / 2) {
hlong = wspace / 8 / 8 / 2;
}
p.reset();
p.moveTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace));
p.lineTo((i + 1f) * wspace + wlong, mHeight / 2 - hspace / 2f + (i * hspace) - hlong);
p.lineTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) - hlong);
p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
p.close();
canvas.drawPath(p, mPaintLeftTop);
p.reset();
p.moveTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace));
p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace) + hspace);
p.lineTo((i + 0.5f) * wspace, mHeight / 2 + (i * hspace) + hspace);
p.close();
canvas.drawPath(p, mPaintLeftLeft);
p.reset();
p.moveTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) - hlong);
p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace));
p.lineTo((i + 1f) * wspace, mHeight / 2 + hspace / 2f + (i * hspace) + hspace);
p.lineTo((i + 1.5f) * wspace + wlong, mHeight / 2 + (i * hspace) + hspace - hlong);
p.close();
canvas.drawPath(p, mPaintLeftRight);
int rightPosition = i;
p.reset();
p.moveTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) - hlong);
p.lineTo(mWidth - (rightPosition + 1f) * wspace - wlong, mHeight / 2 - hspace / 2f + (rightPosition * hspace) - hlong);
p.lineTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace));
p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
p.close();
canvas.drawPath(p, mPaintRightTop);
p.reset();
p.moveTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) - hlong);
p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace) + hspace);
p.lineTo(mWidth - (rightPosition + 1.5f) * wspace - wlong, mHeight / 2 + (rightPosition * hspace) + hspace - hlong);
p.close();
canvas.drawPath(p, mPaintRightLeft);
p.reset();
p.moveTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace));
p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace));
p.lineTo(mWidth - (rightPosition + 1f) * wspace, mHeight / 2 + hspace / 2f + (rightPosition * hspace) + hspace);
p.lineTo(mWidth - (rightPosition + 0.5f) * wspace, mHeight / 2 + (rightPosition * hspace) + hspace);
p.close();
canvas.drawPath(p, mPaintRightRight);
}
canvas.restore();
}
Aggregations