use of android.graphics.PointF in project Signal-Android by WhisperSystems.
the class ScribbleActivity method addTextSticker.
protected void addTextSticker() {
TextLayer textLayer = createTextLayer();
TextEntity textEntity = new TextEntity(textLayer, scribbleView.getWidth(), scribbleView.getHeight());
scribbleView.addEntityAndPosition(textEntity);
// move text sticker up so that its not hidden under keyboard
PointF center = textEntity.absoluteCenter();
center.y = center.y * 0.5F;
textEntity.moveCenterTo(center);
// redraw
scribbleView.invalidate();
startTextEntityEditing();
changeTextEntityColor(toolbar.getToolColor());
}
use of android.graphics.PointF in project Signal-Android by WhisperSystems.
the class MoveGestureDetector method updateStateByEvent.
protected void updateStateByEvent(MotionEvent curr) {
super.updateStateByEvent(curr);
final MotionEvent prev = mPrevEvent;
// Focus intenal
mCurrFocusInternal = determineFocalPoint(curr);
mPrevFocusInternal = determineFocalPoint(prev);
// Focus external
// - Prevent skipping of focus delta when a finger is added or removed
boolean mSkipNextMoveEvent = prev.getPointerCount() != curr.getPointerCount();
mFocusDeltaExternal = mSkipNextMoveEvent ? FOCUS_DELTA_ZERO : new PointF(mCurrFocusInternal.x - mPrevFocusInternal.x, mCurrFocusInternal.y - mPrevFocusInternal.y);
// - Don't directly use mFocusInternal (or skipping will occur). Add
// unskipped delta values to mFocusExternal instead.
mFocusExternal.x += mFocusDeltaExternal.x;
mFocusExternal.y += mFocusDeltaExternal.y;
}
use of android.graphics.PointF in project Signal-Android by WhisperSystems.
the class MotionView method findEntityAtPoint.
@Nullable
private MotionEntity findEntityAtPoint(float x, float y) {
MotionEntity selected = null;
PointF p = new PointF(x, y);
for (int i = entities.size() - 1; i >= 0; i--) {
if (entities.get(i).pointInLayerRect(p)) {
selected = entities.get(i);
break;
}
}
return selected;
}
use of android.graphics.PointF in project Signal-Android by WhisperSystems.
the class TextEntity method updateEntity.
private void updateEntity(boolean moveToPreviousCenter) {
// save previous center
PointF oldCenter = absoluteCenter();
Bitmap newBmp = createBitmap(getLayer(), bitmap);
// recycle previous bitmap (if not reused) as soon as possible
if (bitmap != null && bitmap != newBmp && !bitmap.isRecycled()) {
bitmap.recycle();
}
this.bitmap = newBmp;
float width = bitmap.getWidth();
float height = bitmap.getHeight();
@SuppressWarnings("UnnecessaryLocalVariable") float widthAspect = 1.0F * canvasWidth / width;
// for text we always match text width with parent width
this.holyScale = widthAspect;
// initial position of the entity
srcPoints[0] = 0;
srcPoints[1] = 0;
srcPoints[2] = width;
srcPoints[3] = 0;
srcPoints[4] = width;
srcPoints[5] = height;
srcPoints[6] = 0;
srcPoints[7] = height;
srcPoints[8] = 0;
srcPoints[8] = 0;
if (moveToPreviousCenter) {
// move to previous center
moveCenterTo(oldCenter);
}
}
use of android.graphics.PointF in project lottie-android by airbnb.
the class EllipseContent method getPath.
@Override
public Path getPath() {
if (isPathValid) {
return path;
}
path.reset();
PointF size = sizeAnimation.getValue();
float halfWidth = size.x / 2f;
float halfHeight = size.y / 2f;
// TODO: handle bounds
float cpW = halfWidth * ELLIPSE_CONTROL_POINT_PERCENTAGE;
float cpH = halfHeight * ELLIPSE_CONTROL_POINT_PERCENTAGE;
path.reset();
path.moveTo(0, -halfHeight);
path.cubicTo(0 + cpW, -halfHeight, halfWidth, 0 - cpH, halfWidth, 0);
path.cubicTo(halfWidth, 0 + cpH, 0 + cpW, halfHeight, 0, halfHeight);
path.cubicTo(0 - cpW, halfHeight, -halfWidth, 0 + cpH, -halfWidth, 0);
path.cubicTo(-halfWidth, 0 - cpH, 0 - cpW, -halfHeight, 0, -halfHeight);
PointF position = positionAnimation.getValue();
path.offset(position.x, position.y);
path.close();
Utils.applyTrimPathIfNeeded(path, trimPath);
isPathValid = true;
return path;
}
Aggregations