android.graphics.Paint.Join Java Examples

The following examples show how to use android.graphics.Paint.Join. 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: MultiBoxTracker.java    From tfliteSSDminimalWorkingExample with Apache License 2.0 6 votes vote down vote up
public MultiBoxTracker(final Context context) {
	this.context = context;
	for (final int color : COLORS) {
		availableColors.add(color);
	}

	boxPaint.setColor(Color.RED);
	boxPaint.setStyle(Style.STROKE);
	boxPaint.setStrokeWidth(12.0f);
	boxPaint.setStrokeCap(Cap.ROUND);
	boxPaint.setStrokeJoin(Join.ROUND);
	boxPaint.setStrokeMiter(100);

	textSizePx =
			TypedValue.applyDimension(
					TypedValue.COMPLEX_UNIT_DIP, TEXT_SIZE_DIP, context.getResources().getDisplayMetrics());
	borderedText = new BorderedText(textSizePx);
}
 
Example #2
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 6 votes vote down vote up
public void UpdateCanvas() {
    canvasMaster.drawColor(0, Mode.CLEAR);
    canvasMaster.drawBitmap(lastEditedBitmap, 0.0f, 0.0f, null);
    int i = 0;
    while (true) {
        if (i >= paths.size()) {
            break;
        }
        int brushSize = brushSizes.get(i);
        Paint paint = new Paint();
        paint.setColor(0);
        paint.setStyle(Style.STROKE);
        paint.setAntiAlias(true);
        paint.setStrokeJoin(Join.ROUND);
        paint.setStrokeCap(Cap.ROUND);
        paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
        paint.setStrokeWidth((float) brushSize);
        canvasMaster.drawPath(paths.get(i), paint);
        i += 1;
    }
    touchImageView.invalidate();
}
 
Example #3
Source File: SmoothGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private SmoothGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;
    
    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);

    pathStroke = new Path();
    pathFill = new Path();
}
 
Example #4
Source File: StaticGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private StaticGraph(final int color, final float width, final float height, final float strokeWidth)
{
    this.height = height;
    this.width = width;
    
    pathStroke = new Path();
    pathFill = new Path();
    paintStroke = new Paint();
    paintFill = new Paint();
    
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
}
 
Example #5
Source File: SimpleGraph.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
private SimpleGraph(final int color, final long maxNsecs, final float width, final float height, final float strokeWidth)
{
    this.maxNsecs = maxNsecs;
    // this.width = width;
    this.height = height;
    nsecWidth = width / maxNsecs;
    
    paintStroke = new Paint();
    paintStroke.setColor(color);
    paintStroke.setAlpha(204); // 80%
    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeWidth(strokeWidth);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setAntiAlias(true);
    
    paintFill = new Paint();
    paintFill.setColor(color);
    paintFill.setAlpha(51); // 20%
    paintFill.setStyle(Style.FILL);
    paintFill.setAntiAlias(true);
    
    pathStroke = new Path();
    pathFill = new Path();
}
 
Example #6
Source File: ColorPicker.java    From SystemBarTint with Apache License 2.0 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    }
 
Example #7
Source File: MidView.java    From FimiX8-RE with MIT License 5 votes vote down vote up
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    this.canvas = canvas;
    this.paint.setStrokeWidth(8.0f);
    this.paint.setAntiAlias(true);
    this.paint.setStyle(Style.FILL);
    this.paint.setStrokeJoin(Join.ROUND);
    if (this.clean) {
        this.clean = false;
        removeAll(canvas);
        recycle(this.birmapbg, this.ringbg);
        canvas.drawBitmap(this.birmapbg, 0.0f, 0.0f, this.paint);
        this.paint.setColor(getResources().getColor(R.color.white_100));
        canvas.drawBitmap(this.ringbg, this.endX - this.radius, this.endY - this.radius, this.paint);
        return;
    }
    if (this.joyOkay) {
        this.joyOkay = false;
        removeAll(canvas);
        recycle(this.birmapbg, this.ringbg);
        canvas.drawBitmap(this.rtBmp, 0.0f, 0.0f, this.paint);
    } else {
        canvas.drawBitmap(this.birmapbg, 0.0f, 0.0f, this.paint);
        this.paint.setColor(getResources().getColor(R.color.white_100));
        canvas.drawLine(this.centerX, this.centerY, this.centerX, this.endY, this.paint);
        canvas.drawLine(this.centerX, this.centerY, this.endX, this.centerY, this.paint);
        clipPath(this.type);
        canvas.drawBitmap(this.ringbg, this.endX - this.radius, this.endY - this.radius, this.paint);
    }
    recycle(this.birmapbg, this.ringbg, this.rtBmp);
}
 
Example #8
Source File: MultiColorPicker.java    From Android-Color-Picker with Apache License 2.0 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    }
 
Example #9
Source File: ColorPicker.java    From Android-Color-Picker with Apache License 2.0 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    }
 
Example #10
Source File: ModifierRenderer.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
private static void drawDOMArrow(Canvas ctx, Point[] domPoints, int alpha, Color lineColor)
{
    Paint domPaint = new Paint();
    domPaint.setStrokeCap(Cap.BUTT);
    domPaint.setStrokeJoin(Join.MITER);
    domPaint.setStrokeWidth(3);
    domPaint.setColor(lineColor.toInt());
    domPaint.setStyle(Style.STROKE);
    if(alpha > -1)
        domPaint.setAlpha(alpha);

    Path domPath = new Path();
    domPath.moveTo(domPoints[0].x, domPoints[0].y);
    if (domPoints[1] != null)
    {
        domPath.lineTo(domPoints[1].x, domPoints[1].y);
    }
    if (domPoints[2] != null)
    {
        domPath.lineTo(domPoints[2].x, domPoints[2].y);
    }
    ctx.drawPath(domPath, domPaint);

    domPath.reset();
    domPaint.setStyle(Style.FILL);
    domPath.moveTo(domPoints[3].x, domPoints[3].y);
    domPath.lineTo(domPoints[4].x, domPoints[4].y);
    domPath.lineTo(domPoints[5].x, domPoints[5].y);
    ctx.drawPath(domPath, domPaint);
}
 
Example #11
Source File: PXSVGLoader.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
private static Join lineJoinFromString(String value) {
    if (value == null) {
        return Join.MITER;
    }
    Join join = Join.valueOf(value.toUpperCase(Locale.US));
    if (join == null) {
        PXLog.e(TAG, "Unrecognized line join: " + value);
    }
    return join;
}
 
Example #12
Source File: PXStroke.java    From pixate-freestyle-android with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new PX stroke.
 */
public PXStroke() {
    this.type = PXStrokeType.CENTER;
    this.width = 1.0f;
    this.dashOffset = 0;
    this.lineCap = Cap.BUTT;
    this.lineJoin = Join.MITER;
    this.miterLimit = 4.0f; // What is a reasonable default here?
}
 
Example #13
Source File: ColorPicker.java    From redalert-android with Apache License 2.0 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    }
 
Example #14
Source File: ColorPicker.java    From Mi-Band with GNU General Public License v2.0 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

    }
 
Example #15
Source File: CellContainer.java    From openlauncher with Apache License 2.0 5 votes vote down vote up
public CellContainer(Context context, AttributeSet attr) {
    super(context, attr);
    _paint.setStyle(Style.STROKE);
    _paint.setStrokeWidth(2.0f);
    _paint.setStrokeJoin(Join.ROUND);
    _paint.setColor(Color.WHITE);
    _paint.setAlpha(0);
    _bgPaint.setStyle(Style.FILL);
    _bgPaint.setColor(Color.WHITE);
    _bgPaint.setAlpha(0);
    _outlinePaint.setColor(Color.WHITE);
    _outlinePaint.setAlpha(0);
    init();
}
 
Example #16
Source File: ColorPicker.java    From px-android with MIT License 5 votes vote down vote up
private void drawPointerArrow(Canvas canvas) {

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;

        double tipAngle = (colorHSV[2] - 0.5f) * Math.PI;
        double leftAngle = tipAngle + Math.PI / 96;
        double rightAngle = tipAngle - Math.PI / 96;

        double tipAngleX = Math.cos(tipAngle) * outerWheelRadius;
        double tipAngleY = Math.sin(tipAngle) * outerWheelRadius;
        double leftAngleX = Math.cos(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double leftAngleY = Math.sin(leftAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleX = Math.cos(rightAngle) * (outerWheelRadius + arrowPointerSize);
        double rightAngleY = Math.sin(rightAngle) * (outerWheelRadius + arrowPointerSize);

        arrowPointerPath.reset();
        arrowPointerPath.moveTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);
        arrowPointerPath.lineTo((float) leftAngleX + centerX, (float) leftAngleY + centerY);
        arrowPointerPath.lineTo((float) rightAngleX + centerX, (float) rightAngleY + centerY);
        arrowPointerPath.lineTo((float) tipAngleX + centerX, (float) tipAngleY + centerY);

        valuePointerArrowPaint.setColor(Color.HSVToColor(colorHSV));
        valuePointerArrowPaint.setStyle(Style.FILL);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);

        valuePointerArrowPaint.setStyle(Style.STROKE);
        valuePointerArrowPaint.setStrokeJoin(Join.ROUND);
        valuePointerArrowPaint.setColor(Color.BLACK);
        canvas.drawPath(arrowPointerPath, valuePointerArrowPaint);
    }
 
Example #17
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 5 votes vote down vote up
public void UpdateLastEiditedBitmapForUndoLimit() {
    Canvas canvas = new Canvas(lastEditedBitmap);
    for (int i = 0; i < 1; i += 1) {
        int brushSize = brushSizes.get(i);
        Paint paint = new Paint();
        paint.setColor(0);
        paint.setStyle(Style.STROKE);
        paint.setAntiAlias(true);
        paint.setStrokeJoin(Join.ROUND);
        paint.setStrokeCap(Cap.ROUND);
        paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
        paint.setStrokeWidth((float) brushSize);
        canvas.drawPath(paths.get(i), paint);
    }
}
 
Example #18
Source File: MainActivity.java    From ImageEraser with GNU General Public License v3.0 5 votes vote down vote up
private void drawOnTouchMove() {
    Paint paint = new Paint();
    paint.setStrokeWidth((float) updatedBrushSize);
    paint.setColor(0);
    paint.setStyle(Style.STROKE);
    paint.setAntiAlias(true);
    paint.setStrokeJoin(Join.ROUND);
    paint.setStrokeCap(Cap.ROUND);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC));
    canvasMaster.drawPath(drawingPath, paint);
    touchImageView.invalidate();
}
 
Example #19
Source File: SubtitleView.java    From Exoplayer_VLC with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas c) {
  final StaticLayout layout = this.layout;
  if (layout == null) {
    return;
  }

  final int saveCount = c.save();
  final int innerPaddingX = this.innerPaddingX;
  c.translate(getPaddingLeft() + innerPaddingX, getPaddingTop());

  final int lineCount = layout.getLineCount();
  final Paint textPaint = this.textPaint;
  final Paint paint = this.paint;
  final RectF bounds = lineBounds;

  if (Color.alpha(backgroundColor) > 0) {
    final float cornerRadius = this.cornerRadius;
    float previousBottom = layout.getLineTop(0);

    paint.setColor(backgroundColor);
    paint.setStyle(Style.FILL);

    for (int i = 0; i < lineCount; i++) {
      bounds.left = layout.getLineLeft(i) - innerPaddingX;
      bounds.right = layout.getLineRight(i) + innerPaddingX;
      bounds.top = previousBottom;
      bounds.bottom = layout.getLineBottom(i);
      previousBottom = bounds.bottom;

      c.drawRoundRect(bounds, cornerRadius, cornerRadius, paint);
    }
  }

  if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
    textPaint.setStrokeJoin(Join.ROUND);
    textPaint.setStrokeWidth(outlineWidth);
    textPaint.setColor(edgeColor);
    textPaint.setStyle(Style.FILL_AND_STROKE);
    layout.draw(c);
  } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
    textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
  } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
      || edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
    boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
    int colorUp = raised ? Color.WHITE : edgeColor;
    int colorDown = raised ? edgeColor : Color.WHITE;
    float offset = shadowRadius / 2f;
    textPaint.setColor(foregroundColor);
    textPaint.setStyle(Style.FILL);
    textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
    layout.draw(c);
    textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
  }

  textPaint.setColor(foregroundColor);
  textPaint.setStyle(Style.FILL);
  layout.draw(c);
  textPaint.setShadowLayer(0, 0, 0, 0);
  c.restoreToCount(saveCount);
}
 
Example #20
Source File: PXStroke.java    From pixate-freestyle-android with Apache License 2.0 4 votes vote down vote up
/**
 * @return the lineJoin
 */
public Join getLineJoin() {
    return lineJoin;
}
 
Example #21
Source File: PXStroke.java    From pixate-freestyle-android with Apache License 2.0 4 votes vote down vote up
/**
 * @param lineJoin the lineJoin to set
 */
public void setLineJoin(Join lineJoin) {
    this.lineJoin = lineJoin;
}
 
Example #22
Source File: SubtitlePainter.java    From K-Sonic with MIT License 4 votes vote down vote up
private void drawTextLayout(Canvas canvas) {
  StaticLayout layout = textLayout;
  if (layout == null) {
    // Nothing to draw.
    return;
  }

  int saveCount = canvas.save();
  canvas.translate(textLeft, textTop);

  if (Color.alpha(windowColor) > 0) {
    paint.setColor(windowColor);
    canvas.drawRect(-textPaddingX, 0, layout.getWidth() + textPaddingX, layout.getHeight(),
        paint);
  }

  if (Color.alpha(backgroundColor) > 0) {
    paint.setColor(backgroundColor);
    float previousBottom = layout.getLineTop(0);
    int lineCount = layout.getLineCount();
    for (int i = 0; i < lineCount; i++) {
      lineBounds.left = layout.getLineLeft(i) - textPaddingX;
      lineBounds.right = layout.getLineRight(i) + textPaddingX;
      lineBounds.top = previousBottom;
      lineBounds.bottom = layout.getLineBottom(i);
      previousBottom = lineBounds.bottom;
      canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
    }
  }

  if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
    textPaint.setStrokeJoin(Join.ROUND);
    textPaint.setStrokeWidth(outlineWidth);
    textPaint.setColor(edgeColor);
    textPaint.setStyle(Style.FILL_AND_STROKE);
    layout.draw(canvas);
  } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
    textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
  } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
      || edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
    boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
    int colorUp = raised ? Color.WHITE : edgeColor;
    int colorDown = raised ? edgeColor : Color.WHITE;
    float offset = shadowRadius / 2f;
    textPaint.setColor(foregroundColor);
    textPaint.setStyle(Style.FILL);
    textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
    layout.draw(canvas);
    textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
  }

  textPaint.setColor(foregroundColor);
  textPaint.setStyle(Style.FILL);
  layout.draw(canvas);
  textPaint.setShadowLayer(0, 0, 0, 0);

  canvas.restoreToCount(saveCount);
}
 
Example #23
Source File: SubtitlePainter.java    From no-player with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("PMD.NPathComplexity")  // TODO break this method up
private void drawTextLayout(Canvas canvas) {
    StaticLayout layout = textLayout;
    if (layout == null) {
        // Nothing to draw.
        return;
    }

    int saveCount = canvas.save();
    canvas.translate(textLeft, textTop);

    if (Color.alpha(windowColor) > 0) {
        paint.setColor(windowColor);
        canvas.drawRect(-textPaddingX, 0, layout.getWidth() + textPaddingX, layout.getHeight(),
                paint);
    }

    if (Color.alpha(backgroundColor) > 0) {
        paint.setColor(backgroundColor);
        float previousBottom = layout.getLineTop(0);
        int lineCount = layout.getLineCount();
        for (int i = 0; i < lineCount; i++) {
            lineBounds.left = layout.getLineLeft(i) - textPaddingX;
            lineBounds.right = layout.getLineRight(i) + textPaddingX;
            lineBounds.top = previousBottom;
            lineBounds.bottom = layout.getLineBottom(i);
            previousBottom = lineBounds.bottom;
            canvas.drawRoundRect(lineBounds, cornerRadius, cornerRadius, paint);
        }
    }

    if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
        textPaint.setStrokeJoin(Join.ROUND);
        textPaint.setStrokeWidth(outlineWidth);
        textPaint.setColor(edgeColor);
        textPaint.setStyle(Style.FILL_AND_STROKE);
        layout.draw(canvas);
    } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_DROP_SHADOW) {
        textPaint.setShadowLayer(shadowRadius, shadowOffset, shadowOffset, edgeColor);
    } else if (edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED
            || edgeType == CaptionStyleCompat.EDGE_TYPE_DEPRESSED) {
        boolean raised = edgeType == CaptionStyleCompat.EDGE_TYPE_RAISED;
        int colorUp = raised ? Color.WHITE : edgeColor;
        int colorDown = raised ? edgeColor : Color.WHITE;
        float offset = shadowRadius / 2;
        textPaint.setColor(foregroundColor);
        textPaint.setStyle(Style.FILL);
        textPaint.setShadowLayer(shadowRadius, -offset, -offset, colorUp);
        layout.draw(canvas);
        textPaint.setShadowLayer(shadowRadius, offset, offset, colorDown);
    }

    textPaint.setColor(foregroundColor);
    textPaint.setStyle(Style.FILL);
    layout.draw(canvas);
    textPaint.setShadowLayer(0, 0, 0, 0);

    canvas.restoreToCount(saveCount);
}