Project

General

Profile

« Previous | Next » 

Revision 0b8ffe1a

Added by Leszek Koltunski over 3 years ago

Progress with the Rex Cube (stickers)

View differences:

src/main/java/org/distorted/objects/FactorySticker.java
245 245
    }
246 246

  
247 247
///////////////////////////////////////////////////////////////////////////////////////////////////
248
// TODO
249 248

  
250 249
  void drawRexCornerSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius)
251 250
    {
......
257 256
    paint.setStyle(Paint.Style.STROKE);
258 257
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
259 258

  
260
    float T  = (0.5f-REX_D)*SQ2*(SQ3-1);
261
    float H1 = T*(1.0f + 2*SQ3/3);
262
    float H2 = T*(0.5f +   SQ3/6);
259
    float F  = (0.5f-REX_D)*SQ2*(SQ3-1);
260
    float H1 = F*(1.0f + 2*SQ3/3);
261
    float H2 = F*(0.5f +   SQ3/6);
263 262
    float D  = H2*SQ3;
264 263

  
265 264
    float cx1 = left+ TEXTURE_HEIGHT*0.5f;
......
274 273
    canvas.drawArc( cx1-R1, cy1-R1, cx1+R1, cy1+R1, 255, 30, false ,paint);
275 274
    canvas.drawArc( cx2-R1, cy2-R1, cx2+R1, cy2+R1, 315, 30, false ,paint);
276 275
    canvas.drawArc( cx3-R1, cy3-R1, cx3+R1, cy3+R1, 195, 30, false ,paint);
277
/*
276

  
278 277
    float cx   = left+ TEXTURE_HEIGHT*0.5f;
279 278
    float cy   = top + TEXTURE_HEIGHT*0.5f;
280 279
    float R2   = radius*TEXTURE_HEIGHT;
281
    float dist = ( (0.5f-REX_D)*(SQ3-1) - (2*SQ3/3)*radius )*TEXTURE_HEIGHT;
282

  
283
    canvas.drawArc( cx+dist-R2, cy-R2, cx+dist+R2, cy+R2, 330, 60, false ,paint);
284
    canvas.drawArc( cx-R2, cy+dist-R2, cx+R2, cy+dist+R2,  60, 60, false ,paint);
285
    canvas.drawArc( cx-dist-R2, cy-R2, cx-dist+R2, cy+R2, 150, 60, false ,paint);
286
    canvas.drawArc( cx-R2, cy-dist-R2, cx+R2, cy-dist+R2, 240, 60, false ,paint);
287
 */
280
    float dist = ( (SQ3/3)*F - SQ2*radius )*TEXTURE_HEIGHT;
281
    float dist2= 1.0f*(SQ3/3)*F*TEXTURE_HEIGHT;
282
    float tmp  = SQ2*radius*TEXTURE_HEIGHT;
283
    float distX= (SQ3/2)*dist2 - 1.05f*tmp;
284
    float distY= (0.5f )*dist2 - 0.90f*tmp;
285

  
286
    canvas.drawArc( cx      -R2, cy-dist -R2, cx      +R2, cy-dist +R2, 225, 90, false ,paint);
287
    canvas.drawArc( cx-distX-R2, cy+distY-R2, cx-distX+R2, cy+distY+R2,  75,120, false ,paint);
288
    canvas.drawArc( cx+distX-R2, cy+distY-R2, cx+distX+R2, cy+distY+R2, 345,120, false ,paint);
288 289
    }
289 290

  
290 291
///////////////////////////////////////////////////////////////////////////////////////////////////
......
326 327
    }
327 328

  
328 329
///////////////////////////////////////////////////////////////////////////////////////////////////
329
// TODO
330 330

  
331 331
  void drawRexEdgeSticker(Canvas canvas, Paint paint, int left, int top, int color, float stroke, float radius)
332 332
    {
333 333
    paint.setColor(color);
334 334
    paint.setStyle(Paint.Style.FILL);
335 335
    canvas.drawRect(left,top,left+TEXTURE_HEIGHT,top+TEXTURE_HEIGHT,paint);
336

  
337
    paint.setColor(COLOR_BLACK);
338
    paint.setStyle(Paint.Style.STROKE);
339
    paint.setStrokeWidth(stroke*TEXTURE_HEIGHT);
340

  
341
    final float D = 0.5f - REX_D;
342
    final float F = 0.5f*(0.5f - D*(SQ3-1));
343

  
344
    float cx1 = left+ TEXTURE_HEIGHT*REX_D;
345
    float cy  = top + TEXTURE_HEIGHT*(1-REX_D-F+0.5f);
346
    float cx2 = left+ TEXTURE_HEIGHT*(1-REX_D);
347
    float R1  = 1.0f*TEXTURE_HEIGHT*(1-2*REX_D);
348

  
349
    canvas.drawArc( cx1-R1, cy-R1, cx1+R1, cy+R1, 270, 30, false ,paint);
350
    canvas.drawArc( cx2-R1, cy-R1, cx2+R1, cy+R1, 240, 30, false ,paint);
351

  
352
    float cx = left + TEXTURE_HEIGHT*0.5f;
353
    float R2 = radius*TEXTURE_HEIGHT;
354
    cy       = top + TEXTURE_HEIGHT*(0.5f+F-(2*SQ3/3)*radius);
355

  
356
    canvas.drawArc( cx-R2, cy-R2, cx+R2, cy+R2, 60, 60, false ,paint);
357

  
358
    cy = top + (0.5f-F)*TEXTURE_HEIGHT;
359

  
360
    paint.setStrokeWidth(0.6f*stroke*TEXTURE_HEIGHT);
361
    canvas.drawLine(left, cy, left+TEXTURE_HEIGHT, cy, paint);
336 362
    }
337 363
  }

Also available in: Unified diff