Project

General

Profile

« Previous | Next » 

Revision 9c06394a

Added by Leszek Koltunski over 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/helpers/FactorySticker.java
249 249
///////////////////////////////////////////////////////////////////////////////////////////////////
250 250
// PUBLIC
251 251

  
252
  public void drawRoundedPolygon(Canvas canvas, Paint paint, int left, int top, float[] vertices, float[] angles, float stroke, int color, float[] radii)
252
  public void drawRoundedPolygon(Canvas canvas, Paint paint, int left, int top, int color, ObjectSticker sticker)
253 253
    {
254
    float stroke = sticker.getStroke();
255
    float[] vertices = sticker.getCoords();
256
    float[] angles = sticker.getCurvature();
257
    float[] radii = sticker.getRadii();
258

  
254 259
    stroke *= TEXTURE_HEIGHT;
255 260

  
256 261
    paint.setAntiAlias(true);
src/main/java/org/distorted/helpers/ObjectSticker.java
1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

  
20
package org.distorted.helpers;
21

  
22
///////////////////////////////////////////////////////////////////////////////////////////////////
23

  
24
public class ObjectSticker
25
  {
26
  private final float[] mCoords;
27
  private final float[] mCurvature;
28
  private final float[] mRadii;
29
  private final float mStroke;
30

  
31
///////////////////////////////////////////////////////////////////////////////////////////////////
32

  
33
  public ObjectSticker(float[] coords, float[] curvature, float[] radii, float stroke)
34
    {
35
    mCoords    = coords;
36
    mCurvature = curvature;
37
    mRadii     = radii;
38
    mStroke    = stroke;
39
    }
40

  
41
///////////////////////////////////////////////////////////////////////////////////////////////////
42

  
43
  public float[] getCoords()
44
    {
45
    return mCoords;
46
    }
47

  
48
///////////////////////////////////////////////////////////////////////////////////////////////////
49

  
50
  public float[] getCurvature()
51
    {
52
    return mCurvature;
53
    }
54

  
55
///////////////////////////////////////////////////////////////////////////////////////////////////
56

  
57
  public float[] getRadii()
58
    {
59
    return mRadii;
60
    }
61

  
62
///////////////////////////////////////////////////////////////////////////////////////////////////
63

  
64
  public float getStroke()
65
    {
66
    return mStroke;
67
    }
68
  }
src/main/java/org/distorted/objects/TwistyBandagedAbstract.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.effect.VertexEffect;
30 28
import org.distorted.library.effect.VertexEffectMove;
......
137 135

  
138 136
  private static final int NUM_STICKERS = mStickerDimensions.length;
139 137

  
138
  private static final ObjectSticker[] mStickers;
139

  
140 140
  private static MeshBase[] mMeshes;
141 141

  
142
  static
143
    {
144
    mStickers = new ObjectSticker[NUM_STICKERS];
145

  
146
    for(int s=0; s<NUM_STICKERS; s++)
147
      {
148
      float X = mStickerDimensions[s][0];
149
      float Y = mStickerDimensions[s][1];
150
      float MAX = Math.max(X,Y);
151
      X /= (2*MAX);
152
      Y /= (2*MAX);
153

  
154
      float R = 0.10f / MAX;
155
      float S = 0.08f / MAX;
156
      float[] coords = { -X,-Y, +X,-Y, +X,+Y, -X,+Y};
157
      float[] radii = new float[] {R,R,R,R};
158
      mStickers[s] = new ObjectSticker(coords,null,radii,S);
159
      }
160
    }
161

  
142 162
///////////////////////////////////////////////////////////////////////////////////////////////////
143 163

  
144 164
  TwistyBandagedAbstract(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
368 388

  
369 389
///////////////////////////////////////////////////////////////////////////////////////////////////
370 390

  
371
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
391
  int getColor(int face)
392
    {
393
    return FACE_COLORS[face];
394
    }
395

  
396
///////////////////////////////////////////////////////////////////////////////////////////////////
397

  
398
  ObjectSticker retSticker(int face)
372 399
    {
373
    int numFaces = FACE_COLORS.length;
374
    int stickerType = face/numFaces;
375
    int color = face%numFaces;
376
    float X = mStickerDimensions[stickerType][0];
377
    float Y = mStickerDimensions[stickerType][1];
378
    float MAX = Math.max(X,Y);
379
    float R = 0.10f / MAX;
380
    float S = 0.08f / MAX;
381
    float[] RS = new float[] {R,R,R,R};
382
    X /= (2*MAX);
383
    Y /= (2*MAX);
384

  
385
    float[] vertices = { -X,-Y, +X,-Y, +X,+Y, -X,+Y};
386

  
387
    FactorySticker factory = FactorySticker.getInstance();
388
    factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[color], RS);
400
    return mStickers[face/NUM_FACES];
389 401
    }
390 402

  
391 403
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyCube.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.main.DistortedEffects;
29 27
import org.distorted.library.main.DistortedTexture;
30 28
import org.distorted.library.mesh.MeshBase;
......
120 118
              { -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f }
121 119
          };
122 120

  
121
  private static final ObjectSticker[] mStickers;
122

  
123 123
  private static MeshBase[] mMeshes;
124 124

  
125
  static
126
    {
127
    final float radius = 0.10f;
128
    final float stroke = 0.08f;
129
    final float[] radii = {radius,radius,radius,radius};
130
    mStickers = new ObjectSticker[STICKERS.length];
131
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke );
132
    }
133

  
125 134
///////////////////////////////////////////////////////////////////////////////////////////////////
126 135

  
127 136
  TwistyCube(int size, Static4D quat, DistortedTexture texture,
......
179 188

  
180 189
///////////////////////////////////////////////////////////////////////////////////////////////////
181 190

  
182
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
191
  int getColor(int face)
183 192
    {
184
    float R = 0.10f;
185
    float S = 0.08f;
186
    float[] RS = new float[] {R,R,R,R};
193
    return FACE_COLORS[face];
194
    }
195

  
196
///////////////////////////////////////////////////////////////////////////////////////////////////
187 197

  
188
    FactorySticker factory = FactorySticker.getInstance();
189
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
198
  ObjectSticker retSticker(int face)
199
    {
200
    return mStickers[face/NUM_FACES];
190 201
    }
191 202

  
192 203
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDiamond.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;
......
138 136
             { -0.4330127f, -0.25f, 0.4330127f, -0.25f, 0.0f, 0.5f }
139 137
          };
140 138

  
139
  private static final ObjectSticker[] mStickers;
140

  
141 141
  private static MeshBase[] mMeshes;
142 142

  
143
  static
144
    {
145
    float radius = 0.06f;
146
    float stroke = 0.07f;
147
    float[] radii = new float[] {radius,radius,radius};
148
    mStickers = new ObjectSticker[STICKERS.length];
149
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
150
    }
151

  
143 152
///////////////////////////////////////////////////////////////////////////////////////////////////
144 153

  
145 154
  TwistyDiamond(int size, Static4D quat, DistortedTexture texture,
......
491 500

  
492 501
///////////////////////////////////////////////////////////////////////////////////////////////////
493 502

  
494
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
503
  int getColor(int face)
495 504
    {
496
    float R = 0.06f;
497
    float S = 0.07f;
498
    float[] RS = new float[] {R,R,R};
505
    return FACE_COLORS[face];
506
    }
507

  
508
///////////////////////////////////////////////////////////////////////////////////////////////////
499 509

  
500
    FactorySticker factory = FactorySticker.getInstance();
501
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
510
  ObjectSticker retSticker(int face)
511
    {
512
    return mStickers[face/NUM_FACES];
502 513
    }
503 514

  
504 515
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyDino.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;
......
105 103
             {3,2,0},
106 104
          };
107 105

  
106
  private static MeshBase[] mMeshes;
107

  
108 108
  private static final float[][] STICKERS = new float[][]
109 109
          {
110 110
             { 0.0f, -1.0f/3, 0.5f, 1.0f/6, -0.5f, 1.0f/6 }
111 111
          };
112 112

  
113
  private static MeshBase[] mMeshes;
113
  private static final ObjectSticker[] mStickers;
114

  
115
  static
116
    {
117
    float radius = 0.025f;
118
    float stroke = 0.050f;
119
    float[] radii = new float[] {radius,radius,radius};
120
    mStickers = new ObjectSticker[STICKERS.length];
121
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
122
    }
114 123

  
115 124
///////////////////////////////////////////////////////////////////////////////////////////////////
116 125

  
......
213 222

  
214 223
///////////////////////////////////////////////////////////////////////////////////////////////////
215 224

  
216
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
225
  int getColor(int face)
217 226
    {
218
    float R = 0.025f;
219
    float S = 0.05f;
220
    float[] RS = new float[] {R,R,R};
227
    return FACE_COLORS[face];
228
    }
221 229

  
222
    FactorySticker factory = FactorySticker.getInstance();
223
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
230
///////////////////////////////////////////////////////////////////////////////////////////////////
231

  
232
  ObjectSticker retSticker(int face)
233
    {
234
    return mStickers[face/NUM_FACES];
224 235
    }
225 236

  
226 237
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyHelicopter.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;
......
223 221
            { 2,0,3 }
224 222
          };
225 223

  
224
  private static MeshBase[] mMeshes;
225

  
226 226
  private static final float[][] STICKERS = new float[][]
227 227
          {
228 228
            { -0.5f, 0.25f, 0.25f, -0.5f, 0.25f, 0.25f }
229 229
          };
230 230

  
231
  private static MeshBase[] mMeshes;
231
  private static final ObjectSticker[] mStickers;
232

  
233
  static
234
    {
235
    float radius = 0.03f;
236
    float stroke = 0.05f;
237
    float[] radii = new float[] {radius,radius,radius};
238
    mStickers = new ObjectSticker[STICKERS.length];
239
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
240
    }
232 241

  
233 242
///////////////////////////////////////////////////////////////////////////////////////////////////
234 243

  
......
375 384

  
376 385
///////////////////////////////////////////////////////////////////////////////////////////////////
377 386

  
378
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
387
  int getColor(int face)
379 388
    {
380
    float R = 0.03f;
381
    float S = 0.05f;
382
    float[] RS = new float[] {R,R,R};
389
    return FACE_COLORS[face];
390
    }
383 391

  
384
    FactorySticker factory = FactorySticker.getInstance();
385
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
392
///////////////////////////////////////////////////////////////////////////////////////////////////
393

  
394
  ObjectSticker retSticker(int face)
395
    {
396
    return mStickers[face/NUM_FACES];
386 397
    }
387 398

  
388 399
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyIvy.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.effect.VertexEffect;
30 28
import org.distorted.library.effect.VertexEffectMove;
......
107 105

  
108 106
  private static MeshBase mCornerMesh, mFaceMesh;
109 107

  
108
  private static final int NUM_STICKERS = 2;
109
  private static final ObjectSticker[] mStickers;
110

  
111
  static
112
    {
113
    mStickers = new ObjectSticker[NUM_STICKERS];
114

  
115
    float A = (+0.5f-IVY_M)*IVY_C;
116
    float B = (-0.5f-IVY_M)*IVY_C;
117
    float C = 0.50f-IVY_D;
118
    float D = (float)(Math.PI/4);
119

  
120
    final float[][] coords = { {A,B,A,A,B,A},{-C,C,C,-C} };
121
    final float[][] angles = { { 0,0,D },{ D,D } };
122
    final float[][] radii  = { { 0,0.02f,0 },{ 0.06f,0.06f } };
123
    final float[] strokes = { 0.03f, 0.08f };
124

  
125
    for(int s=0; s<NUM_STICKERS; s++)
126
      {
127
      mStickers[s] = new ObjectSticker(coords[s],angles[s],radii[s],strokes[s]);
128
      }
129
    }
130

  
110 131
///////////////////////////////////////////////////////////////////////////////////////////////////
111 132

  
112 133
  TwistyIvy(int size, Static4D quat, DistortedTexture texture,
......
147 168

  
148 169
  int getNumStickerTypes(int numLayers)
149 170
    {
150
    return 2;
171
    return NUM_STICKERS;
151 172
    }
152 173

  
153 174
///////////////////////////////////////////////////////////////////////////////////////////////////
......
392 413

  
393 414
///////////////////////////////////////////////////////////////////////////////////////////////////
394 415

  
395
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
416
  int getColor(int face)
396 417
    {
397
    int COLORS = FACE_COLORS.length;
398
    FactorySticker factory = FactorySticker.getInstance();
399

  
400
    if( face<COLORS )
401
      {
402
      float S = 0.03f;
403
      float R = 0.02f;
404
      float[] RS = new float[] {0,R,0};
405

  
406
      float ANGLE = (float)(Math.PI/4);
407

  
408
      float A = (+0.5f-IVY_M)*IVY_C;
409
      float B = (-0.5f-IVY_M)*IVY_C;
410

  
411
      float[] vertices = new float[] { A, B, A, A, B, A };
412
      float[] angles   = new float[] { 0, 0, ANGLE };
413

  
414
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
415
      }
416
    else
417
      {
418
      float S = 0.08f;
419
      float R = 0.06f;
420
      float[] RS = new float[] {R,R};
421

  
422
      float ANGLE = (float)(Math.PI/4);
423
      float A = 0.50f-IVY_D;
418
    return FACE_COLORS[face];
419
    }
424 420

  
425
      float[] vertices = new float[] { -A, A, A, -A };
426
      float[] angles   = new float[] { ANGLE, ANGLE };
421
///////////////////////////////////////////////////////////////////////////////////////////////////
427 422

  
428
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
429
      }
423
  ObjectSticker retSticker(int face)
424
    {
425
    return mStickers[face/NUM_FACES];
430 426
    }
431 427

  
432 428
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyJing.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;
......
204 202

  
205 203
  private static MeshBase[] mMeshes;
206 204

  
205
  private static final ObjectSticker[] mStickers;
206

  
207
  static
208
    {
209
    mStickers = new ObjectSticker[STICKERS.length];
210
    final float R1 = 0.05f;
211
    final float R2 = 0.10f;
212
    final float R3 = 0.03f;
213
    final float[][] radii  = { { R1,R1,R1,R1 },{ R3,R3,R2,R2 },{ R1,R1,R1 } };
214
    final float[] strokes = { 0.06f, 0.03f, 0.05f };
215

  
216
    for(int s=0; s<STICKERS.length; s++)
217
      {
218
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
219
      }
220
    }
221

  
207 222
///////////////////////////////////////////////////////////////////////////////////////////////////
208 223

  
209 224
  TwistyJing(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
370 385

  
371 386
///////////////////////////////////////////////////////////////////////////////////////////////////
372 387

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

  
380
    switch(stickerType)
381
      {
382
      case 0:  R = 0.05f; S = 0.06f; RS = new float[] {R,R,R,R}; break;
383
      case 1:  R = 0.03f; S = 0.03f; RS = new float[] {R,R,R,R}; break;
384
      default: R = 0.05f; S = 0.05f; RS = new float[] {R,R,R  }; break;
385
      }
393
///////////////////////////////////////////////////////////////////////////////////////////////////
386 394

  
387
    FactorySticker factory = FactorySticker.getInstance();
388
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
395
  ObjectSticker retSticker(int face)
396
    {
397
    return mStickers[face/NUM_FACES];
389 398
    }
390 399

  
391 400
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyKilominx.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.helpers.QuatHelper;
29 27
import org.distorted.library.effect.MatrixEffectQuaternion;
30 28
import org.distorted.library.main.DistortedEffects;
......
60 58

  
61 59
  private static final float CENTER_CORR = 0.87f;
62 60

  
63
  private static final float C = 1.14f; // make the 'center' sticker artificially larger, so that we paint
64
                                        // over the area in the center of the face.
65

  
66 61
  private static final float[][] STICKERS = new float[][]
67 62
      {
68
        { C*-0.36616942f, C*-0.36327124f, C*0.5f, C*-0.36327124f, C*0.23233888f, C*0.4605048f, C*-0.36616942f, C*0.26603764f },
63
        { -0.36616942f, -0.36327124f, 0.5f, -0.36327124f, 0.23233888f, 0.4605048f, -0.36616942f, 0.26603764f },
69 64
        { -0.36327127f, -0.5f, 0.36327127f, -0.26393202f, 0.36327127f, 0.5f, -0.36327127f, 0.26393202f },
70 65
        { -0.3249197f, -0.39442718f, 0.3249197f, -0.39442718f, 0.3249197f, 0.5f, -0.3249197f, 0.2888544f }
71 66
      };
......
74 69

  
75 70
  static
76 71
    {
72
    final float C = 1.14f; // make the 'center' sticker artificially larger, so that we paint
73
                           // over the area in the center of the face.
74

  
77 75
    int[] sizes = ObjectList.KILO.getSizes();
78 76
    int variants = sizes.length;
79 77
    mNumCornerEdgeVariants = sizes[0]==3 ? variants-1 : variants;
80 78

  
79
    STICKERS[0][0] *= C;
80
    STICKERS[0][1] *= C;
81
    STICKERS[0][2] *= C;
82
    STICKERS[0][3] *= C;
83
    STICKERS[0][4] *= C;
84
    STICKERS[0][5] *= C;
85
    STICKERS[0][6] *= C;
86
    STICKERS[0][7] *= C;
87

  
81 88
    STICKERS[0][2] *= CENTER_CORR;
82 89
    STICKERS[0][3] *= CENTER_CORR;
83 90
    }
84 91

  
92
  private static final ObjectSticker[] mStickers;
93
  static
94
    {
95
    mStickers = new ObjectSticker[STICKERS.length];
96

  
97
    float R = 0.10f;
98
    final float[][] radii = { {R,R,R,R},{R,R,R,R},{R,R,R,R} };
99
    final float[] strokes = { 0.20f, 0.11f, 0.10f };
100

  
101
    for(int s=0; s<STICKERS.length; s++)
102
      {
103
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
104
      }
105
    }
106

  
85 107
///////////////////////////////////////////////////////////////////////////////////////////////////
86 108

  
87 109
  TwistyKilominx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
635 657

  
636 658
///////////////////////////////////////////////////////////////////////////////////////////////////
637 659

  
638
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
660
  int getColor(int face)
639 661
    {
640
    int COLORS = FACE_COLORS.length;
641
    int variant = face/COLORS;
662
    return FACE_COLORS[face];
663
    }
664

  
665
///////////////////////////////////////////////////////////////////////////////////////////////////
666

  
667
  ObjectSticker retSticker(int face)
668
    {
669
    return mStickers[getStickerIndex(face)];
670
    }
671

  
672
///////////////////////////////////////////////////////////////////////////////////////////////////
673

  
674
  private int getStickerIndex(int face)
675
    {
676
    int variant = face/NUM_FACES;
642 677
    int numLayers = getNumLayers();
643 678

  
644
    if( variant == (numLayers-1)/2 || numLayers==3 ) // center
645
      {
646
      float R = 0.10f;
647
      float S = 0.20f;
648
      float[] RS = new float[] {R,R,R,R};
679
    if( variant == (numLayers-1)/2 || numLayers==3 ) return 0;
680
    if( variant==0 ) return 1;
649 681

  
650
      FactorySticker factory = FactorySticker.getInstance();
651
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face%NUM_FACES], RS);
652
      }
653
    else if( variant==0 ) // corner
654
      {
655
      float R = 0.10f;
656
      float S = 0.11f;
657
      float[] RS = new float[] {R,R,R,R};
658
      FactorySticker factory = FactorySticker.getInstance();
659
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[1], null, S, FACE_COLORS[face%COLORS], RS);
660
      }
661
    else  // edge
662
      {
663
      float R = 0.10f;
664
      float S = 0.10f;
665
      float[] RS = new float[] {R,R,R,R};
666
      FactorySticker factory = FactorySticker.getInstance();
667
      factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[2], null, S, FACE_COLORS[face%COLORS], RS);
668
      }
682
    return 2;
669 683
    }
670 684

  
671 685
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyMegaminx.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.helpers.QuatHelper;
29 27
import org.distorted.library.effect.MatrixEffectQuaternion;
30 28
import org.distorted.library.main.DistortedEffects;
......
58 56
        { -0.29389262f, 0.4045085f, -0.47552824f, -0.1545085f, 0.0f, -0.5f, 0.47552824f, -0.1545085f, 0.29389262f, 0.4045085f }
59 57
      };
60 58

  
59
  private static final ObjectSticker[] mStickers;
60
  static
61
    {
62
    mStickers = new ObjectSticker[STICKERS.length];
63

  
64
    final float R0 = 0.08f;
65
    final float R1 = 0.12f;
66
    final float R2 = 0.12f;
67
    final float R3 = 0.08f;
68
    final float R4 = 0.10f;
69
    final float[][] radii = { {R0,R0,R0,R0},{R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4,R4,R4} };
70
    final float[] strokes = { 0.10f,0.12f,0.12f,0.08f,0.07f };
71

  
72
    for(int s=0; s<STICKERS.length; s++)
73
      {
74
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
75
      }
76
    }
77

  
61 78
///////////////////////////////////////////////////////////////////////////////////////////////////
62 79

  
63 80
  TwistyMegaminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
531 548

  
532 549
///////////////////////////////////////////////////////////////////////////////////////////////////
533 550

  
534
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
551
  int getColor(int face)
535 552
    {
536
    int COLORS = FACE_COLORS.length;
537
    float R,S;
538
    float[] RS;
539
    int index,variant = face/COLORS;
553
    return FACE_COLORS[face];
554
    }
540 555

  
541
    if( variant==0 ) { R = 0.08f; S = 0.10f; index = 0; RS = new float[] {R,R,R,R}; }
542
    else
543
      {
544
      int numLayers = getNumLayers();
556
///////////////////////////////////////////////////////////////////////////////////////////////////
557

  
558
  ObjectSticker retSticker(int face)
559
    {
560
    return mStickers[getStickerIndex(face)];
561
    }
562

  
563
///////////////////////////////////////////////////////////////////////////////////////////////////
564

  
565
  private int getStickerIndex(int face)
566
    {
567
    int variant = face/NUM_FACES;
545 568

  
546
      if( variant < (numLayers+1)/2 )
569
    if( variant==0 ) return 0;
570

  
571
    int numLayers = getNumLayers();
572

  
573
    if( variant < (numLayers+1)/2 )
574
      {
575
      if( numLayers==3 ) return 1;
576
      else
547 577
        {
548
        if( numLayers==3 ) { R = 0.12f; S = 0.12f; index = 1; RS = new float[] {R,R,R,R}; }
549
        else
550
          {
551
          if( variant==1 ) { R = 0.12f; S = 0.12f; index = 2; RS = new float[] {R,R,R,R}; }
552
          else             { R = 0.08f; S = 0.08f; index = 3; RS = new float[] {R,R,R,R}; }
553
          }
578
        if( variant==1 ) return 2;
579
        else             return 3;
554 580
        }
555
      else { R = 0.10f; S = 0.07f; index = 4; RS = new float[] {R,R,R,R,R}; }
556 581
      }
557 582

  
558
    FactorySticker factory = FactorySticker.getInstance();
559
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], RS);
583
    return 4;
560 584
    }
561 585

  
562 586
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyObject.java
28 28
import com.google.firebase.crashlytics.FirebaseCrashlytics;
29 29

  
30 30
import org.distorted.helpers.FactoryCubit;
31
import org.distorted.helpers.FactorySticker;
32
import org.distorted.helpers.ObjectSticker;
31 33
import org.distorted.helpers.QuatHelper;
32 34
import org.distorted.library.effect.Effect;
33 35
import org.distorted.library.effect.MatrixEffectMove;
......
588 590
    paint.setColor(COLOR_BLACK);
589 591
    canvas.drawRect(0, 0, mNumTexCols*TEXTURE_HEIGHT, mNumTexRows*TEXTURE_HEIGHT, paint);
590 592

  
591
    int tex = 0;
593
    int face = 0;
594
    FactorySticker factory = FactorySticker.getInstance();
592 595

  
593 596
    for(int row=0; row<mNumTexRows; row++)
594 597
      for(int col=0; col<mNumTexCols; col++)
595 598
        {
596
        if( tex>=NUM_TEXTURES ) break;
597
        createFaceTexture(canvas, paint, tex, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT);
598
        tex++;
599
        if( face>=NUM_TEXTURES ) break;
600
        ObjectSticker sticker = retSticker(face);
601
        factory.drawRoundedPolygon(canvas, paint, col*TEXTURE_HEIGHT, row*TEXTURE_HEIGHT, getColor(face%NUM_FACES), sticker);
602
        face++;
599 603
        }
600 604

  
601 605
    if( !mTexture.setTexture(bitmap) )
......
970 974
  abstract int getNumStickerTypes(int numLayers);
971 975
  abstract int getNumCubitFaces();
972 976
  abstract MeshBase createCubitMesh(int cubit, int numLayers);
973
  abstract void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top);
977
  abstract ObjectSticker retSticker(int face);
978
  abstract int getColor(int face);
974 979
  abstract int getFaceColor(int cubit, int cubitface, int numLayers);
975 980
  abstract float returnMultiplier();
976 981
  abstract float[][] getCuts(int numLayers);
src/main/java/org/distorted/objects/TwistyPyraminx.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.main.DistortedEffects;
29 27
import org.distorted.library.main.DistortedTexture;
30 28
import org.distorted.library.mesh.MeshBase;
......
120 118
  private static MeshBase[] mMeshes;
121 119
  private static float[] mRowChances;
122 120

  
121
  private static final ObjectSticker[] mStickers;
122

  
123
  static
124
    {
125
    mStickers = new ObjectSticker[STICKERS.length];
126
    final float stroke = 0.08f;
127
    final float radius = 0.06f;
128
    final float[] radii= {radius,radius,radius};
129
    mStickers[0] = new ObjectSticker(STICKERS[0],null,radii,stroke);
130
    }
131

  
123 132
///////////////////////////////////////////////////////////////////////////////////////////////////
124 133

  
125 134
  TwistyPyraminx(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
358 367

  
359 368
///////////////////////////////////////////////////////////////////////////////////////////////////
360 369

  
361
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
370
  int getColor(int face)
362 371
    {
363
    float R = 0.06f;
364
    float S = 0.08f;
365
    float[] RS = new float[] {R,R,R};
372
    return FACE_COLORS[face];
373
    }
374

  
375
///////////////////////////////////////////////////////////////////////////////////////////////////
366 376

  
367
    FactorySticker factory = FactorySticker.getInstance();
368
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
377
  ObjectSticker retSticker(int face)
378
    {
379
    return mStickers[face/NUM_FACES];
369 380
    }
370 381

  
371 382
///////////////////////////////////////////////////////////////////////////////////////////////////
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
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyRex.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.effect.VertexEffect;
30 28
import org.distorted.library.effect.VertexEffectMove;
......
137 135

  
138 136
  private static MeshBase mCornerMesh, mFaceMesh, mEdgeMesh;
139 137

  
138
  private static final int NUM_STICKERS = 3;
139
  private static final ObjectSticker[] mStickers;
140

  
141
  static
142
    {
143
    mStickers = new ObjectSticker[NUM_STICKERS];
144

  
145
    final float A = REX_D*SQ2;
146
    final float B = (1-REX_D)*SQ2/2;
147
    final float C = 1.0f;
148
    final float D = 0.5f-REX_D;
149
    final float E = (float)(Math.PI/15);
150
    final float F = (float)(Math.PI/20);
151
    final float R1= 0.02f;
152
    final float R2= 0.04f;
153
    final float R3= 0.06f;
154
    final float[][] coords = { {A/2,-B/3,-A/2,-B/3,0,2*B/3},{-REX_D,0,0,-REX_D,+REX_D,0,0,+REX_D},{-C/2,D/3,C/2,D/3,0,-2*D/3} };
155
    final float[][] angles = { { -E/2,E,E },null,{ F/10,-F,-F } };
156
    final float[][] radii  = { {R1,R1,R1},{R2,R2,R2,R2},{0,0,R3} };
157
    final float[] strokes = { 0.05f, 0.035f, 0.045f };
158

  
159
    for(int s=0; s<NUM_STICKERS; s++)
160
      {
161
      mStickers[s] = new ObjectSticker(coords[s],angles[s],radii[s],strokes[s]);
162
      }
163
    }
164

  
140 165
///////////////////////////////////////////////////////////////////////////////////////////////////
141 166

  
142 167
  TwistyRex(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
177 202

  
178 203
  int getNumStickerTypes(int numLayers)
179 204
    {
180
    return 3;
205
    return NUM_STICKERS;
181 206
    }
182 207

  
183 208
///////////////////////////////////////////////////////////////////////////////////////////////////
......
549 574

  
550 575
///////////////////////////////////////////////////////////////////////////////////////////////////
551 576

  
552
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
577
  int getColor(int face)
553 578
    {
554
    int COLORS = FACE_COLORS.length;
555
    FactorySticker factory = FactorySticker.getInstance();
556

  
557
    if( face<COLORS )
558
      {
559
      float S = 0.05f;
560
      float R = 0.02f;
561
      float[] RS = new float[] {R,R,R};
562
      float ANGLE = (float)(Math.PI/15);
563
      float F = REX_D*SQ2;
564
      float G = (1-REX_D)*SQ2/2;
565
      float[] vertices = new float[] { F/2, -G/3, -F/2, -G/3, 0, 2*G/3 };
566
      float[] angles   = new float[] { -ANGLE/2, ANGLE, ANGLE };
567

  
568
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
569
      }
570
    else if( face<2*COLORS )
571
      {
572
      float S = 0.035f;
573
      float R = 0.040f;
574
      float[] RS = new float[] {R,R,R,R};
575
      float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
576
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[face%COLORS], RS);
577
      }
578
    else
579
      {
580
      float S = 0.045f;
581
      float R = 0.060f;
582
      float[] RS = new float[] {0,0,R};
579
    return FACE_COLORS[face];
580
    }
583 581

  
584
      float ANGLE = (float)(Math.PI/20);
585
      float F = 1.0f;
586
      float G = 0.5f-REX_D;
587
      float[] vertices = new float[] { -F/2, G/3, F/2, G/3, 0, -2*G/3 };
588
      float[] angles   = new float[] { ANGLE/10, -ANGLE, -ANGLE };
582
///////////////////////////////////////////////////////////////////////////////////////////////////
589 583

  
590
      factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
591
      }
584
  ObjectSticker retSticker(int face)
585
    {
586
    return mStickers[face/NUM_FACES];
592 587
    }
593 588

  
594 589
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySkewb.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;
......
177 175

  
178 176
  private static MeshBase[] mMeshes;
179 177

  
178
  private static final ObjectSticker[] mStickers;
179

  
180
  static
181
    {
182
    mStickers = new ObjectSticker[STICKERS.length+1];
183
    final float R1 = 0.025f;
184
    final float R2 = 0.025f;
185
    final float R3 = 0.055f;
186
    final float[][] radii  = { { R1,R1,R1 },{ R2,R2,R2 },{ R3,R3,R3,R3 } };
187
    final float[] strokes = { 0.045f, 0.035f, 0.035f };
188

  
189
    for(int s=0; s<STICKERS.length+1; s++)
190
      {
191
      int index = s<2 ? 0:1;
192
      mStickers[s] = new ObjectSticker(STICKERS[index],null,radii[s],strokes[s]);
193
      }
194
    }
195

  
180 196
///////////////////////////////////////////////////////////////////////////////////////////////////
181 197

  
182 198
  TwistySkewb(int size, Static4D quat, DistortedTexture texture,
......
572 588

  
573 589
///////////////////////////////////////////////////////////////////////////////////////////////////
574 590

  
575
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
591
  int getColor(int face)
576 592
    {
577
    int COLORS = FACE_COLORS.length;
578
    float R,S;
579
    float[] RS;
580
    int index, cubitType = face/COLORS;
593
    return FACE_COLORS[face];
594
    }
581 595

  
582
    switch(cubitType)
583
      {
584
      case 0 : R = 0.025f; S = 0.045f; index= 0; RS = new float[] {R,R,R  }; break;
585
      case 1 : R = 0.025f; S = 0.035f; index= 0; RS = new float[] {R,R,R  }; break;
586
      default: R = 0.055f; S = 0.035f; index= 1; RS = new float[] {R,R,R,R}; break;
587
      }
596
///////////////////////////////////////////////////////////////////////////////////////////////////
588 597

  
589
    FactorySticker factory = FactorySticker.getInstance();
590
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], RS);
598
  ObjectSticker retSticker(int face)
599
    {
600
    return mStickers[face/NUM_FACES];
591 601
    }
592 602

  
593 603
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySquare.java
274 274
    return new float[][] { {-0.5f,+0.5f}, {0.0f} };
275 275
    }
276 276

  
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278

  
279
  int getColor(int face)
280
    {
281
    return FACE_COLORS[face];
282
    }
283

  
277 284
///////////////////////////////////////////////////////////////////////////////////////////////////
278 285
// PUBLIC API
279 286

  
src/main/java/org/distorted/objects/TwistySquare1.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;
......
104 102
      { -0.2637079f, -0.38185397f, 0.38185397f, -0.38185397f, 0.38185397f, 0.2637079f, -0.5f, 0.5f } // corner top
105 103
    };
106 104

  
107
  private static final int NUM_ST = STICKERS.length;
105
  private static final int NUM_STICKERS = STICKERS.length;
108 106

  
109 107
  private static final int[][] mStickerType = new int[][]
110 108
    {
111
      {  NUM_ST,NUM_ST,0,     1,     2,NUM_ST },
112
      {       3,NUM_ST,4,NUM_ST,NUM_ST,NUM_ST },
113
      {       5,NUM_ST,2,     2,NUM_ST,NUM_ST }
109
      {  NUM_STICKERS,NUM_STICKERS,0,           1,           2,NUM_STICKERS },
110
      {             3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS },
111
      {             5,NUM_STICKERS,2,           2,NUM_STICKERS,NUM_STICKERS }
114 112
    };
115 113

  
116 114
  // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
......
149 147
  private final int[] mCornerQuat;
150 148
  private int mPermittedUp, mPermittedDo;
151 149

  
150
  private static final ObjectSticker[] mStickers;
151

  
152
  static
153
    {
154
    mStickers = new ObjectSticker[NUM_STICKERS];
155
    final float R1 = 0.06f;
156
    final float R2 = 0.04f;
157
    final float R3 = 0.11f;
158
    final float R4 = 0.03f;
159
    final float R5 = 0.11f;
160
    final float R6 = 0.08f;
161
    final float[][] radii  = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6,R6} };
162
    final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.08f };
163

  
164
    for(int s=0; s<NUM_STICKERS; s++)
165
      {
166
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
167
      }
168
    }
169

  
152 170
///////////////////////////////////////////////////////////////////////////////////////////////////
153 171

  
154 172
  TwistySquare1(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
221 239

  
222 240
///////////////////////////////////////////////////////////////////////////////////////////////////
223 241

  
224
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
242
  ObjectSticker retSticker(int face)
225 243
    {
226
    int COLORS = FACE_COLORS.length;
227
    int stickerType = face/COLORS;
228
    float R,S;
229
    float[] RS;
230

  
231
    switch(stickerType)
232
      {
233
      case 0:  R = 0.06f; S = 0.05f; RS= new float[] {R,R,R,R}; break;
234
      case 1:  R = 0.04f; S = 0.04f; RS= new float[] {R,R,R,R}; break;
235
      case 2:  R = 0.11f; S = 0.09f; RS= new float[] {R,R,R,R}; break;
236
      case 3:  R = 0.03f; S = 0.05f; RS= new float[] {R,R,R  }; break;
237
      case 4:  R = 0.11f; S = 0.08f; RS= new float[] {R,R,R,R}; break;
238
      case 5:  R = 0.08f; S = 0.08f; RS= new float[] {R,R,R,R}; break;
239
      default: R = 0.00f; S = 0.00f; RS= new float[] {R,R,R,R}; break;
240
      }
241

  
242
    FactorySticker factory = FactorySticker.getInstance();
243
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
244
    return mStickers[face/NUM_FACES];
244 245
    }
245 246

  
246 247
///////////////////////////////////////////////////////////////////////////////////////////////////
......
254 255

  
255 256
  int getNumStickerTypes(int numLayers)
256 257
    {
257
    return STICKERS.length;
258
    return NUM_STICKERS;
258 259
    }
259 260

  
260 261
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistySquare2.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;
......
114 112
      { -0.11602539f, -0.25f, 0.4330127f, -0.25f, -0.3169873f, 0.5f }                     // corner top
115 113
    };
116 114

  
117
  private static final int NUM_ST = STICKERS.length;
115
  private static final int NUM_STICKERS = STICKERS.length;
118 116

  
119 117
  private static final int[][] mStickerType = new int[][]
120 118
    {
121
      {  NUM_ST,NUM_ST,0,     1,     2,NUM_ST },
122
      {       3,NUM_ST,4,NUM_ST,NUM_ST,NUM_ST },
123
      {       5,NUM_ST,2,NUM_ST,NUM_ST,NUM_ST },
124
      {  NUM_ST,     5,2,NUM_ST,NUM_ST,NUM_ST }
119
      {  NUM_STICKERS,NUM_STICKERS,0,           1,           2,NUM_STICKERS },
120
      {             3,NUM_STICKERS,4,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS },
121
      {             5,NUM_STICKERS,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS },
122
      {  NUM_STICKERS,           5,2,NUM_STICKERS,NUM_STICKERS,NUM_STICKERS }
125 123
    };
126 124

  
127 125
  // YELLOW 0 WHITE 1 BLUE 2 GREEN 3 RED 4 ORANGE 5
......
158 156
      { 3, 0, 4, 0, 0, 0 },
159 157
    };
160 158

  
159
  private static final ObjectSticker[] mStickers;
160

  
161
  static
162
    {
163
    mStickers = new ObjectSticker[NUM_STICKERS];
164
    final float R1 = 0.06f;
165
    final float R2 = 0.04f;
166
    final float R3 = 0.11f;
167
    final float R4 = 0.03f;
168
    final float R5 = 0.11f;
169
    final float R6 = 0.025f;
170
    final float[][] radii  = { {R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3},{R4,R4,R4},{R5,R5,R5,R5},{R6,R6,R6} };
171
    final float[] strokes = { 0.05f,0.04f,0.09f,0.05f,0.08f,0.06f };
172

  
173
    for(int s=0; s<NUM_STICKERS; s++)
174
      {
175
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
176
      }
177
    }
178

  
161 179
///////////////////////////////////////////////////////////////////////////////////////////////////
162 180

  
163 181
  TwistySquare2(int size, Static4D quat, DistortedTexture texture, MeshSquare mesh,
......
226 244

  
227 245
///////////////////////////////////////////////////////////////////////////////////////////////////
228 246

  
229
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
247
  ObjectSticker retSticker(int face)
230 248
    {
231
    int COLORS = FACE_COLORS.length;
232
    int stickerType = face/COLORS;
233
    float R,S;
234
    float[] RS;
235

  
236
    switch(stickerType)
237
      {
238
      case 0:  R = 0.060f; S = 0.05f; RS= new float[] {R,R,R,R}; break;
239
      case 1:  R = 0.040f; S = 0.04f; RS= new float[] {R,R,R,R}; break;
240
      case 2:  R = 0.110f; S = 0.09f; RS= new float[] {R,R,R,R}; break;
241
      case 3:  R = 0.030f; S = 0.05f; RS= new float[] {R,R,R  }; break;
242
      case 4:  R = 0.110f; S = 0.08f; RS= new float[] {R,R,R,R}; break;
243
      case 5:  R = 0.025f; S = 0.06f; RS= new float[] {R,R,R  }; break;
244
      default: R = 0.000f; S = 0.00f; RS= new float[] {R,R,R,R}; break;
245
      }
246

  
247
    FactorySticker factory = FactorySticker.getInstance();
248
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
249
    return mStickers[face/NUM_FACES];
249 250
    }
250 251

  
251 252
///////////////////////////////////////////////////////////////////////////////////////////////////
......
259 260

  
260 261
  int getNumStickerTypes(int numLayers)
261 262
    {
262
    return STICKERS.length;
263
    return NUM_STICKERS;
263 264
    }
264 265

  
265 266
///////////////////////////////////////////////////////////////////////////////////////////////////
src/main/java/org/distorted/objects/TwistyUltimate.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;
......
221 219

  
222 220
  private static MeshBase[] mMeshes;
223 221

  
222
  private static final ObjectSticker[] mStickers;
223

  
224
  static
225
    {
226
    mStickers = new ObjectSticker[STICKERS.length];
227
    final float R1 = 0.08f;
228
    final float R2 = 0.13f;
229
    final float R3 = 0.11f;
230
    final float[][] radii  = { {R1,R1,R1,R1,R1},{R2,R2,R2,R2},{R3,R3,R3,R3} };
231
    final float[] strokes = { 0.07f, 0.09f, 0.08f };
232

  
233
    for(int s=0; s<STICKERS.length; s++)
234
      {
235
      mStickers[s] = new ObjectSticker(STICKERS[s],null,radii[s],strokes[s]);
236
      }
237
    }
238

  
224 239
///////////////////////////////////////////////////////////////////////////////////////////////////
225 240

  
226 241
  TwistyUltimate(int size, Static4D quat, DistortedTexture texture,
......
342 357

  
343 358
///////////////////////////////////////////////////////////////////////////////////////////////////
344 359

  
345
  void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top)
360
  int getFaceColor(int cubit, int cubitface, int size)
346 361
    {
347
    int COLORS = FACE_COLORS.length;
348
    int stickerType = face/COLORS;
349
    float R,S;
350
    float[] RS;
362
    return mFaceMap[cubit][cubitface];
363
    }
351 364

  
352
    switch(stickerType)
353
      {
354
      case 0:  R = 0.08f; S = 0.07f; RS= new float[] {R,R,R,R,R}; break;
355
      case 1:  R = 0.13f; S = 0.09f; RS= new float[] {R,R,R,R  }; break;
356
      case 2:  R = 0.11f; S = 0.08f; RS= new float[] {R,R,R,R  }; break;
357
      default: R = 0.00f; S = 0.00f; RS= new float[] {R,R,R,R  }; break;
358
      }
365
///////////////////////////////////////////////////////////////////////////////////////////////////
359 366

  
360
    FactorySticker factory = FactorySticker.getInstance();
361
    factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
367
  int getColor(int face)
368
    {
369
    return FACE_COLORS[face];
362 370
    }
363 371

  
364 372
///////////////////////////////////////////////////////////////////////////////////////////////////
365 373

  
366
  int getFaceColor(int cubit, int cubitface, int size)
374
  ObjectSticker retSticker(int face)
367 375
    {
368
    return mFaceMap[cubit][cubitface];
376
    return mStickers[face/NUM_FACES];
369 377
    }
370 378

  
371 379
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff