Project

General

Profile

« Previous | Next » 

Revision 9c06394a

Added by Leszek Koltunski almost 3 years ago

Standarize drawing stickers of a twisty puzzle. From now on, there's no 'sticker drawing' code in the individual classes, only some constants.

View differences:

src/main/java/org/distorted/objects/TwistyRedi.java
20 20
package org.distorted.objects;
21 21

  
22 22
import android.content.res.Resources;
23
import android.graphics.Canvas;
24
import android.graphics.Paint;
25 23

  
26 24
import org.distorted.helpers.FactoryCubit;
27
import org.distorted.helpers.FactorySticker;
25
import org.distorted.helpers.ObjectSticker;
28 26
import org.distorted.library.effect.MatrixEffectQuaternion;
29 27
import org.distorted.library.main.DistortedEffects;
30 28
import org.distorted.library.main.DistortedTexture;
......
195 193
  private static int[] mPossibleAxis, mPossibleLayers;
196 194
  private static int[] mNumOccurences;
197 195

  
196
  private static final ObjectSticker[] mStickers;
197

  
198
  static
199
    {
200
    mStickers = new ObjectSticker[STICKERS.length];
201
    final float R0 = 0.09f;
202
    final float R1 = 0.06f;
203
    final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1,R1} };
204
    final float[] strokes = { 0.09f,0.06f };
205

  
206
    for(int s=0; s<STICKERS.length; s++)
207
      {
208
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
209
      }
210
    }
211

  
198 212
///////////////////////////////////////////////////////////////////////////////////////////////////
199 213

  
200 214
  TwistyRedi(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
372 386

  
373 387
///////////////////////////////////////////////////////////////////////////////////////////////////
374 388

  
375
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
389
  int getColor(int face)
376 390
    {
377
    int COLORS = FACE_COLORS.length;
378
    int stickerType = face/COLORS;
379
    float R,S;
391
    return FACE_COLORS[face];
392
    }
380 393

  
381
    switch(stickerType)
382
      {
383
      case 0:  R = 0.09f; S = 0.09f; break;
384
      case 1:  R = 0.06f; S = 0.06f; break;
385
      default: R = 0.00f; S = 0.00f; break;
386
      }
387
    float[] RS = new float[] {R,R,R,R};
388
    FactorySticker factory = FactorySticker.getInstance();
389
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
394
///////////////////////////////////////////////////////////////////////////////////////////////////
395

  
396
  ObjectSticker retSticker(int face)
397
    {
398
    return mStickers[face/NUM_FACES];
390 399
    }
391 400

  
392 401
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff