mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-27 07:58:49 +01:00
do a better job of figuring out whether to use black or white to
outline blank tiles.
This commit is contained in:
parent
1f664fa9e8
commit
2ce4c1417c
1 changed files with 15 additions and 9 deletions
|
@ -515,7 +515,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (CELL_ISBLANK & flags) != 0 ) {
|
if ( (CELL_ISBLANK & flags) != 0 ) {
|
||||||
markBlank( rect, pending );
|
markBlank( rect, backColor );
|
||||||
}
|
}
|
||||||
|
|
||||||
// frame the cell
|
// frame the cell
|
||||||
|
@ -936,10 +936,22 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
return null != m_fontDims;
|
return null != m_fontDims;
|
||||||
} // figureFontDims
|
} // figureFontDims
|
||||||
|
|
||||||
private void markBlank( final Rect rect, boolean whiteOnBlack )
|
private boolean isLightColor( int color )
|
||||||
|
{
|
||||||
|
int sum = 0;
|
||||||
|
for ( int ii = 0; ii < 3; ++ii ) {
|
||||||
|
sum += color & 0xFF;
|
||||||
|
color >>= 8;
|
||||||
|
}
|
||||||
|
boolean result = sum > (127*3);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void markBlank( final Rect rect, int backColor )
|
||||||
{
|
{
|
||||||
RectF oval = new RectF( rect.left, rect.top, rect.right, rect.bottom );
|
RectF oval = new RectF( rect.left, rect.top, rect.right, rect.bottom );
|
||||||
int curColor = 0;
|
int curColor = 0;
|
||||||
|
boolean whiteOnBlack = !isLightColor( backColor );
|
||||||
if ( whiteOnBlack ) {
|
if ( whiteOnBlack ) {
|
||||||
curColor = m_strokePaint.getColor();
|
curColor = m_strokePaint.getColor();
|
||||||
m_strokePaint.setColor( WHITE );
|
m_strokePaint.setColor( WHITE );
|
||||||
|
@ -955,13 +967,7 @@ public class BoardView extends View implements DrawCtx, BoardHandler,
|
||||||
int background = m_otherColors[ CommonPrefs.COLOR_NOTILE ];
|
int background = m_otherColors[ CommonPrefs.COLOR_NOTILE ];
|
||||||
if ( background != m_backgroundUsed ) {
|
if ( background != m_backgroundUsed ) {
|
||||||
m_backgroundUsed = background;
|
m_backgroundUsed = background;
|
||||||
|
m_darkOnLight = isLightColor( background );
|
||||||
int sum = 0;
|
|
||||||
for ( int ii = 0; ii < 3; ++ii ) {
|
|
||||||
sum += background & 0xFF;
|
|
||||||
background >>= 8;
|
|
||||||
}
|
|
||||||
m_darkOnLight = sum > (127*3);
|
|
||||||
}
|
}
|
||||||
return m_darkOnLight;
|
return m_darkOnLight;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue