kopia lustrzana https://github.com/olgamiller/SSTVEncoder2
Made the corner radius of color boxes similar displayed on devices with different resolution
rodzic
80f872e14a
commit
780f641242
|
@ -40,20 +40,21 @@ class GridColorPalette implements IColorPalette {
|
||||||
private final static float STROKE_WIDTH_FACTOR = 6f;
|
private final static float STROKE_WIDTH_FACTOR = 6f;
|
||||||
private final static float BOX_SIZE_DP = 96f;
|
private final static float BOX_SIZE_DP = 96f;
|
||||||
private final static float SPACE_FACTOR = 6f;
|
private final static float SPACE_FACTOR = 6f;
|
||||||
private final static float CORNER_RADIUS = 6f;
|
|
||||||
private final int[] mColorList;
|
private final int[] mColorList;
|
||||||
private final Paint mPaint;
|
private final Paint mPaint;
|
||||||
private final RectF mSelectedBounds;
|
private final RectF mSelectedBounds;
|
||||||
private final float mDisplayMetricsDensity;
|
private final float mDisplayMetricsDensity;
|
||||||
private int mColumns, mRows;
|
private int mColumns, mRows;
|
||||||
private float mWidth, mHeight;
|
private float mWidth, mHeight;
|
||||||
private float mBoxSize, mSpace, mStrokeWidth;
|
private float mBoxSize, mSpace, mStrokeWidth, mCornerRadius;
|
||||||
private int mSelectedColorIndex;
|
private int mSelectedColorIndex;
|
||||||
private boolean mValid;
|
private boolean mValid;
|
||||||
|
|
||||||
GridColorPalette(int[] colorList, float displayMetricsDensity) {
|
GridColorPalette(int[] colorList, float displayMetricsDensity) {
|
||||||
|
final float CORNER_RADIUS = 3f;
|
||||||
mColorList = colorList;
|
mColorList = colorList;
|
||||||
mDisplayMetricsDensity = displayMetricsDensity;
|
mDisplayMetricsDensity = displayMetricsDensity;
|
||||||
|
mCornerRadius = CORNER_RADIUS * mDisplayMetricsDensity;
|
||||||
mPaint = new Paint();
|
mPaint = new Paint();
|
||||||
setPaintStyleForBox();
|
setPaintStyleForBox();
|
||||||
mSelectedBounds = new RectF();
|
mSelectedBounds = new RectF();
|
||||||
|
@ -115,7 +116,7 @@ class GridColorPalette implements IColorPalette {
|
||||||
for (int color : mColorList) {
|
for (int color : mColorList) {
|
||||||
RectF rect = new RectF(x, y, x + mBoxSize, y + mBoxSize);
|
RectF rect = new RectF(x, y, x + mBoxSize, y + mBoxSize);
|
||||||
mPaint.setColor(color);
|
mPaint.setColor(color);
|
||||||
canvas.drawRoundRect(rect, CORNER_RADIUS, CORNER_RADIUS, mPaint);
|
canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint);
|
||||||
x += mBoxSize + mSpace;
|
x += mBoxSize + mSpace;
|
||||||
if (x > maxX) {
|
if (x > maxX) {
|
||||||
x = mSpace;
|
x = mSpace;
|
||||||
|
@ -134,7 +135,7 @@ class GridColorPalette implements IColorPalette {
|
||||||
RectF rect = new RectF(l - padding, t - padding, r + padding, b + padding);
|
RectF rect = new RectF(l - padding, t - padding, r + padding, b + padding);
|
||||||
Paint.Style paintStyle = mPaint.getStyle();
|
Paint.Style paintStyle = mPaint.getStyle();
|
||||||
setPaintStyleForSelectedBox();
|
setPaintStyleForSelectedBox();
|
||||||
canvas.drawRoundRect(rect, CORNER_RADIUS, CORNER_RADIUS, mPaint);
|
canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint);
|
||||||
mPaint.setStyle(paintStyle);
|
mPaint.setStyle(paintStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue