kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
Considered the outline in the text bounds calculation,
Renamed (forgotten) "border" to "outline", Removed one "inset" call in drawShadowpull/3/head
rodzic
c3368ecd81
commit
68701fc5a1
|
@ -47,7 +47,7 @@ class LabelPainter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void draw(Canvas canvas) {
|
public void draw(Canvas canvas) {
|
||||||
drawBorder(canvas, mX, mY);
|
drawOutline(canvas, mX, mY);
|
||||||
canvas.drawText(mLabel.getText(), mX, mY, mPaint);
|
canvas.drawText(mLabel.getText(), mX, mY, mPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,16 +66,15 @@ class LabelPainter {
|
||||||
mPaint.setAlpha(255);
|
mPaint.setAlpha(255);
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
|
|
||||||
mPaint.setColor(Color.RED);
|
mPaint.setColor(Color.BLUE);
|
||||||
bounds.inset(-5f, -5f);
|
|
||||||
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
||||||
|
|
||||||
mPaint.setColor(Color.GREEN);
|
mPaint.setColor(Color.GREEN);
|
||||||
bounds.inset(1f, 1f);
|
bounds.inset(-1f, -1f);
|
||||||
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
||||||
|
|
||||||
mPaint.setColor(Color.BLUE);
|
mPaint.setColor(Color.RED);
|
||||||
bounds.inset(1f, 1f);
|
bounds.inset(-1f, -1f);
|
||||||
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
canvas.drawRoundRect(bounds, rx, ry, mPaint);
|
||||||
|
|
||||||
setPaintSettings(mSizeFactor);
|
setPaintSettings(mSizeFactor);
|
||||||
|
@ -87,7 +86,7 @@ class LabelPainter {
|
||||||
float x = (mX - src.left) * factor;
|
float x = (mX - src.left) * factor;
|
||||||
float y = (mY - src.top) * factor;
|
float y = (mY - src.top) * factor;
|
||||||
setSizePaintSettings(factor * mSizeFactor);
|
setSizePaintSettings(factor * mSizeFactor);
|
||||||
drawBorder(canvas, x, y);
|
drawOutline(canvas, x, y);
|
||||||
canvas.drawText(mLabel.getText(), x, y, mPaint);
|
canvas.drawText(mLabel.getText(), x, y, mPaint);
|
||||||
setSizePaintSettings(mSizeFactor);
|
setSizePaintSettings(mSizeFactor);
|
||||||
}
|
}
|
||||||
|
@ -114,12 +113,16 @@ class LabelPainter {
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
String text = mLabel.getText();
|
String text = mLabel.getText();
|
||||||
mPaint.getTextBounds(text, 0, text.length(), bounds);
|
mPaint.getTextBounds(text, 0, text.length(), bounds);
|
||||||
|
if (mLabel.getOutline()) {
|
||||||
|
int dxOutline = (int) (mLabel.getOutlineSize() * mPaint.getTextSize()) / 2;
|
||||||
|
bounds.inset(-dxOutline, -dxOutline);
|
||||||
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawBorder(Canvas canvas, float x, float y) {
|
private void drawOutline(Canvas canvas, float x, float y) {
|
||||||
if (mLabel.getOutline()) {
|
if (mLabel.getOutline()) {
|
||||||
setBorderPaintSettings();
|
setOutlinePaintSettings();
|
||||||
canvas.drawText(mLabel.getText(), x, y, mPaint);
|
canvas.drawText(mLabel.getText(), x, y, mPaint);
|
||||||
setTextPaintSettings();
|
setTextPaintSettings();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +135,7 @@ class LabelPainter {
|
||||||
setSizePaintSettings(sizeFactor);
|
setSizePaintSettings(sizeFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBorderPaintSettings() {
|
private void setOutlinePaintSettings() {
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
mPaint.setColor(mLabel.getOutlineColor());
|
mPaint.setColor(mLabel.getOutlineColor());
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue