SaturationValueDrawable.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:spline 作者:
@Override
public void draw(Canvas canvas) {
    Rect b = getBounds();
    int height = b.height();
    int width = b.width();

    Paint valuePaint = new Paint();
    valuePaint.setShader(
            new LinearGradient(0, mInset, 0, height - mInset,
                    Color.WHITE, Color.BLACK, Shader.TileMode.CLAMP)
    );

    float hsv[] = {mHue, 1.0f, 1.0f};
    int pureHue = Color.HSVToColor(hsv);
    Paint saturationPaint = new Paint();
    saturationPaint.setShader(
            new LinearGradient(mInset, 0, width - mInset, 0,
                    Color.WHITE, pureHue, Shader.TileMode.CLAMP)
    );
    saturationPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));

    canvas.drawRect(b, valuePaint);
    canvas.drawRect(b, saturationPaint);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号