android.graphics.CornerPathEffect Java Examples

The following examples show how to use android.graphics.CornerPathEffect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MountainView.java    From BackgroundView with Apache License 2.0 6 votes vote down vote up
private void init() {
    mPaint = new Paint();
    // 绘制贝塞尔曲线
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(8);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setTextSize(60);
    mPaint.setPathEffect(new CornerPathEffect(4));

    for (int i = 0; i < mData.length; i++) {
        mData[i] = new PointF();
    }
    for (int i = 0; i < mCtrl.length; i++) {
        mCtrl[i] = new PointF();
    }


}
 
Example #2
Source File: TabIndicator.java    From ViewPagerHelper with Apache License 2.0 6 votes vote down vote up
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mHeight = h;
    mWidth = w;
    mPath = new Path();
    int width = mWidth / mVisiableSize;
    if (mTabtyle == TabShapeType.TRI) {
        //画三角形
        mPaint.setPathEffect(new CornerPathEffect(2)); //使三角形更加圆润
        mPath.moveTo((width - mTabWidth) / 2, mHeight);
        mPath.lineTo((width + mTabWidth) / 2, mHeight);
        mPath.lineTo(width / 2, mHeight - mTabHeight);

    } else {
        mPath.close();
        //画条状
        mPath.moveTo((width - mTabWidth) / 2, mHeight);
        mPath.lineTo((width + mTabWidth) / 2, mHeight);
        mPath.lineTo((width + mTabWidth) / 2, mHeight - mTabHeight);
        mPath.lineTo((width - mTabWidth) / 2, mHeight - mTabHeight);
        mPath.close();
    }


}
 
Example #3
Source File: OWLoadingView.java    From OverWatchLoading with Apache License 2.0 6 votes vote down vote up
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    viewHeight = getMeasuredHeight();
    viewWidth = getMeasuredWidth();
    if (viewWidth != 0 && viewHeight != 0) {
        center.x = viewWidth / 2f;
        center.y = viewHeight / 2f;
        float spaceRate = 1 / 100f;
        space = viewWidth <= viewHeight ? viewWidth * spaceRate : viewHeight * spaceRate;
        hexagonRadius = (float) ((viewWidth - 2 * space) / (3 * Math.sqrt(3)));
        initHexagonCenters();
        //圆角处理
        paint.setPathEffect(new CornerPathEffect(hexagonRadius * 0.1f));
        baseDataInited = true;
    }
}
 
Example #4
Source File: CurveView.java    From CurveView with GNU General Public License v3.0 6 votes vote down vote up
private void init() {
        mCornerPathEffect = new CornerPathEffect(mCorner);

        mContentPaint = new Paint();
        mContentPaint.setStyle(Paint.Style.STROKE);
        mContentPaint.setColor(mContentColor);
        mContentPaint.setStrokeWidth(mStrokeWidth);
        mContentPaint.setPathEffect(mCornerPathEffect);

        mBackgroundPaint = new Paint();
//        mBackgroundPaint.setColor(mFillColor);

        mXAxisPaint = new TextPaint();
        mXAxisPaint.setColor(mAxisTextColor);
        mXAxisPaint.setTextSize(mAxisTextSize);

        mDotTextPaint = new TextPaint();
        mDotTextPaint.setColor(mDotTextColor);
        mDotTextPaint.setTextSize(mDotTextSize);

        mContentPath = new Path();
        //        mMaxVelocity = ViewConfiguration.get(getContext()).getScaledMaximumFlingVelocity();
        mMaxVelocity = 3000;
    }
 
Example #5
Source File: Paper.java    From shaky-android with Apache License 2.0 6 votes vote down vote up
public Paper(@NonNull Context context, @NonNull AttributeSet attrs) {
    super(context, attrs);

    // red brush for marking up bugs
    thinPaint.setColor(Color.RED);
    thinPaint.setAntiAlias(true);
    thinPaint.setStrokeWidth(THIN_STROKE_WIDTH);
    thinPaint.setStyle(Paint.Style.STROKE);
    thinPaint.setStrokeJoin(Paint.Join.ROUND);
    thinPaint.setPathEffect(new CornerPathEffect(PATH_SMOOTH));

    // white brush to white-out sensitive information
    thickPaint = new Paint(thinPaint);
    thickPaint.setStrokeWidth(THICK_STROKE_WIDTH);
    thickPaint.setColor(Color.WHITE);

    // set default drawing path
    currentBrush = thinPath;
}
 
Example #6
Source File: ProgressWheel.java    From pandroid with Apache License 2.0 6 votes vote down vote up
/**
 * Set the properties of the paints we're using to
 * draw the progress wheel
 */
private void setupPaints() {
    if (roundStroke) {
        barPaint.setDither(true);
        barPaint.setStrokeCap(Paint.Cap.ROUND);
        barPaint.setPathEffect(new CornerPathEffect(10) );
    }

    barPaint.setColor(barColor);
    barPaint.setAntiAlias(true);
    barPaint.setStyle(Style.STROKE);
    barPaint.setStrokeWidth(barWidth);

    rimPaint.setColor(rimColor);
    rimPaint.setAntiAlias(true);
    rimPaint.setStyle(Style.STROKE);
    rimPaint.setStrokeWidth(rimWidth);
}
 
Example #7
Source File: SimpleDraw.java    From zone-sdk with MIT License 6 votes vote down vote up
private void initView() {
    mHolder = getHolder();
    mHolder.addCallback(this);
    setFocusable(true);
    setFocusableInTouchMode(true);
    this.setKeepScreenOn(true);
    mPath = new Path();
    mPaint = new Paint();
    mPaint.setColor(Color.RED);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeWidth(20);
    mPaint.setDither(true);
    mPaint.setAntiAlias(true);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setPathEffect(new CornerPathEffect(10)); 
    
}
 
Example #8
Source File: ViewPagerIndicator.java    From GOpenSource_AppKit_Android_AS with MIT License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	mTabVisibleCount = 2;
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffff9a23"));
	mPaint.setColor(getContext().getResources().getColor(R.color.yellow));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example #9
Source File: ViewPagerIndicator.java    From umeng_community_android with MIT License 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

    mLinePaint = new Paint();
    mLinePaint.setAntiAlias(true);
    mLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mLinePaint.setStyle(Style.FILL);
    mLinePaint.setStrokeWidth(10);

    mDividerLinePaint = new Paint();
    mDividerLinePaint.setAntiAlias(true);
    mDividerLinePaint.setColor(COLOR_TEXT_HIGHLIGHTCOLOR);
    mDividerLinePaint.setStyle(Style.FILL);
    mDividerLinePaint.setStrokeWidth(5);
}
 
Example #10
Source File: ViewPagerIndicator.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);

    // 获得自定义属性,tab的数量
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ViewPagerIndicator);
    mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_showItem,
            COUNT_DEFAULT_TAB);
    if (mTabVisibleCount < 0)
        mTabVisibleCount = COUNT_DEFAULT_TAB;

    mTriangleColor = a.getColor(R.styleable.ViewPagerIndicator_triangleColor, COLOR_DEFAULT_TRIANGLE);
    if (mTriangleColor < 0) {
        mTriangleColor = COLOR_DEFAULT_TRIANGLE;
    }
    a.recycle();

    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(mTriangleColor);
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example #11
Source File: ViewPagerIndicator.java    From Android-ViewPagerIndicator with Apache License 2.0 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获取可见Tab的数量
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ViewPagerIndicator);

	mTabVisibleCount = a.getInt(
			R.styleable.ViewPagerIndicator_visible_tab_count,
			COUNT_DEFAULT_TAB);
	if (mTabVisibleCount < 0)
	{
		mTabVisibleCount = COUNT_DEFAULT_TAB;
	}
	a.recycle();

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffffffff"));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example #12
Source File: ViewPagerIndicator.java    From miappstore with Apache License 2.0 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs)
{
	super(context, attrs);

	// 获得自定义属性,tab的数量
	TypedArray a = context.obtainStyledAttributes(attrs,
			R.styleable.ViewPagerIndicator);
	mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
			COUNT_DEFAULT_TAB);
	if (mTabVisibleCount < 0)
		mTabVisibleCount = COUNT_DEFAULT_TAB;
	a.recycle();

	// 初始化画笔
	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(Color.parseColor("#ffffffff"));
	mPaint.setStyle(Style.FILL);
	mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example #13
Source File: SmoothStrokeMode.java    From cidrawing with Apache License 2.0 6 votes vote down vote up
protected CiPaint assignPaint() {
    CiPaint paint = new CiPaint(drawingContext.getPaint());
    paint.setStyle(Paint.Style.STROKE);
    paint.setAntiAlias(true);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeCap(Paint.Cap.ROUND);
    if (smoothRadius > 0) {
        CornerPathEffect effect = new CornerPathEffect(smoothRadius);
        if (paint.getPathEffect() == null) {
            paint.setPathEffect(effect);
        } else {
            ComposePathEffect composeEffect = new ComposePathEffect(paint.getPathEffect(), effect);
            paint.setPathEffect(composeEffect);
        }
    }
    return paint;
}
 
Example #14
Source File: ViewPagerIndicator.java    From smart-farmer-android with Apache License 2.0 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);

    // 获得自定义属性,tab的数量
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.ViewPagerIndicator);
    mTabVisibleCount = a.getInt(R.styleable.ViewPagerIndicator_item_count,
            COUNT_DEFAULT_TAB);
    if (mTabVisibleCount < 0)
        mTabVisibleCount = COUNT_DEFAULT_TAB;
    a.recycle();

    // 初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(Color.parseColor("#ffffffff"));
    mPaint.setStyle(Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));

}
 
Example #15
Source File: CustomButton.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
public CustomButton(Context context) {
	super(context);
	paint = new Paint(Paint.ANTI_ALIAS_FLAG);
	paint.setStyle(Style.FILL);
	paint.setColor(Color.BLACK);
	paint.setTextSize(40);

	fillPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	fillPaint.setStyle(Style.FILL);
	fillPaint.setColor(Color.RED);
	CornerPathEffect effect = new CornerPathEffect(30);
	fillPaint.setPathEffect(effect);
	fillPaint.setStyle(Style.FILL_AND_STROKE);
	fillPaint.setShader(new LinearGradient(0F, 120, getWidth(),
			getHeight(), Color.CYAN, Color.RED, Shader.TileMode.CLAMP));

}
 
Example #16
Source File: BarcodeGraphicBase.java    From mlkit-material-android with Apache License 2.0 6 votes vote down vote up
BarcodeGraphicBase(GraphicOverlay overlay) {
  super(overlay);

  boxPaint = new Paint();
  boxPaint.setColor(ContextCompat.getColor(context, R.color.barcode_reticle_stroke));
  boxPaint.setStyle(Paint.Style.STROKE);
  boxPaint.setStrokeWidth(
      context.getResources().getDimensionPixelOffset(R.dimen.barcode_reticle_stroke_width));

  scrimPaint = new Paint();
  scrimPaint.setColor(ContextCompat.getColor(context, R.color.barcode_reticle_background));
  eraserPaint = new Paint();
  eraserPaint.setStrokeWidth(boxPaint.getStrokeWidth());
  eraserPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));

  boxCornerRadius =
      context.getResources().getDimensionPixelOffset(R.dimen.barcode_reticle_corner_radius);

  pathPaint = new Paint();
  pathPaint.setColor(Color.WHITE);
  pathPaint.setStyle(Paint.Style.STROKE);
  pathPaint.setStrokeWidth(boxPaint.getStrokeWidth());
  pathPaint.setPathEffect(new CornerPathEffect(boxCornerRadius));

  boxRect = PreferenceUtils.getBarcodeReticleBox(overlay);
}
 
Example #17
Source File: LeafView.java    From BackgroundView with Apache License 2.0 6 votes vote down vote up
private void init() {
    mPaint = new Paint();
    // 绘制贝塞尔曲线
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(8);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setTextSize(60);
    mPaint.setPathEffect(new CornerPathEffect(4));

    for (int i = 0; i < mData.length; i++) {
        mData[i] = new PointF();
    }
    for (int i = 0; i < mCtrl.length; i++) {
        mCtrl[i] = new PointF();
    }

}
 
Example #18
Source File: ViewPagerIndicator.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
public ViewPagerIndicator(Context context, AttributeSet attrs) {
    super(context, attrs);
    //获取可见的tab数量
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerIndicator);
    mVisibleTabCount = a.getInt(R.styleable.ViewPagerIndicator_visibleTabCount, 3);
    tabSelectedColor = a.getColor(R.styleable.ViewPagerIndicator_tabSelectedColor, getResources().getColor(R.color.orange_red_300));
    spaceHeight = (int) a.getDimension(R.styleable.ViewPagerIndicator_spaceHeight, 2);
    tabNormalColor = a.getColor(R.styleable.ViewPagerIndicator_tabNormalColor, getResources().getColor(R.color.black_transparency_500));
    lineHeight = (int) a.getDimension(R.styleable.ViewPagerIndicator_lineHeight, 2);
    tabTextSize = (int) a.getDimension(R.styleable.ViewPagerIndicator_tabTextSize, 14);
    margin = (int) a.getDimension(R.styleable.ViewPagerIndicator_margin, 0);
    int lineColor = a.getColor(R.styleable.ViewPagerIndicator_lineColor, getResources().getColor(R.color.orange_500));
    if (mVisibleTabCount < 0) {
        mVisibleTabCount = 3;
    }
    a.recycle();
    mPath = new Path();
    //初始化画笔
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setColor(lineColor);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setPathEffect(new CornerPathEffect(3));
    setOrientation(HORIZONTAL);
}
 
Example #19
Source File: VoronoiView.java    From Vorolay with Apache License 2.0 5 votes vote down vote up
private void initPaint() {
    p = new Paint();
    p.setAntiAlias(true);
    p.setColor(mBorderColor);
    p.setStrokeWidth(mBorderWidth);
    p.setStyle(Paint.Style.STROKE);

    if (mRoundCornersEnabled) {
        p.setStrokeJoin(Paint.Join.ROUND);
        p.setStrokeCap(Paint.Cap.SQUARE);
        p.setPathEffect(new CornerPathEffect(15));
    }
}
 
Example #20
Source File: SimpleRatingBar.java    From SimpleRatingBar with Apache License 2.0 5 votes vote down vote up
/**
 * Sets radius of star corner in pixels.
 * Throws IllegalArgumentException if provided value is less than zero.
 * @param starCornerRadius
   */
public void setStarCornerRadius(float starCornerRadius) {
  this.starCornerRadius = starCornerRadius;
  if (starCornerRadius < 0) {
    throw new IllegalArgumentException(String.format("SimpleRatingBar initialized with invalid value for starCornerRadius. Found %f, but should be greater or equal than 0",
            starCornerRadius));
  }
  cornerPathEffect = new CornerPathEffect(starCornerRadius);
  paintStarBorder.setPathEffect(cornerPathEffect);
  paintStarOutline.setPathEffect(cornerPathEffect);
  // request redraw of the view
  invalidate();
}
 
Example #21
Source File: SimpleRatingBar.java    From SimpleRatingBar with Apache License 2.0 5 votes vote down vote up
/**
 * Inits paint objects and default values.
 */
private void initView() {
  starPath = new Path();
  cornerPathEffect = new CornerPathEffect(starCornerRadius);

  paintStarOutline = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  paintStarOutline.setStyle(Paint.Style.FILL_AND_STROKE);
  paintStarOutline.setAntiAlias(true);
  paintStarOutline.setDither(true);
  paintStarOutline.setStrokeJoin(Paint.Join.ROUND);
  paintStarOutline.setStrokeCap(Paint.Cap.ROUND);
  paintStarOutline.setColor(Color.BLACK);
  paintStarOutline.setPathEffect(cornerPathEffect);

  paintStarBorder = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  paintStarBorder.setStyle(Paint.Style.STROKE);
  paintStarBorder.setStrokeJoin(Paint.Join.ROUND);
  paintStarBorder.setStrokeCap(Paint.Cap.ROUND);
  paintStarBorder.setStrokeWidth(starBorderWidth);
  paintStarBorder.setPathEffect(cornerPathEffect);

  paintStarBackground = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  paintStarBackground.setStyle(Paint.Style.FILL_AND_STROKE);
  paintStarBackground.setAntiAlias(true);
  paintStarBackground.setDither(true);
  paintStarBackground.setStrokeJoin(Paint.Join.ROUND);
  paintStarBackground.setStrokeCap(Paint.Cap.ROUND);

  paintStarFill = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
  paintStarFill.setStyle(Paint.Style.FILL_AND_STROKE);
  paintStarFill.setAntiAlias(true);
  paintStarFill.setDither(true);
  paintStarFill.setStrokeJoin(Paint.Join.ROUND);
  paintStarFill.setStrokeCap(Paint.Cap.ROUND);

  defaultStarSize = applyDimension(COMPLEX_UNIT_DIP, 30, getResources().getDisplayMetrics());
}
 
Example #22
Source File: ChevronRegionView.java    From CameraV with GNU General Public License v3.0 5 votes vote down vote up
private void updatePath()
{
	float radius = getWidth() / 20;
	float arrowHeight = getHeight() / 4;

	Rect rect = new Rect(2, 2, this.getWidth() - 4, this.getHeight() - 4);

	mPath = new Path();
	mPath.moveTo(rect.left + radius, rect.top);
	mPath.lineTo(rect.right, rect.top);
	mPath.lineTo(rect.right, rect.bottom - arrowHeight);
	mPath.lineTo(rect.exactCenterX(), rect.bottom);
	mPath.lineTo(rect.left, rect.bottom - arrowHeight);
	mPath.lineTo(rect.left, rect.top);
	mPath.close();

	int color = this.getContext().getResources().getColor(R.color.tag_unselected_outline);
	if (mIsActive)
		color = this.getContext().getResources().getColor(R.color.tag_selected_outline);

	mPaint = new Paint();
	mPaint.setAntiAlias(true);
	mPaint.setColor(color);
	mPaint.setStyle(Paint.Style.FILL);
	mPaint.setStrokeWidth(0);
	mPaint.setStrokeJoin(Paint.Join.ROUND); // set the join to round you
											// want
	mPaint.setStrokeCap(Paint.Cap.ROUND); // set the paint cap to round too
	mPaint.setPathEffect(new CornerPathEffect(radius)); // set the path
														// effect when they

	color = this.getContext().getResources().getColor(R.color.tag_unselected);
	if (mIsActive)
		color = this.getContext().getResources().getColor(R.color.tag_selected);
	mShader = new LinearGradient(0, 0, 0, getHeight(), color, color, Shader.TileMode.CLAMP);
}
 
Example #23
Source File: PolygonImageView.java    From PolygonImageView with Apache License 2.0 5 votes vote down vote up
/**
 * Init paints and effects
 */
@SuppressLint("NewApi")
private void init() {
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setPathEffect(new CornerPathEffect(mPolygonShapeSpec.getCornerRadius()));
    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setPathEffect(new CornerPathEffect(mPolygonShapeSpec.getCornerRadius()));

    if(mPolygonShapeSpec.hasBorder()) {
        mBorderPaint.setColor(mPolygonShapeSpec.getBorderColor());
        mBorderPaint.setStrokeWidth(mPolygonShapeSpec.getBorderWidth());
    }

    if (mPolygonShapeSpec.hasShadow()) {
        //Shadow on border even if isBordered is false. Better effect and performance that
        //using shadow on main paint
        mBorderPaint.setShadowLayer(mPolygonShapeSpec.getShadowRadius(), mPolygonShapeSpec.getShadowXOffset(),
                mPolygonShapeSpec.getShadowYOffset(), mPolygonShapeSpec.getShadowColor());
    }

    //Avoid known shadow problems
    if (Build.VERSION.SDK_INT > 13)
        setLayerType(LAYER_TYPE_SOFTWARE, null);

    mPolygonShape = new RegularPolygonShape();
}
 
Example #24
Source File: PolygonImageView.java    From PolygonImageView with Apache License 2.0 5 votes vote down vote up
/**
 * Sets new radius for corners and updates view.
 *
 * @param cornerRadius new corner radius
 */
public void setCornerRadius(float cornerRadius) {
    mPolygonShapeSpec.setCornerRadius(cornerRadius);
    mBorderPaint.setPathEffect(new CornerPathEffect(cornerRadius));
    mPaint.setPathEffect(new CornerPathEffect(cornerRadius));
    invalidate();
}
 
Example #25
Source File: MediaActionDrawable.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public MediaActionDrawable() {
    paint.setColor(0xffffffff);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setStrokeWidth(AndroidUtilities.dp(3));
    paint.setStyle(Paint.Style.STROKE);

    paint3.setColor(0xffffffff);

    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textPaint.setTextSize(AndroidUtilities.dp(13));
    textPaint.setColor(0xffffffff);

    paint2.setColor(0xffffffff);
    paint2.setPathEffect(new CornerPathEffect(AndroidUtilities.dp(2)));
}
 
Example #26
Source File: MediaActionDrawable.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public MediaActionDrawable() {
    paint.setColor(0xffffffff);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setStrokeWidth(AndroidUtilities.dp(3));
    paint.setStyle(Paint.Style.STROKE);

    paint3.setColor(0xffffffff);

    textPaint.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    textPaint.setTextSize(AndroidUtilities.dp(13));
    textPaint.setColor(0xffffffff);

    paint2.setColor(0xffffffff);
    paint2.setPathEffect(new CornerPathEffect(AndroidUtilities.dp(2)));
}
 
Example #27
Source File: ActivityEventView.java    From arcusandroid with Apache License 2.0 5 votes vote down vote up
protected void init(Context context) {
    canvasHeight = 1;
    canvasWidth = 1;

    // TODO: Set font typeface
    textPaintBrush.setColor(WHITE);
    textPaintBrush.setAlpha(sixtyPercent);
    setTextHeightInSP(11);

    eventPaintBrush.setColor(WHITE);
    // If this has an opacity may need to change the +1 for width so these don't overlap
    eventPaintBrush.setStyle(Paint.Style.STROKE);

    borderAndLinePaintBrush.setStrokeWidth(2);
    borderAndLinePaintBrush.setColor(WHITE);
    borderAndLinePaintBrush.setDither(true);
    borderAndLinePaintBrush.setStyle(Paint.Style.STROKE);
    borderAndLinePaintBrush.setStrokeJoin(Paint.Join.ROUND);
    borderAndLinePaintBrush.setStrokeCap(Paint.Cap.ROUND);
    borderAndLinePaintBrush.setPathEffect(new CornerPathEffect(10));
    borderAndLinePaintBrush.setAntiAlias(true);
    borderRectangle = new RectF();
    halfSolidLineStroke = borderAndLinePaintBrush.getStrokeWidth() / 2;

    alphaPaintBrush.setColor(BLACK);
    alphaPaintBrush.setStrokeWidth(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()));
    alphaPaintBrush.setStyle(Paint.Style.FILL);

    setSuperscriptScaleFactor(.65f);
    setAxisSizeDP(15);
    setBucketSize(5f);

    setEndTime(System.currentTimeMillis());
    setShouldDrawBorder(true);
    setShouldDrawAxis(false);
    setBorderRadius(5);

    setUseAxisAlpha(false);
    setUseContentAlpha(false);
}
 
Example #28
Source File: ColoringLoadingView.java    From ColoringLoading with Apache License 2.0 5 votes vote down vote up
private void initPaint() {
  mCharacterPaint = new Paint();
  mCharacterPaint.setColor(Color.BLACK);
  mCharacterPaint.setStyle(Paint.Style.STROKE);
  mCharacterPaint.setStrokeWidth(20);
  mCharacterPaint.setStrokeCap(Paint.Cap.ROUND);
  mCharacterPaint.setPathEffect(new CornerPathEffect(10));
  mCharacterPaint.setAntiAlias(true);

  mLoadingPaint = new Paint();
  mLoadingPaint.setColor(Color.BLACK);
  mLoadingPaint.setStrokeWidth(10);
  mLoadingPaint.setStyle(Paint.Style.STROKE);
  mLoadingPaint.setStrokeCap(Paint.Cap.ROUND);
  mLoadingPaint.setPathEffect(new CornerPathEffect(10));
  mLoadingPaint.setAntiAlias(true);

  mPencilPaint = new Paint();
  mPencilPaint.setStyle(Paint.Style.FILL);
  mPencilPaint.setColor(Color.BLACK);
  mPencilPaint.setAntiAlias(true);

  mColoringPaint = new Paint();
  mColoringPaint.setStyle(Paint.Style.STROKE);
  mColoringPaint.setStrokeWidth(30);
  mColoringPaint.setStrokeCap(Paint.Cap.ROUND);
  mColoringPaint.setAntiAlias(true);
  mColoringPaint.setColor(0xffF8C92C);

  mBackgroundPaint = new Paint();
  mBackgroundPaint.setStyle(Paint.Style.FILL);
  mBackgroundPaint.setAntiAlias(true);
  mBackgroundPaint.setColor(Color.WHITE);

  mShadowPaint = new Paint();
  mShadowPaint.setStyle(Paint.Style.FILL);
  mShadowPaint.setColor(0x70000000);
  mShadowPaint.setMaskFilter(new BlurMaskFilter(16, BlurMaskFilter.Blur.NORMAL));

}
 
Example #29
Source File: TreeView.java    From BackgroundView with Apache License 2.0 5 votes vote down vote up
private void init() {
    mPaint = new Paint();
    // 绘制贝塞尔曲线
    mPaint.setColor(mColor);
    mPaint.setStrokeWidth(8);
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setStyle(Paint.Style.FILL);
    mPaint.setTextSize(60);
    mPaint.setPathEffect(new CornerPathEffect(4));

}
 
Example #30
Source File: SparkView.java    From spark with Apache License 2.0 5 votes vote down vote up
/**
 * Set the corner radius in pixels to use when rounding the sparkline's segments. Passing 0
 * indicates that corners should not be rounded.
 */
public void setCornerRadius(float cornerRadius) {
    this.cornerRadius = cornerRadius;
    if (cornerRadius != 0) {
        sparkLinePaint.setPathEffect(new CornerPathEffect(cornerRadius));
        sparkFillPaint.setPathEffect(new CornerPathEffect(cornerRadius));
    } else {
        sparkLinePaint.setPathEffect(null);
        sparkFillPaint.setPathEffect(null);
    }
    invalidate();
}