Project

General

Profile

« Previous | Next » 

Revision 7e8750c9

Added by Leszek Koltunski 2 months ago

progress with configurable stickers

View differences:

src/main/java/org/distorted/objectlib/main/TwistyObject.java
1239 1239
// figure out the whole face to which (cubit,face) belongs, repaint all (cubit,face) pairs to
1240 1240
// the new color.
1241 1241

  
1242
  void repaintPuzzleFace(int cubit, int face, int color)
1242
  void repaintPuzzleFace(int cubit, int face, int color, float borders, float corners)
1243 1243
    {
1244
    android.util.Log.e("D", "repainting: "+cubit+" "+face+" "+color);
1244
    int oldColorIndex = getCubitFaceColor(cubit,face);
1245
    int oldColor = getColor(oldColorIndex);
1246

  
1247
    if( oldColor!=color )
1248
      {
1249
      changeColorInTexture(borders,corners,oldColor,color);
1250
      setTexture();
1251
      }
1245 1252
    }
1246 1253

  
1247 1254
///////////////////////////////////////////////////////////////////////////////////////////////////
......
1656 1663
        }
1657 1664
    }
1658 1665

  
1666
///////////////////////////////////////////////////////////////////////////////////////////////////
1667

  
1668
  void changeColorInTexture(float borders, float corners, int oldColor, int newColor)
1669
    {
1670
    Paint paint = new Paint();
1671
    Canvas canvas = new Canvas(mBitmap);
1672
    paint.setAntiAlias(true);
1673
    int texture = 0;
1674
    FactorySticker factory = FactorySticker.getInstance();
1675

  
1676
    for(int row=0; row<mNumTexRows; row++)
1677
      for(int col=0; col<mNumTexCols; col++)
1678
        {
1679
        if( texture<mNumTextures-mNumOverrides )
1680
          {
1681
          int color = getColor(texture%mNumFaceColors);
1682

  
1683
          if( color==oldColor )
1684
            {
1685
            ObjectSticker sticker = retSticker(texture/mNumFaceColors);
1686
            factory.drawRoundedPolygons(canvas, paint, col*mTexHeight, (mNumTexRows-row)*mTexHeight, newColor, mTexHeight, sticker,borders,corners);
1687
            }
1688
          }
1689

  
1690
        texture++;
1691
        }
1692
    }
1693

  
1659 1694
///////////////////////////////////////////////////////////////////////////////////////////////////
1660 1695

  
1661 1696
  void setTexture()

Also available in: Unified diff