Search in sources :

Example 91 with RectF

use of android.graphics.RectF in project ZI by yixia.

the class ColorPickerView method alphaToPoint.

private Point alphaToPoint(int alpha) {
    final RectF rect = mAlphaRect;
    final float width = rect.width();
    Point p = new Point();
    p.x = (int) (width - (alpha * width / 0xff) + rect.left);
    p.y = (int) rect.top;
    return p;
}
Also used : RectF(android.graphics.RectF) Point(android.graphics.Point)

Example 92 with RectF

use of android.graphics.RectF in project ZI by yixia.

the class ColorPickerView method pointToAlpha.

private int pointToAlpha(int x) {
    final RectF rect = mAlphaRect;
    final int width = (int) rect.width();
    if (x < rect.left) {
        x = 0;
    } else if (x > rect.right) {
        x = width;
    } else {
        x = x - (int) rect.left;
    }
    return 0xff - (x * 0xff / width);
}
Also used : RectF(android.graphics.RectF) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 93 with RectF

use of android.graphics.RectF in project ZI by yixia.

the class ColorPickerView method drawSatValPanel.

private void drawSatValPanel(Canvas canvas) {
    final RectF rect = mSatValRect;
    if (BORDER_WIDTH_PX > 0) {
        mBorderPaint.setColor(mBorderColor);
        canvas.drawRect(mDrawingRect.left, mDrawingRect.top, rect.right + BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
    }
    if (mValShader == null) {
        mValShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, 0xffffffff, 0xff000000, TileMode.CLAMP);
    }
    int rgb = Color.HSVToColor(new float[] { mHue, 1f, 1f });
    mSatShader = new LinearGradient(rect.left, rect.top, rect.right, rect.top, 0xffffffff, rgb, TileMode.CLAMP);
    ComposeShader mShader = new ComposeShader(mValShader, mSatShader, PorterDuff.Mode.MULTIPLY);
    mSatValPaint.setShader(mShader);
    canvas.drawRect(rect, mSatValPaint);
    Point p = satValToPoint(mSat, mVal);
    mSatValTrackerPaint.setColor(0xff000000);
    canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS - 1f * mDensity, mSatValTrackerPaint);
    mSatValTrackerPaint.setColor(0xffdddddd);
    canvas.drawCircle(p.x, p.y, PALETTE_CIRCLE_TRACKER_RADIUS, mSatValTrackerPaint);
}
Also used : RectF(android.graphics.RectF) LinearGradient(android.graphics.LinearGradient) ComposeShader(android.graphics.ComposeShader) Point(android.graphics.Point) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 94 with RectF

use of android.graphics.RectF in project ZI by yixia.

the class ColorPickerView method drawHuePanel.

private void drawHuePanel(Canvas canvas) {
    final RectF rect = mHueRect;
    if (BORDER_WIDTH_PX > 0) {
        mBorderPaint.setColor(mBorderColor);
        canvas.drawRect(rect.left - BORDER_WIDTH_PX, rect.top - BORDER_WIDTH_PX, rect.right + BORDER_WIDTH_PX, rect.bottom + BORDER_WIDTH_PX, mBorderPaint);
    }
    if (mHueShader == null) {
        mHueShader = new LinearGradient(rect.left, rect.top, rect.left, rect.bottom, buildHueColorArray(), null, TileMode.CLAMP);
        mHuePaint.setShader(mHueShader);
    }
    canvas.drawRect(rect, mHuePaint);
    float rectHeight = 4 * mDensity / 2;
    Point p = hueToPoint(mHue);
    RectF r = new RectF();
    r.left = rect.left - RECTANGLE_TRACKER_OFFSET;
    r.right = rect.right + RECTANGLE_TRACKER_OFFSET;
    r.top = p.y - rectHeight;
    r.bottom = p.y + rectHeight;
    canvas.drawRoundRect(r, 2, 2, mHueTrackerPaint);
}
Also used : RectF(android.graphics.RectF) LinearGradient(android.graphics.LinearGradient) Point(android.graphics.Point)

Example 95 with RectF

use of android.graphics.RectF in project ZI by yixia.

the class ColorPickerView method pointToHue.

private float pointToHue(float y) {
    final RectF rect = mHueRect;
    float height = rect.height();
    if (y < rect.top) {
        y = 0f;
    } else if (y > rect.bottom) {
        y = height;
    } else {
        y = y - rect.top;
    }
    return 360f - (y * 360f / height);
}
Also used : RectF(android.graphics.RectF)

Aggregations

RectF (android.graphics.RectF)1274 Paint (android.graphics.Paint)451 Rect (android.graphics.Rect)178 Matrix (android.graphics.Matrix)155 Bitmap (android.graphics.Bitmap)150 Path (android.graphics.Path)141 Canvas (android.graphics.Canvas)136 Point (android.graphics.Point)86 ImageView (android.widget.ImageView)78 PorterDuffXfermode (android.graphics.PorterDuffXfermode)51 LinearGradient (android.graphics.LinearGradient)41 View (android.view.View)39 SuppressLint (android.annotation.SuppressLint)35 Drawable (android.graphics.drawable.Drawable)27 PointF (android.graphics.PointF)23 RadialGradient (android.graphics.RadialGradient)21 TextPaint (android.text.TextPaint)21 ArrayList (java.util.ArrayList)21 BitmapDrawable (android.graphics.drawable.BitmapDrawable)20 TypedArray (android.content.res.TypedArray)14