Project

General

Profile

« Previous | Next » 

Revision cdc515b9

Added by Leszek Koltunski about 8 years ago

Correct Bean

View differences:

src/main/java/org/distorted/examples/bean/BeanRenderer.java
57 57
      {
58 58
      mView = v;
59 59
     
60
      pLeft = new Static3D(106, 192, 0);
61
      pRight= new Static3D(230, 150, 0);
60
      pLeft = new Static3D( 98, 183, 0);
61
      pRight= new Static3D(233, 140, 0);
62 62
      
63
      rLeft = new Static4D(-9,-31,35,35);
64
      rRight= new Static4D(-9,-31,35,35);
63
      rLeft = new Static4D( -3,-33,47,47);
64
      rRight= new Static4D(-14,-33,47,47);
65 65
     
66 66
      dLeft = new Dynamic3D(2000,0.0f);
67 67
      dRight= new Dynamic3D(2000,0.0f);
68 68

  
69 69
      Static3D p1 = new Static3D(  0,  0, 0);
70
      Static3D p2 = new Static3D(-10,-30, 0);
70
      Static3D p2 = new Static3D(-15,-30, 0);
71 71
      
72 72
      dLeft.add(p1);
73 73
      dLeft.add(p1);
......
143 143
      bmpHeight = bitmap.getHeight();
144 144
      bmpWidth  = bitmap.getWidth();
145 145
      
146
      mBean = new DistortedBitmap(bitmap, 30);
146
      mBean = new DistortedBitmap(bitmap, 25);
147 147
      mBean.distort(dLeft , pLeft , rLeft );
148 148
      mBean.distort(dRight, pRight, rRight);
149 149
      
src/main/java/org/distorted/examples/effects3d/Effects3DActivity.java
67 67
  private boolean[] mShape;
68 68
  private DistortedObject mObject;
69 69
  private int mObjectType;
70
  private int mBitmap;
70
  private int mBitmapID;
71
  private Bitmap mBitmap;
71 72

  
72 73
  private ArrayList<Effects3DEffect> mEffects;
73 74
  private int mEffectAdd;
......
134 135
    Spinner bitmapSpinner  = (Spinner)findViewById(R.id.objectpicker_spinnerBitmap);
135 136
    bitmapSpinner.setOnItemSelectedListener(this);
136 137

  
137
    String[] objectBitmap = new String[] { "Grid", "Girl", "Dog", "Cat", "Squares"};
138
    String[] objectBitmap = new String[] { "Grid", "Girl", "Dog", "Cat", "Squares", "Bean", "Lisa"};
138 139

  
139 140
    ArrayAdapter<String> adapterBitmap = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, objectBitmap);
140 141
    adapterBitmap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
......
251 252

  
252 253
  public Bitmap getBitmap()
253 254
    {
254
    Bitmap bmp;
255

  
256
    if( mBitmap!=-1)
255
    if( mBitmap==null )
257 256
      {
258
      InputStream is = getResources().openRawResource(mBitmap);
259

  
260
      try
261
        {
262
        bmp = BitmapFactory.decodeStream(is);
263
        }
264
      finally
257
      if( mBitmapID!=-1)
265 258
        {
259
        InputStream is = getResources().openRawResource(mBitmapID);
260

  
266 261
        try
267 262
          {
268
          is.close();
263
          mBitmap = BitmapFactory.decodeStream(is);
264
          }
265
        finally
266
          {
267
          try
268
            {
269
            is.close();
270
            }
271
          catch(IOException e) { }
269 272
          }
270
        catch(IOException e) { }
271 273
        }
272
      }
273
    else
274
      {
275
      final int W = 640;
276
      final int H = 640;
274
      else
275
        {
276
        final int W = 640;
277
        final int H = 640;
277 278

  
278
      Paint paint = new Paint();
279
      bmp = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
280
      Canvas canvas = new Canvas(bmp);
279
        Paint paint = new Paint();
280
        mBitmap = Bitmap.createBitmap(W,H, Bitmap.Config.ARGB_8888);
281
        Canvas canvas = new Canvas(mBitmap);
281 282

  
282
      paint.setAntiAlias(true);
283
      paint.setTextAlign(Paint.Align.CENTER);
284
      paint.setColor(0xff008800);
285
      paint.setStyle(Paint.Style.FILL);
286
      canvas.drawRect(0, 0, W, H, paint);
287
      paint.setColor(0xffffffff);
283
        paint.setAntiAlias(true);
284
        paint.setTextAlign(Paint.Align.CENTER);
285
        paint.setColor(0xff008800);
286
        paint.setStyle(Paint.Style.FILL);
287
        canvas.drawRect(0, 0, W, H, paint);
288
        paint.setColor(0xffffffff);
288 289

  
289
      for(int i=0; i<=mNumCols ; i++ )
290
        {
291
        canvas.drawRect(W*i/mNumCols - 1,                0,  W*i/mNumCols + 1,  H               , paint);
292
        canvas.drawRect(               0, H *i/mNumCols -1,  W               ,  H*i/mNumCols + 1, paint);
290
        for(int i=0; i<=mNumCols ; i++ )
291
          {
292
          canvas.drawRect(W*i/mNumCols - 1,                0,  W*i/mNumCols + 1,  H               , paint);
293
          canvas.drawRect(               0, H *i/mNumCols -1,  W               ,  H*i/mNumCols + 1, paint);
294
          }
293 295
        }
294 296
      }
295 297

  
296
    return bmp;
298
    return mBitmap;
297 299
    }
298 300

  
299 301
///////////////////////////////////////////////////////////////////////////////////////////////////
......
381 383
    firstScreen = false;
382 384

  
383 385
    Distorted.setMaxVertex(20);    // those have to be called before
384
    Distorted.setMaxFragment(10);  // any DistortedObject gets created!
386
    Distorted.setMaxFragment(3);   // any DistortedObject gets created!
385 387

  
386 388
    if( mObjectType==1 )
387 389
      {
388
      mObject = new DistortedBitmap(100,100,mNumCols);
390
      getBitmap();
391
      mObject = new DistortedBitmap(mBitmap.getWidth(),mBitmap.getHeight(),mNumCols);
389 392
      setEffectView();
390 393
      }
391 394
    else
......
429 432
                                            break;
430 433
      case R.id.objectpicker_spinnerBitmap: switch(pos)
431 434
                                              {
432
                                              case 0: mBitmap = -1        ; break;
433
                                              case 1: mBitmap = R.raw.face; break;
434
                                              case 2: mBitmap = R.raw.dog;  break;
435
                                              case 3: mBitmap = R.raw.cat;  break;
436
                                              case 4: mBitmap = R.raw.grid; break;
435
                                              case 0: mBitmapID = -1        ; break;
436
                                              case 1: mBitmapID = R.raw.face; break;
437
                                              case 2: mBitmapID = R.raw.dog ; break;
438
                                              case 3: mBitmapID = R.raw.cat ; break;
439
                                              case 4: mBitmapID = R.raw.grid; break;
440
                                              case 5: mBitmapID = R.raw.bean; break;
441
                                              case 6: mBitmapID = R.raw.monalisa; break;
437 442
                                              }
438 443
                                            break;
439 444
      case R.id.effects3dspinner          : mEffectAdd = pos;

Also available in: Unified diff