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/ObjectControl.java
901 901

  
902 902
///////////////////////////////////////////////////////////////////////////////////////////////////
903 903

  
904
    public void repaintPuzzleFace(int cubit, int face, int color)
904
    public void repaintPuzzleFace(int cubit, int face, int color, float borders, float corners)
905 905
      {
906
      mPreRender.repaintPuzzleFace(cubit,face,color);
906
      mPreRender.repaintPuzzleFace(cubit,face,color,borders,corners);
907 907
      }
908 908

  
909 909
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objectlib/main/ObjectPreRender.java
60 60
  private float mFinishAngle, mAvgSpeed;
61 61
  private long mScrambleStartTime, mScrambleEndTime;
62 62
  private int mIconMode;
63
  private float mTextureBorders, mTextureCorners;
63 64

  
64 65
  // debugging only
65 66
  private long mAddRotationTime;
......
389 390
  private void repaintPuzzleFaceNow()
390 391
    {
391 392
    mRepaintPuzzleFace = false;
392
    if( mNewObject!=null ) mNewObject.repaintPuzzleFace(mCubit,mFace,mNewColor);
393
    if( mNewObject!=null ) mNewObject.repaintPuzzleFace(mCubit,mFace,mNewColor,mTextureBorders,mTextureCorners);
393 394
    }
394 395

  
395 396
///////////////////////////////////////////////////////////////////////////////////////////////////
......
472 473

  
473 474
///////////////////////////////////////////////////////////////////////////////////////////////////
474 475

  
475
  public void repaintPuzzleFace(int cubit, int face, int newColor)
476
  public void repaintPuzzleFace(int cubit, int face, int newColor, float borders, float corners)
476 477
    {
477 478
    mRepaintPuzzleFace = true;
478 479

  
479 480
    mCubit    = cubit;
480 481
    mFace     = face;
481 482
    mNewColor = newColor;
483
    mTextureBorders = borders;
484
    mTextureCorners = corners;
482 485
    }
483 486

  
484 487
///////////////////////////////////////////////////////////////////////////////////////////////////
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