Revision 43668bcc
Added by Leszek Koltunski 2 months ago
src/main/java/org/distorted/objectlib/main/TwistyObject.java | ||
---|---|---|
1466 | 1466 |
setCubitQuat(i,0); |
1467 | 1467 |
} |
1468 | 1468 |
} |
1469 |
|
|
1470 |
mTextureBorderMultiplier = os.getFloat(key+"_border", 1.0f); |
|
1471 |
mTextureCornerMultiplier = os.getFloat(key+"_corner", 1.0f); |
|
1472 |
String colors = os.getString(key+"_colors", null); |
|
1473 |
boolean different = false; |
|
1474 |
|
|
1475 |
if( colors!=null ) different = restoreColors(colors,mColorTable); |
|
1476 |
|
|
1477 |
if( different || mTextureBorderMultiplier!=1.0f || mTextureCornerMultiplier!=1.0f ) |
|
1478 |
{ |
|
1479 |
createTexture(mTextureBorderMultiplier,mTextureCornerMultiplier); |
|
1480 |
setTexture(); |
|
1481 |
} |
|
1469 | 1482 |
} |
1470 | 1483 |
|
1471 | 1484 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
1508 | 1521 |
return sb.toString(); |
1509 | 1522 |
} |
1510 | 1523 |
|
1524 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1525 |
|
|
1526 |
private boolean restoreColors(String colors, int[] table) |
|
1527 |
{ |
|
1528 |
String[] parts = colors.split(","); |
|
1529 |
int len = parts.length; |
|
1530 |
boolean ret = false; |
|
1531 |
|
|
1532 |
try |
|
1533 |
{ |
|
1534 |
for(int s=0; s<len; s++) |
|
1535 |
{ |
|
1536 |
table[s] = Integer.parseInt(parts[s]); |
|
1537 |
if( table[s]!=mOriginalColorTable[s] ) ret = true; |
|
1538 |
} |
|
1539 |
} |
|
1540 |
catch(NumberFormatException nfe) |
|
1541 |
{ |
|
1542 |
for(int s=0; s<len; s++) table[s] = mOriginalColorTable[s]; |
|
1543 |
return false; |
|
1544 |
} |
|
1545 |
|
|
1546 |
return ret; |
|
1547 |
} |
|
1548 |
|
|
1511 | 1549 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1512 | 1550 |
|
1513 | 1551 |
private float computeRadiusCorrection(float[][] sticker, int curr, int len) |
... | ... | |
1677 | 1715 |
return COLOR_INTERNAL; |
1678 | 1716 |
} |
1679 | 1717 |
|
1718 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1719 |
|
|
1720 |
public float getTextureBorders() |
|
1721 |
{ |
|
1722 |
return mTextureBorderMultiplier; |
|
1723 |
} |
|
1724 |
|
|
1725 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1726 |
|
|
1727 |
public float getTextureCorners() |
|
1728 |
{ |
|
1729 |
return mTextureCornerMultiplier; |
|
1730 |
} |
|
1731 |
|
|
1680 | 1732 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
1681 | 1733 |
// the getFaceColors + final INTERNAL_COLOR in a grid (so that we do not exceed the maximum texture size) |
1682 | 1734 |
|
1683 |
void createTexture(float borders, float corners)
|
|
1735 |
void createTexture(float border, float corner)
|
|
1684 | 1736 |
{ |
1685 | 1737 |
Paint paint = new Paint(); |
1686 | 1738 |
Canvas canvas = new Canvas(mBitmap); |
... | ... | |
1691 | 1743 |
paint.setColor(getInternalColor()); |
1692 | 1744 |
canvas.drawRect(0, 0, mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, paint); |
1693 | 1745 |
|
1694 |
mTextureBorderMultiplier = borders;
|
|
1695 |
mTextureCornerMultiplier = corners;
|
|
1746 |
mTextureBorderMultiplier = border; |
|
1747 |
mTextureCornerMultiplier = corner; |
|
1696 | 1748 |
|
1697 | 1749 |
int texture = 0; |
1698 | 1750 |
FactorySticker factory = FactorySticker.getInstance(); |
... | ... | |
1753 | 1805 |
if( mBitmap==null ) |
1754 | 1806 |
{ |
1755 | 1807 |
mBitmap = Bitmap.createBitmap( mNumTexCols*mTexHeight, mNumTexRows*mTexHeight, Bitmap.Config.ARGB_4444); |
1756 |
createTexture(1.0f,1.0f);
|
|
1808 |
createTexture(mTextureBorderMultiplier,mTextureCornerMultiplier);
|
|
1757 | 1809 |
} |
1758 | 1810 |
|
1759 | 1811 |
if( !mTexture.setTextureAlreadyInverted(mBitmap) ) |
Also available in: Unified diff
Restore the colors and sticker properties from Preferences.