Search in sources :

Example 1 with PointF

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());
}
Also used : TextLayer(org.thoughtcrime.securesms.scribbles.viewmodel.TextLayer) PointF(android.graphics.PointF) TextEntity(org.thoughtcrime.securesms.scribbles.widget.entity.TextEntity)

Example 2 with PointF

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;
}
Also used : PointF(android.graphics.PointF) MotionEvent(android.view.MotionEvent)

Example 3 with PointF

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;
}
Also used : PointF(android.graphics.PointF) MotionEntity(org.thoughtcrime.securesms.scribbles.widget.entity.MotionEntity) Paint(android.graphics.Paint) Nullable(android.support.annotation.Nullable)

Example 4 with PointF

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);
    }
}
Also used : Bitmap(android.graphics.Bitmap) PointF(android.graphics.PointF)

Example 5 with PointF

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;
}
Also used : PointF(android.graphics.PointF)

Aggregations

PointF (android.graphics.PointF)686 Paint (android.graphics.Paint)132 Point (android.graphics.Point)53 RectF (android.graphics.RectF)53 Matrix (android.graphics.Matrix)43 Test (org.junit.Test)40 Path (android.graphics.Path)29 View (android.view.View)28 Drawable (android.graphics.drawable.Drawable)23 ArrayList (java.util.ArrayList)23 MotionEvent (android.view.MotionEvent)22 NonNull (android.support.annotation.NonNull)21 Rect (android.graphics.Rect)18 ValueAnimator (android.animation.ValueAnimator)14 ViewGroup (android.view.ViewGroup)11 List (java.util.List)11 Animator (android.animation.Animator)10 Bitmap (android.graphics.Bitmap)10 GestureDetector (android.view.GestureDetector)10 LinearSmoothScroller (android.support.v7.widget.LinearSmoothScroller)9