Revision 29bc084f
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/helpers/FactorySticker.java | ||
---|---|---|
24 | 24 |
|
25 | 25 |
import static org.distorted.objects.TwistyObject.TEXTURE_HEIGHT; |
26 | 26 |
import static org.distorted.objects.TwistyObject.COLOR_BLACK; |
27 |
import static org.distorted.objects.TwistyRex.REX_D; |
|
28 | 27 |
|
29 | 28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
30 | 29 |
|
31 | 30 |
public class FactorySticker |
32 | 31 |
{ |
33 |
private static final float SQ2 = (float)Math.sqrt(2); |
|
34 |
private static final float REX_X,REX_R,REX_B,REX_A, REX_P, REX_T, REX_C, REX_S; |
|
35 | 32 |
private static FactorySticker mThis; |
36 |
|
|
37 |
static |
|
38 |
{ |
|
39 |
float F = REX_D*SQ2; |
|
40 |
float G = (1-REX_D)*SQ2/2; |
|
41 |
|
|
42 |
REX_X = (0.5f-REX_D*REX_D)/(2*REX_D); |
|
43 |
REX_R = (float)Math.sqrt(2*REX_X*REX_X+0.5f); |
|
44 |
REX_B = (float) ((180/Math.PI)*(2*Math.asin( Math.sqrt(REX_D*REX_D-REX_D+0.5f) / (2*REX_R) ))); |
|
45 |
REX_A = (float) ((180/Math.PI)*Math.acos(REX_X/REX_R)) - 45; |
|
46 |
REX_P = 45 + REX_B/2 + REX_A; |
|
47 |
REX_T = (float) ( Math.tan( (Math.PI/180)*(45-REX_P/2) ) ); |
|
48 |
REX_C = (float)(REX_R/Math.cos((Math.PI/180)*REX_B/2) ); |
|
49 |
REX_S = (float)(1/Math.sqrt(1+4*G*G/(F*F))); |
|
50 |
} |
|
51 |
|
|
52 | 33 |
private float mOX, mOY, mR; |
53 | 34 |
|
54 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
149 | 130 |
|
150 | 131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
151 | 132 |
|
152 |
private void drawCurrCurvVertex(Canvas canvas, Paint paint, int left, int top, float r, float stroke, float pX, float pY, float cX, float cY, float nX, float nY, float pA, float cA)
|
|
133 |
private void drawCurrCurveV(Canvas canvas, Paint paint, int left, int top, float r, float stroke, float pX, float pY, float cX, float cY, float nX, float nY, float pA, float cA)
|
|
153 | 134 |
{ |
154 | 135 |
pX = (0.5f+pX)*TEXTURE_HEIGHT; |
155 | 136 |
pY = (0.5f-pY)*TEXTURE_HEIGHT; |
... | ... | |
268 | 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
269 | 250 |
// PUBLIC |
270 | 251 |
|
271 |
public void drawRoundedPolygon(Canvas canvas, Paint paint, int left, int top, float[] vertices, float[] angles, float stroke, int color, float radius)
|
|
252 |
public void drawRoundedPolygon(Canvas canvas, Paint paint, int left, int top, float[] vertices, float[] angles, float stroke, int color, float[] radii)
|
|
272 | 253 |
{ |
273 | 254 |
stroke *= TEXTURE_HEIGHT; |
274 | 255 |
|
... | ... | |
299 | 280 |
{ |
300 | 281 |
if( prevA==0 ) |
301 | 282 |
{ |
302 |
drawCurrVertex(canvas, paint, left, top, radius, stroke, prevX,prevY,currX,currY,nextX,nextY);
|
|
283 |
drawCurrVertex(canvas, paint, left, top, radii[vert], stroke, prevX,prevY,currX,currY,nextX,nextY);
|
|
303 | 284 |
} |
304 | 285 |
else |
305 | 286 |
{ |
306 |
drawCurrCurvVertex(canvas, paint, left, top, radius, stroke, prevX,prevY,currX,currY,nextX,nextY,prevA,currA);
|
|
287 |
drawCurrCurveV(canvas, paint, left, top, radii[vert], stroke, prevX,prevY,currX,currY,nextX,nextY,prevA,currA);
|
|
307 | 288 |
} |
308 | 289 |
|
309 | 290 |
prevX = currX; |
... | ... | |
326 | 307 |
} |
327 | 308 |
} |
328 | 309 |
} |
329 |
|
|
330 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
331 |
|
|
332 |
public void drawRexCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius1, float radius2) |
|
333 |
{ |
|
334 |
|
|
335 |
/* |
|
336 |
paint.setColor(color); |
|
337 |
paint.setStyle(Paint.Style.FILL); |
|
338 |
canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint); |
|
339 |
|
|
340 |
paint.setColor(COLOR_BLACK); |
|
341 |
paint.setStyle(Paint.Style.STROKE); |
|
342 |
paint.setStrokeWidth(stroke*TEXTURE_HEIGHT); |
|
343 |
|
|
344 |
float F = REX_D*SQ2; |
|
345 |
float G = (1-REX_D)*SQ2/2; |
|
346 |
|
|
347 |
float cx1 = left + (0.5f-F/2)*TEXTURE_HEIGHT; |
|
348 |
float cx2 = left + (0.5f+F/2)*TEXTURE_HEIGHT; |
|
349 |
float cy = top + (0.5f+G/3)*TEXTURE_HEIGHT; |
|
350 |
|
|
351 |
canvas.drawLine(cx1, cy, cx2, cy, paint); |
|
352 |
|
|
353 |
float X = REX_C-F/2; |
|
354 |
float R1 = TEXTURE_HEIGHT*(REX_R + 0.5f*stroke); |
|
355 |
float cx3 = left + (0.5f-X)*TEXTURE_HEIGHT; |
|
356 |
float cx4 = left + (0.5f+X)*TEXTURE_HEIGHT; |
|
357 |
|
|
358 |
canvas.drawArc( cx3-R1, cy-R1, cx3+R1, cy+R1, 360-REX_B/2, REX_B/2, false ,paint); |
|
359 |
canvas.drawArc( cx4-R1, cy-R1, cx4+R1, cy+R1, 180 , REX_B/2, false ,paint); |
|
360 |
|
|
361 |
float cx5 = left + (0.5f+F/2-radius2)*TEXTURE_HEIGHT; |
|
362 |
float cx6 = left + (0.5f-F/2+radius2)*TEXTURE_HEIGHT; |
|
363 |
float cy1 = top + (0.5f+G/3-radius2)*TEXTURE_HEIGHT; |
|
364 |
float R2 = TEXTURE_HEIGHT*radius2; |
|
365 |
|
|
366 |
canvas.drawArc( cx5-R2, cy1-R2, cx5+R2, cy1+R2, 0, 90, false ,paint); |
|
367 |
canvas.drawArc( cx6-R2, cy1-R2, cx6+R2, cy1+R2, 90, 90, false ,paint); |
|
368 |
|
|
369 |
float cx7 = left + 0.5f*TEXTURE_HEIGHT; |
|
370 |
float cy2 = top + (0.5f-2*G/3 + radius1/REX_S)*TEXTURE_HEIGHT; |
|
371 |
float R3 = TEXTURE_HEIGHT*(radius1 + 0.5f*stroke); |
|
372 |
canvas.drawArc( cx7-R3, cy2-R3, cx7+R3, cy2+R3, 270-(90-REX_B/2), 180-REX_B, false ,paint); |
|
373 |
*/ |
|
374 |
} |
|
375 |
|
|
376 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
377 |
|
|
378 |
public void drawRexEdgeSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius) |
|
379 |
{ |
|
380 |
paint.setColor(color); |
|
381 |
paint.setStyle(Paint.Style.FILL); |
|
382 |
canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint); |
|
383 |
|
|
384 |
paint.setColor(COLOR_BLACK); |
|
385 |
paint.setStyle(Paint.Style.STROKE); |
|
386 |
paint.setStrokeWidth(stroke*TEXTURE_HEIGHT); |
|
387 |
|
|
388 |
final float D = ( 0.5f - (0.5f-REX_D)/3); |
|
389 |
float cx1 = left+ TEXTURE_HEIGHT*(0.5f-REX_X); |
|
390 |
float cy1 = top + TEXTURE_HEIGHT*(0.5f+REX_X+D); |
|
391 |
float cx2 = left+ TEXTURE_HEIGHT*(0.5f+REX_X); |
|
392 |
float R1 = TEXTURE_HEIGHT*REX_R; |
|
393 |
|
|
394 |
canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 315-REX_A-REX_B, REX_B, false ,paint); |
|
395 |
canvas.drawArc( cx2-R1, cy1-R1, cx2+R1, cy1+R1, 225+REX_A , REX_B, false ,paint); |
|
396 |
|
|
397 |
float CORR_Y = radius/12; |
|
398 |
float CORR_A = 10; |
|
399 |
float sin = (float)Math.sin(Math.PI*REX_P/180); |
|
400 |
float cx = left + 0.5f*TEXTURE_HEIGHT; |
|
401 |
float cy = top + ( 0.5f + 2*(0.5f-REX_D)/3 -CORR_Y -radius/sin )*TEXTURE_HEIGHT; |
|
402 |
float R2 = TEXTURE_HEIGHT*radius; |
|
403 |
|
|
404 |
canvas.drawArc( cx-R2, cy-R2, cx+R2, cy+R2, 90-(REX_P-CORR_A), 2*(REX_P-CORR_A), false ,paint); |
|
405 |
|
|
406 |
float F = 0.1f; |
|
407 |
float G = 0.6f; |
|
408 |
float R3 = TEXTURE_HEIGHT*radius*G*0.9f; |
|
409 |
float X = G*radius/REX_T; |
|
410 |
float cx4 = left + X*TEXTURE_HEIGHT; |
|
411 |
float cx3 = left + (1-X)*TEXTURE_HEIGHT; |
|
412 |
float cy3 = top + (0.5f - (0.5f-REX_D)/3 + G*radius - F*stroke)*TEXTURE_HEIGHT; |
|
413 |
|
|
414 |
canvas.drawArc( cx3-R3, cy3-R3, cx3+R3, cy3+R3, 270 , 90+REX_P, false ,paint); |
|
415 |
canvas.drawArc( cx4-R3, cy3-R3, cx4+R3, cy3+R3, 270-(90+REX_P), 90+REX_P, false ,paint); |
|
416 |
|
|
417 |
float cy5 = top + D*TEXTURE_HEIGHT; |
|
418 |
|
|
419 |
paint.setStrokeWidth((1-2*F)*stroke*TEXTURE_HEIGHT); |
|
420 |
canvas.drawLine(left, cy5, left+TEXTURE_HEIGHT, cy5, paint); |
|
421 |
} |
|
422 | 310 |
} |
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
---|---|---|
378 | 378 |
float MAX = Math.max(X,Y); |
379 | 379 |
float R = 0.10f / MAX; |
380 | 380 |
float S = 0.08f / MAX; |
381 |
float[] RS = new float[] {R,R,R,R}; |
|
381 | 382 |
X /= (2*MAX); |
382 | 383 |
Y /= (2*MAX); |
383 | 384 |
|
384 | 385 |
float[] vertices = { -X,-Y, +X,-Y, +X,+Y, -X,+Y}; |
385 | 386 |
|
386 | 387 |
FactorySticker factory = FactorySticker.getInstance(); |
387 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[color], R); |
|
388 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[color], RS);
|
|
388 | 389 |
} |
389 | 390 |
|
390 | 391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
183 | 183 |
{ |
184 | 184 |
float R = 0.10f; |
185 | 185 |
float S = 0.08f; |
186 |
float[] RS = new float[] {R,R,R,R}; |
|
186 | 187 |
|
187 | 188 |
FactorySticker factory = FactorySticker.getInstance(); |
188 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], R); |
|
189 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
|
|
189 | 190 |
} |
190 | 191 |
|
191 | 192 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
495 | 495 |
{ |
496 | 496 |
float R = 0.06f; |
497 | 497 |
float S = 0.07f; |
498 |
float[] RS = new float[] {R,R,R}; |
|
498 | 499 |
|
499 | 500 |
FactorySticker factory = FactorySticker.getInstance(); |
500 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], R); |
|
501 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
|
|
501 | 502 |
} |
502 | 503 |
|
503 | 504 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
217 | 217 |
{ |
218 | 218 |
float R = 0.025f; |
219 | 219 |
float S = 0.05f; |
220 |
float[] RS = new float[] {R,R,R}; |
|
220 | 221 |
|
221 | 222 |
FactorySticker factory = FactorySticker.getInstance(); |
222 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], R); |
|
223 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
|
|
223 | 224 |
} |
224 | 225 |
|
225 | 226 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyHelicopter.java | ||
---|---|---|
379 | 379 |
{ |
380 | 380 |
float R = 0.03f; |
381 | 381 |
float S = 0.05f; |
382 |
float[] RS = new float[] {R,R,R}; |
|
382 | 383 |
|
383 | 384 |
FactorySticker factory = FactorySticker.getInstance(); |
384 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], R); |
|
385 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
|
|
385 | 386 |
} |
386 | 387 |
|
387 | 388 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyIvy.java | ||
---|---|---|
401 | 401 |
{ |
402 | 402 |
float S = 0.03f; |
403 | 403 |
float R = 0.02f; |
404 |
float[] RS = new float[] {0,R,0}; |
|
404 | 405 |
|
405 | 406 |
float ANGLE = (float)(Math.PI/4); |
406 | 407 |
|
... | ... | |
410 | 411 |
float[] vertices = new float[] { A, B, A, A, B, A }; |
411 | 412 |
float[] angles = new float[] { 0, 0, ANGLE }; |
412 | 413 |
|
413 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], R); |
|
414 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
|
|
414 | 415 |
} |
415 | 416 |
else |
416 | 417 |
{ |
417 | 418 |
float S = 0.08f; |
418 | 419 |
float R = 0.06f; |
420 |
float[] RS = new float[] {R,R}; |
|
419 | 421 |
|
420 | 422 |
float ANGLE = (float)(Math.PI/4); |
421 | 423 |
float A = 0.50f-IVY_D; |
... | ... | |
423 | 425 |
float[] vertices = new float[] { -A, A, A, -A }; |
424 | 426 |
float[] angles = new float[] { ANGLE, ANGLE }; |
425 | 427 |
|
426 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], R); |
|
428 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
|
|
427 | 429 |
} |
428 | 430 |
} |
429 | 431 |
|
src/main/java/org/distorted/objects/TwistyJing.java | ||
---|---|---|
375 | 375 |
int COLORS = FACE_COLORS.length; |
376 | 376 |
int stickerType = face/COLORS; |
377 | 377 |
float R,S; |
378 |
float[] RS; |
|
378 | 379 |
|
379 | 380 |
switch(stickerType) |
380 | 381 |
{ |
381 |
case 0: R = 0.05f; S = 0.06f; break; |
|
382 |
case 1: R = 0.03f; S = 0.03f; break; |
|
383 |
default: R = 0.05f; S = 0.05f; break; |
|
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;
|
|
384 | 385 |
} |
385 | 386 |
|
386 | 387 |
FactorySticker factory = FactorySticker.getInstance(); |
387 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], R); |
|
388 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
|
|
388 | 389 |
} |
389 | 390 |
|
390 | 391 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyKilominx.java | ||
---|---|---|
642 | 642 |
{ |
643 | 643 |
float R = 0.10f; |
644 | 644 |
float S = 0.09f; |
645 |
float[] RS = new float[] {R,R,R,R}; |
|
645 | 646 |
float cx = STICKERS[0][2]/CENTER_CORR; |
646 | 647 |
float cy = STICKERS[0][3]/CENTER_CORR; |
647 | 648 |
|
648 | 649 |
FactorySticker factory = FactorySticker.getInstance(); |
649 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face%NUM_FACES], R); |
|
650 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face%NUM_FACES], RS);
|
|
650 | 651 |
canvas.drawCircle(left+(0.5f+cx)*TEXTURE_HEIGHT, top+(0.5f-cy)*TEXTURE_HEIGHT, 0.05f*TEXTURE_HEIGHT, paint); |
651 | 652 |
} |
652 | 653 |
else if( variant==0 ) // corner |
653 | 654 |
{ |
654 | 655 |
float R = 0.10f; |
655 | 656 |
float S = 0.11f; |
657 |
float[] RS = new float[] {R,R,R,R}; |
|
656 | 658 |
FactorySticker factory = FactorySticker.getInstance(); |
657 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[1], null, S, FACE_COLORS[face%COLORS], R); |
|
659 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[1], null, S, FACE_COLORS[face%COLORS], RS);
|
|
658 | 660 |
} |
659 | 661 |
else // edge |
660 | 662 |
{ |
661 | 663 |
float R = 0.10f; |
662 | 664 |
float S = 0.10f; |
665 |
float[] RS = new float[] {R,R,R,R}; |
|
663 | 666 |
FactorySticker factory = FactorySticker.getInstance(); |
664 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[2], null, S, FACE_COLORS[face%COLORS], R); |
|
667 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[2], null, S, FACE_COLORS[face%COLORS], RS);
|
|
665 | 668 |
} |
666 | 669 |
} |
667 | 670 |
|
src/main/java/org/distorted/objects/TwistyMegaminx.java | ||
---|---|---|
535 | 535 |
{ |
536 | 536 |
int COLORS = FACE_COLORS.length; |
537 | 537 |
float R,S; |
538 |
float[] RS; |
|
538 | 539 |
int index,variant = face/COLORS; |
539 | 540 |
|
540 |
if( variant==0 ) { R = 0.08f; S = 0.10f; index = 0; } |
|
541 |
if( variant==0 ) { R = 0.08f; S = 0.10f; index = 0; RS = new float[] {R,R,R,R}; }
|
|
541 | 542 |
else |
542 | 543 |
{ |
543 | 544 |
int numLayers = getNumLayers(); |
544 | 545 |
|
545 | 546 |
if( variant < (numLayers+1)/2 ) |
546 | 547 |
{ |
547 |
if( numLayers==3 ) { R = 0.12f; S = 0.12f; index = 1; } |
|
548 |
if( numLayers==3 ) { R = 0.12f; S = 0.12f; index = 1; RS = new float[] {R,R,R,R}; }
|
|
548 | 549 |
else |
549 | 550 |
{ |
550 |
if( variant==1 ) { R = 0.12f; S = 0.12f; index = 2; } |
|
551 |
else { R = 0.08f; S = 0.08f; index = 3; } |
|
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}; }
|
|
552 | 553 |
} |
553 | 554 |
} |
554 |
else { R = 0.10f; S = 0.07f; index = 4; } |
|
555 |
else { R = 0.10f; S = 0.07f; index = 4; RS = new float[] {R,R,R,R,R}; }
|
|
555 | 556 |
} |
556 | 557 |
|
557 | 558 |
FactorySticker factory = FactorySticker.getInstance(); |
558 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], R); |
|
559 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], RS);
|
|
559 | 560 |
} |
560 | 561 |
|
561 | 562 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyPyraminx.java | ||
---|---|---|
362 | 362 |
{ |
363 | 363 |
float R = 0.06f; |
364 | 364 |
float S = 0.08f; |
365 |
float[] RS = new float[] {R,R,R}; |
|
365 | 366 |
|
366 | 367 |
FactorySticker factory = FactorySticker.getInstance(); |
367 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], R); |
|
368 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[0], null, S, FACE_COLORS[face], RS);
|
|
368 | 369 |
} |
369 | 370 |
|
370 | 371 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRedi.java | ||
---|---|---|
384 | 384 |
case 1: R = 0.06f; S = 0.06f; break; |
385 | 385 |
default: R = 0.00f; S = 0.00f; break; |
386 | 386 |
} |
387 |
|
|
387 |
float[] RS = new float[] {R,R,R,R}; |
|
388 | 388 |
FactorySticker factory = FactorySticker.getInstance(); |
389 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], R); |
|
389 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
|
|
390 | 390 |
} |
391 | 391 |
|
392 | 392 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyRex.java | ||
---|---|---|
558 | 558 |
{ |
559 | 559 |
float S = 0.05f; |
560 | 560 |
float R = 0.02f; |
561 |
float[] RS = new float[] {R,R,R}; |
|
561 | 562 |
float ANGLE = (float)(Math.PI/15); |
562 | 563 |
float F = REX_D*SQ2; |
563 | 564 |
float G = (1-REX_D)*SQ2/2; |
564 | 565 |
float[] vertices = new float[] { F/2, -G/3, -F/2, -G/3, 0, 2*G/3 }; |
565 | 566 |
float[] angles = new float[] { -ANGLE/2, ANGLE, ANGLE }; |
566 | 567 |
|
567 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], R); |
|
568 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS);
|
|
568 | 569 |
} |
569 | 570 |
else if( face<2*COLORS ) |
570 | 571 |
{ |
571 | 572 |
float S = 0.035f; |
572 | 573 |
float R = 0.040f; |
574 |
float[] RS = new float[] {R,R,R,R}; |
|
573 | 575 |
float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D}; |
574 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[face%COLORS], R); |
|
576 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, null, S, FACE_COLORS[face%COLORS], RS);
|
|
575 | 577 |
} |
576 | 578 |
else |
577 | 579 |
{ |
578 |
float S = 0.051f; |
|
579 |
float R = 0.070f; |
|
580 |
factory.drawRexEdgeSticker(canvas, paint, left, top, FACE_COLORS[face%COLORS], S, R); |
|
580 |
float S = 0.045f; |
|
581 |
float R = 0.060f; |
|
582 |
float[] RS = new float[] {0,0,R}; |
|
583 |
|
|
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 }; |
|
589 |
|
|
590 |
factory.drawRoundedPolygon(canvas, paint, left, top, vertices, angles, S, FACE_COLORS[face%COLORS], RS); |
|
581 | 591 |
} |
582 | 592 |
} |
583 | 593 |
|
src/main/java/org/distorted/objects/TwistySkewb.java | ||
---|---|---|
575 | 575 |
void createFaceTexture(Canvas canvas, Paint paint, int face, int left, int top) |
576 | 576 |
{ |
577 | 577 |
int COLORS = FACE_COLORS.length; |
578 |
float R=0.0f,S=0.0f; |
|
579 |
int index=0, cubitType = face/COLORS; |
|
578 |
float R,S; |
|
579 |
float[] RS; |
|
580 |
int index, cubitType = face/COLORS; |
|
580 | 581 |
|
581 | 582 |
switch(cubitType) |
582 | 583 |
{ |
583 |
case 0: R = 0.025f; S = 0.045f; index= 0; break;
|
|
584 |
case 1: R = 0.025f; S = 0.035f; index= 0; break;
|
|
585 |
case 2: R = 0.055f; S = 0.035f; index= 1; break;
|
|
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;
|
|
586 | 587 |
} |
587 | 588 |
|
588 | 589 |
FactorySticker factory = FactorySticker.getInstance(); |
589 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], R); |
|
590 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[index], null, S, FACE_COLORS[face%COLORS], RS);
|
|
590 | 591 |
} |
591 | 592 |
|
592 | 593 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySquare1.java | ||
---|---|---|
226 | 226 |
int COLORS = FACE_COLORS.length; |
227 | 227 |
int stickerType = face/COLORS; |
228 | 228 |
float R,S; |
229 |
float[] RS; |
|
229 | 230 |
|
230 | 231 |
switch(stickerType) |
231 | 232 |
{ |
232 |
case 0: R = 0.06f; S = 0.05f; break; |
|
233 |
case 1: R = 0.04f; S = 0.04f; break; |
|
234 |
case 2: R = 0.11f; S = 0.09f; break; |
|
235 |
case 3: R = 0.03f; S = 0.05f; break; |
|
236 |
case 4: R = 0.11f; S = 0.08f; break; |
|
237 |
case 5: R = 0.08f; S = 0.08f; break; |
|
238 |
default: R = 0.00f; S = 0.00f; break; |
|
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;
|
|
239 | 240 |
} |
240 | 241 |
|
241 | 242 |
FactorySticker factory = FactorySticker.getInstance(); |
242 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], R); |
|
243 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
|
|
243 | 244 |
} |
244 | 245 |
|
245 | 246 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistySquare2.java | ||
---|---|---|
231 | 231 |
int COLORS = FACE_COLORS.length; |
232 | 232 |
int stickerType = face/COLORS; |
233 | 233 |
float R,S; |
234 |
float[] RS; |
|
234 | 235 |
|
235 | 236 |
switch(stickerType) |
236 | 237 |
{ |
237 |
case 0: R = 0.060f; S = 0.05f; break; |
|
238 |
case 1: R = 0.040f; S = 0.04f; break; |
|
239 |
case 2: R = 0.110f; S = 0.09f; break; |
|
240 |
case 3: R = 0.030f; S = 0.05f; break; |
|
241 |
case 4: R = 0.110f; S = 0.08f; break; |
|
242 |
case 5: R = 0.025f; S = 0.06f; break; |
|
243 |
default: R = 0.000f; S = 0.00f; break; |
|
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;
|
|
244 | 245 |
} |
245 | 246 |
|
246 | 247 |
FactorySticker factory = FactorySticker.getInstance(); |
247 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], R); |
|
248 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
|
|
248 | 249 |
} |
249 | 250 |
|
250 | 251 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyUltimate.java | ||
---|---|---|
347 | 347 |
int COLORS = FACE_COLORS.length; |
348 | 348 |
int stickerType = face/COLORS; |
349 | 349 |
float R,S; |
350 |
float[] RS; |
|
350 | 351 |
|
351 | 352 |
switch(stickerType) |
352 | 353 |
{ |
353 |
case 0: R = 0.08f; S = 0.07f; break; |
|
354 |
case 1: R = 0.13f; S = 0.09f; break; |
|
355 |
case 2: R = 0.11f; S = 0.08f; break; |
|
356 |
default: R = 0.00f; S = 0.00f; break; |
|
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;
|
|
357 | 358 |
} |
358 | 359 |
|
359 | 360 |
FactorySticker factory = FactorySticker.getInstance(); |
360 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], R); |
|
361 |
factory.drawRoundedPolygon(canvas, paint, left, top, STICKERS[stickerType], null, S, FACE_COLORS[face%COLORS], RS);
|
|
361 | 362 |
} |
362 | 363 |
|
363 | 364 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
Also available in: Unified diff
Convert the last 'special' case, the Rex edge sticker, to the generic sticker mechanism.