Project

General

Profile

Download (110 KB) Statistics
| Branch: | Revision:

library / src / main / java / org / distorted / library / DistortedObject.java @ d333eb6b

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted 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
// Distorted 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 Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library;
21

    
22
import android.graphics.Bitmap;
23
import android.opengl.GLES20;
24
import android.opengl.GLUtils;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
/**
28
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
29
 */
30
public abstract class DistortedObject 
31
{
32
    private static float[] mViewMatrix = new float[16];
33
   
34
    protected EffectQueueMatrix    mM;
35
    protected EffectQueueFragment  mF;
36
    protected EffectQueueVertex    mV;
37
    protected EffectQueueOther mO;
38

    
39
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
40
 
41
    protected GridObject mGrid = null;
42
    protected long mID;
43
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
44

    
45
    protected Bitmap[] mBmp= null; // 
46
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
47
    boolean[] mBitmapSet;          // 
48

    
49
///////////////////////////////////////////////////////////////////////////////////////////////////
50

    
51
    protected abstract DistortedObject deepCopy(int flags);
52

    
53
///////////////////////////////////////////////////////////////////////////////////////////////////
54

    
55
    protected void initializeData(int size)
56
      {
57
      mID             = DistortedObjectList.add(this);
58
      mSize           = size;
59
      mTextureDataH   = new int[1];
60
      mTextureDataH[0]= 0;
61
      mBmp            = new Bitmap[1];
62
      mBmp[0]         = null;
63
      mBitmapSet      = new boolean[1];
64
      mBitmapSet[0]   = false;
65
      
66
      initializeEffectLists(this,0);
67
      
68
      if( Distorted.isInitialized() ) resetTexture();    
69
      }
70
    
71
///////////////////////////////////////////////////////////////////////////////////////////////////
72
    
73
    protected void initializeEffectLists(DistortedObject d, int flags)
74
      {
75
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
76
        {
77
        mM = d.mM;
78
        matrixCloned = true;
79
        } 
80
      else
81
        {
82
        mM = new EffectQueueMatrix(d);
83
        matrixCloned = false;  
84
        }
85
    
86
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
87
        {
88
        mV = d.mV;
89
        vertexCloned = true;
90
        } 
91
      else
92
        {
93
        mV = new EffectQueueVertex(d);
94
        vertexCloned = false;  
95
        }
96
    
97
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
98
        {
99
        mF = d.mF;
100
        fragmentCloned = true;
101
        } 
102
      else
103
        {
104
        mF = new EffectQueueFragment(d);
105
        fragmentCloned = false;   
106
        }
107

    
108
      mO= new EffectQueueOther(d); // Other effects are never cloned.
109
      }
110
    
111
///////////////////////////////////////////////////////////////////////////////////////////////////
112
// this will be called on startup and every time OpenGL context has been lost
113
// also call this from the constructor if the OpenGL context has been created already.
114
    
115
    void resetTexture()
116
      {
117
      if( mTextureDataH!=null ) 
118
        {
119
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
120

    
121
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
122
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
123
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
124
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
125
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
126
       
127
        if( mBmp!=null && mBmp[0]!=null)
128
          {
129
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
130
          mBmp[0] = null;
131
          }
132
        }
133
      }
134
  
135
///////////////////////////////////////////////////////////////////////////////////////////////////
136
   
137
    void drawPriv(long currTime, DistortedProjection dp)
138
      {
139
      GLES20.glViewport(0, 0, dp.width, dp.height); 
140
      
141
      mM.compute(currTime);
142
      mM.send(mViewMatrix, dp);
143
      
144
      mV.compute(currTime);
145
      mV.postprocess();
146
      mV.send();
147
        
148
      mF.compute(currTime);
149
      mF.postprocess(mViewMatrix);
150
      mF.send();
151
       
152
      mGrid.draw();
153

    
154
      mO.send();
155
      }
156

    
157
///////////////////////////////////////////////////////////////////////////////////////////////////
158
   
159
    void drawNoEffectsPriv(DistortedProjection dp)
160
      {
161
      GLES20.glViewport(0, 0, dp.width, dp.height);
162
      mM.sendNoEffects(dp);
163
      mV.sendZero();
164
      mF.sendZero();
165
      mGrid.draw();
166
      }
167
    
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169
   
170
    void releasePriv()
171
      {
172
      if( matrixCloned  ==false) mM.abortAll();
173
      if( vertexCloned  ==false) mV.abortAll();
174
      if( fragmentCloned==false) mF.abortAll();
175

    
176
      mO.abortAll();
177

    
178
      mBmp          = null;
179
      mGrid         = null;
180
      mM            = null;
181
      mV            = null;
182
      mF            = null;
183
      mO            = null;
184
      mTextureDataH = null;
185
      }
186
 
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188

    
189
    long getBitmapID()
190
      {
191
      return mBmp==null ? 0 : mBmp.hashCode();
192
      }
193

    
194
///////////////////////////////////////////////////////////////////////////////////////////////////
195

    
196
  /**
197
   * Default empty constructor so that derived classes can call it
198
   */
199
    public DistortedObject()
200
      {
201

    
202
      }
203

    
204
///////////////////////////////////////////////////////////////////////////////////////////////////
205
  /**
206
   * Copy constructor used to create a DistortedObject based on various parts of another object.
207
   * <p>
208
   * Whatever we do not clone gets created just like in the default constructor.
209
   * We only call this from the descendant's classes' constructors where we have to pay attention
210
   * to give it the appropriate type of a DistortedObject!
211
   *
212
   * @param dc    Source object to create our object from
213
   * @param flags A bitmask of values specifying what to copy.
214
   *              For example, CLONE_BITMAP | CLONE_MATRIX.
215
   */
216
    public DistortedObject(DistortedObject dc, int flags)
217
      {
218
      initializeEffectLists(dc,flags);
219

    
220
      mID = DistortedObjectList.add(this);
221

    
222
      mSizeX = dc.mSizeX;
223
      mSizeY = dc.mSizeY;
224
      mSizeZ = dc.mSizeZ;
225
      mSize  = dc.mSize;
226
      mGrid  = dc.mGrid;
227

    
228
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
229
        {
230
        mTextureDataH = dc.mTextureDataH;
231
        mBmp          = dc.mBmp;
232
        mBitmapSet    = dc.mBitmapSet;
233
        }
234
      else
235
        {
236
        mTextureDataH   = new int[1];
237
        mTextureDataH[0]= 0;
238
        mBitmapSet      = new boolean[1];
239
        mBitmapSet[0]   = false;
240
        mBmp            = new Bitmap[1];
241
        mBmp[0]         = null;
242

    
243
        if( Distorted.isInitialized() ) resetTexture();
244
        }
245
      }
246

    
247
///////////////////////////////////////////////////////////////////////////////////////////////////
248
/**
249
 * Draw the DistortedObject to the location specified by current Matrix effects.    
250
 *     
251
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
252
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
253
 *        Object.
254
 */
255
   public void draw(long currTime)
256
     {
257
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
258
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
259
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
260
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
261
      
262
     drawPriv(currTime, Distorted.mProjection);
263
     }
264
 
265
///////////////////////////////////////////////////////////////////////////////////////////////////
266
/**
267
 * Releases all resources.
268
 */
269
   public synchronized void release()
270
     {
271
     releasePriv();  
272
     DistortedObjectList.remove(this);
273
     }
274

    
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
/**
277
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
278
 * <p>
279
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
280
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
281
 * 
282
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
283
 */
284
   
285
   public void setBitmap(Bitmap bmp)
286
     {
287
     mBitmapSet[0] = true; 
288
      
289
     if( Distorted.isInitialized() )
290
       {
291
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
292
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
293
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
294
       }
295
     else
296
       {
297
       mBmp[0] = bmp;  
298
       }
299
     }
300
    
301
///////////////////////////////////////////////////////////////////////////////////////////////////
302
/**
303
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
304
 * to one of the Effects that are currently applied to the DistortedBitmap.
305
 * 
306
 * @param el A class implementing the EffectListener interface that wants to get notifications.
307
 */
308
   public void addEventListener(EffectListener el)
309
     {
310
     mV.addListener(el);
311
     mF.addListener(el);
312
     mM.addListener(el);
313
     mO.addListener(el);
314
     }
315

    
316
///////////////////////////////////////////////////////////////////////////////////////////////////
317
/**
318
 * Removes the calling class from the list of Listeners.
319
 * 
320
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
321
 */
322
   public void removeEventListener(EffectListener el)
323
     {
324
     mV.removeListener(el);
325
     mF.removeListener(el);
326
     mM.removeListener(el);
327
     mO.removeListener(el);
328
     }
329
   
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331
/**
332
 * Returns the height of the DistortedObject.
333
 *    
334
 * @return height of the object, in pixels.
335
 */
336
   public int getWidth()
337
     {
338
     return mSizeX;   
339
     }
340

    
341
///////////////////////////////////////////////////////////////////////////////////////////////////
342
/**
343
 * Returns the width of the DistortedObject.
344
 * 
345
 * @return width of the Object, in pixels.
346
 */
347
    public int getHeight()
348
      {
349
      return mSizeY;  
350
      }
351
    
352
///////////////////////////////////////////////////////////////////////////////////////////////////
353
/**
354
 * Returns the depth of the DistortedObject.
355
 * 
356
 * @return depth of the Object, in pixels.
357
 */
358
    public int getDepth()
359
      {
360
      return mSizeZ;  
361
      }
362
        
363
///////////////////////////////////////////////////////////////////////////////////////////////////
364
/**
365
 * Returns unique ID of this instance.
366
 * 
367
 * @return ID of the object.
368
 */
369
    public long getID()
370
      {
371
      return mID;  
372
      }
373
    
374
///////////////////////////////////////////////////////////////////////////////////////////////////
375
/**
376
 * Aborts all Effects.
377
 * @return Number of effects aborted.
378
 */
379
    public int abortAllEffects()
380
      {
381
      return mM.abortAll() + mV.abortAll() + mF.abortAll() + mO.abortAll();
382
      }
383

    
384
///////////////////////////////////////////////////////////////////////////////////////////////////
385
/**
386
 * Aborts all Effects of a given type, for example all MATRIX Effects.
387
 * 
388
 * @param type one of the constants defined in {@link EffectTypes}
389
 * @return Number of effects aborted.
390
 */
391
    public int abortEffects(EffectTypes type)
392
      {
393
      switch(type)
394
        {
395
        case MATRIX  : return mM.abortAll();
396
        case VERTEX  : return mV.abortAll();
397
        case FRAGMENT: return mF.abortAll();
398
        case OTHER   : return mO.abortAll();
399
        default      : return 0;
400
        }
401
      }
402
    
403
///////////////////////////////////////////////////////////////////////////////////////////////////
404
/**
405
 * Aborts a single Effect.
406
 * 
407
 * @param id ID of the Effect we want to abort.
408
 * @return number of Effects aborted. Always either 0 or 1.
409
 */
410
    public int abortEffect(long id)
411
      {
412
      int type = (int)(id&EffectTypes.MASK);
413

    
414
      if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
415
      if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
416
      if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
417
      if( type==EffectTypes.OTHER.type    ) return mO.removeByID(id>>EffectTypes.LENGTH);
418

    
419
      return 0;
420
      }
421

    
422
///////////////////////////////////////////////////////////////////////////////////////////////////
423
/**
424
 * Abort all Effects of a given type, for example all rotations.
425
 * 
426
 * @param name one of the constants defined in {@link EffectNames}
427
 * @return number of Effects aborted.
428
 */
429
    public int abortEffects(EffectNames name)
430
      {
431
      switch(name.getType())
432
        {
433
        case MATRIX  : return mM.removeByType(name);
434
        case VERTEX  : return mV.removeByType(name);
435
        case FRAGMENT: return mF.removeByType(name);
436
        case OTHER   : return mO.removeByType(name);
437
        default      : return 0;
438
        }
439
      }
440
    
441
///////////////////////////////////////////////////////////////////////////////////////////////////
442
/**
443
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
444
 * 
445
 * @param id Effect ID we want to print info about
446
 * @return <code>true</code> if a single Effect of type effectType has been found.
447
 */
448
    
449
    public boolean printEffect(long id)
450
      {
451
      int type = (int)(id&EffectTypes.MASK);
452

    
453
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
454
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
455
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
456
      if( type==EffectTypes.OTHER.type    )  return mO.printByID(id>>EffectTypes.LENGTH);
457

    
458
      return false;
459
      }
460
   
461
///////////////////////////////////////////////////////////////////////////////////////////////////   
462
///////////////////////////////////////////////////////////////////////////////////////////////////
463
// Individual effect functions.
464
///////////////////////////////////////////////////////////////////////////////////////////////////
465
// Matrix-based effects
466
///////////////////////////////////////////////////////////////////////////////////////////////////
467
// MOVE
468
/**
469
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
470
 * 
471
 * @param di 3-dimensional Interpolator which at any given time will return a Float3D
472
 *           representing the current coordinates of the vector we want to move the Object with.
473
 * @return   ID of the effect added, or -1 if we failed to add one. 
474
 */
475
  public long move(Interpolator3D di)
476
    {   
477
    return mM.add(EffectNames.MOVE,null,di);  
478
    }
479

    
480
///////////////////////////////////////////////////////////////////////////////////////////////////
481
/**
482
 * Moves the Bitmap by a vector that smoothly changes from (0,0,0) to (x,y,z).
483
 *  
484
 * @param x        The x-coordinate of the vector we want to move the Object with. 
485
 * @param y        The y-coordinate of the vector we want to move the Object with.
486
 * @param z        The z-coordinate of the vector we want to move the Object with.
487
 * @param duration The time, in milliseconds, it takes to complete the movement.
488
 * @return         ID of the effect added, or -1 if we failed to add one. 
489
 */
490
  public long move(float x,float y,float z, int duration)
491
    {   
492
    Interpolator3D di = new Interpolator3D();  
493
    di.setCount(0.5f);
494
    di.setDuration(duration);
495
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
496
    di.add(new Float3D(x,y,z));                        
497

    
498
    return mM.add(EffectNames.MOVE,null,di);  
499
    }
500

    
501
///////////////////////////////////////////////////////////////////////////////////////////////////
502
/**
503
 * Moves the Bitmap by vector (x,y,z) immediately.
504
 *   
505
 * @param x The x-coordinate of the vector we want to move the Object with. 
506
 * @param y The y-coordinate of the vector we want to move the Object with.
507
 * @param z The z-coordinate of the vector we want to move the Object with.
508
 * @return  ID of the effect added, or -1 if we failed to add one. 
509
 */
510
  public long move(float x,float y,float z)
511
    {   
512
    return mM.add(EffectNames.MOVE,0.0f,0.0f,0.0f,x,y,z,0.0f);  
513
    }
514

    
515
///////////////////////////////////////////////////////////////////////////////////////////////////
516
// SCALE
517
/**
518
 * Scales the Object by factors that change in time as returned by the Interpolator.
519
 * 
520
 * @param di 3-dimensional Interpolator which at any given time returns a Float3D
521
 *           representing the current x- , y- and z- scale factors.
522
 * @return   ID of the effect added, or -1 if we failed to add one. 
523
 */
524
  public long scale(Interpolator3D di)
525
    {   
526
    return mM.add(EffectNames.SCALE,null,di);  
527
    }
528

    
529
///////////////////////////////////////////////////////////////////////////////////////////////////
530
/**
531
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
532
 * after 'duration' milliseconds. 
533
 *    
534
 * @param xscale   After time 'duration' passes, Bitmap's width will get multiplied by xscale; e.g. if 
535
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
536
 * @param yscale   Factor to scale Object's height with.
537
 * @param zscale   Factor to scale Object's depth with.
538
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
539
 * @return         ID of the effect added, or -1 if we failed to add one. 
540
 */
541
  public long scale(float xscale,float yscale,float zscale, int duration)
542
    {   
543
    Interpolator3D di = new Interpolator3D();  
544
    di.setCount(0.5f);
545
    di.setDuration(duration);
546
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
547
    di.add(new Float3D(xscale,yscale,zscale));                        
548

    
549
    return mM.add(EffectNames.SCALE,null,di);  
550
    }
551

    
552
///////////////////////////////////////////////////////////////////////////////////////////////////
553
/**
554
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
555
 *   
556
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
557
 *               xscale=2, the Object immediately becomes twice broader.
558
 * @param yscale factor to scale Object's height with.
559
 * @param zscale factor to scale Object's depth with. 
560
 * @return       ID of the effect added, or -1 if we failed to add one. 
561
 */
562
  public long scale(float xscale,float yscale,float zscale)
563
    {   
564
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,xscale,yscale,zscale,0.0f);  
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568
/**
569
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
570
 *   
571
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
572
 *              scale=2, the Object immediately becomes twice larger.
573
 * @return      ID of the effect added, or -1 if we failed to add one. 
574
 */
575
  public long scale(float scale)
576
    {   
577
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,scale,scale,scale,0.0f);  
578
    }
579
    
580
///////////////////////////////////////////////////////////////////////////////////////////////////
581
// ROTATE
582
/**
583
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
584
 * 
585
 * @param i 3-dimensional Interpolator which at any given time will return the current center of 
586
 *          the rotation
587
 * @param v 4-dimensional Interpolator which at any given time will return a Float4D
588
 *          representing the current rotation in the (angle,axisX,axisY,axisY) form. 
589
 * @return  ID of the effect added, or -1 if we failed to add one. 
590
 */
591
  public long rotate(Interpolator3D i, Interpolator4D v)
592
    {   
593
    return mM.add(EffectNames.ROTATE, i, v);  
594
    }
595

    
596
///////////////////////////////////////////////////////////////////////////////////////////////////  
597
/**
598
 * Rotates the Object around a static point, with angle and axis that change in time.
599
 * 
600
 * @param point Center of the rotation
601
 * @param v     4-dimensional Interpolator which at any given time will return a Float4D
602
 *              representing the current rotation in the (angle,axisX,axisY,axisY) form. 
603
 * @return      ID of the effect added, or -1 if we failed to add one. 
604
 */
605
  public long rotate(Float3D point, Interpolator4D v)
606
    {   
607
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v);  
608
    }
609
  
610
///////////////////////////////////////////////////////////////////////////////////////////////////  
611
/**
612
 * Rotates the Object around a static point, with angle that changes in time, around axis 
613
 * (axisX, axisY, axisZ). 
614
 * 
615
 * @param point Center of the rotation
616
 * @param v     1-dimensional Interpolator which at any given time will return the current rotation 
617
 *              angle.
618
 * @param axisX Rotation vector: x-coordinate
619
 * @param axisY Rotation vector: y-coordinate         
620
 * @param axisZ Rotation vector: z-coordinate         
621
 * @return      ID of the effect added, or -1 if we failed to add one. 
622
 */
623
  public long rotate(Float3D point, Interpolator1D v, float axisX, float axisY, float axisZ)
624
    {   
625
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v, axisX, axisY, axisZ);  
626
    }
627
  
628
///////////////////////////////////////////////////////////////////////////////////////////////////
629
/**
630
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
631
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
632
 * 
633
 * @param i 3-dimensional Interpolator which at any given time will return the current center
634
 *          of the rotation.
635
 * @param a 1-dimensional Interpolator which returns the current rotation angle.         
636
 * @return  ID of the effect added, or -1 if we failed to add one. 
637
 */
638
  public long rotate(Interpolator3D i, Interpolator1D a)
639
    {   
640
    return mM.add(EffectNames.ROTATE, i, a, 0.0f,0.0f,1.0f);  
641
    }
642

    
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
/**
645
 * Rotates the Object around a constant point, with angle that changes in time.  
646
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
647
 *   
648
 * @param point    Coordinates of the Point we are rotating around.
649
 * @param angle    Angle that we want to rotate the Bitmap to. Unit: degrees
650
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
651
 * @return         ID of the effect added, or -1 if we failed to add one. 
652
 */
653
  public long rotate(Float3D point, int angle, int duration)
654
    {   
655
    Interpolator1D di = new Interpolator1D();  
656
    di.setCount(0.5f);
657
    di.setDuration(duration);
658
    di.add(new Float1D(    0));                             
659
    di.add(new Float1D(angle));                        
660

    
661
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z, di, 0.0f,0.0f,1.0f);  
662
    }
663

    
664
///////////////////////////////////////////////////////////////////////////////////////////////////
665
/**
666
 * Rotates the Object immediately by 'angle' degrees around point p.   
667
 * Axis of rotation is given by the last 3 floats.
668
 *   
669
 * @param point Coordinates of the Point we are rotating around.
670
 * @param angle Angle that we want to rotate the Bitmap to. Unit: degrees
671
 * @param axisX Axis of rotation: x-coordinate
672
 * @param axisY Axis of rotation: y-coordinate
673
 * @param axisZ Axis of rotation: z-coordinate
674
 * @return      ID of the effect added, or -1 if we failed to add one. 
675
 */
676
  public long rotate(Float3D point, float angle, float axisX, float axisY, float axisZ)
677
    {   
678
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z, angle, axisX, axisY, axisZ);  
679
    }
680
  
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682
/**
683
 * Rotates the Object immediately by 'angle' degrees around point p.   
684
 *   
685
 * @param point  Coordinates of the Point we are rotating around.
686
 * @param angle  The angle that we want to rotate the Bitmap to. Unit: degrees
687
 * @return       ID of the effect added, or -1 if we failed to add one. 
688
 */
689
  public long rotate(Float3D point, int angle)
690
    {   
691
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z,angle,0.0f,0.0f,1.0f);  
692
    }
693

    
694
///////////////////////////////////////////////////////////////////////////////////////////////////
695
// QUATERNION
696
/**
697
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
698
 *   
699
 * @param point Coordinates of the Point we are rotating around.
700
 * @param qX    Quaternion: x-coordinate
701
 * @param qY    Quaternion: y-coordinate
702
 * @param qZ    Quaternion: z-coordinate
703
 * @param qW    Quaternion: w-coordinate
704
 * @return      ID of the effect added, or -1 if we failed to add one. 
705
 */
706
  public long quaternion(Float3D point, float qX, float qY, float qZ, float qW)
707
    {   
708
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,qX,qY,qZ,qW);   
709
    }
710

    
711
///////////////////////////////////////////////////////////////////////////////////////////////////
712
/**
713
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
714
 *   
715
 * @param point Coordinates of the Point we are rotating around.
716
 * @param iq    Interpolator that's going to, at any given moment, return a quaternion.
717
 * @return      ID of the effect added, or -1 if we failed to add one. 
718
 */
719
  public long quaternion(Float3D point, InterpolatorQuat iq)
720
    {   
721
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,iq);  
722
    }
723

    
724
///////////////////////////////////////////////////////////////////////////////////////////////////
725
/**
726
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
727
 *   
728
 * @param i  Interpolator that returns the current center of rotation.
729
 * @param iq Interpolator that's going to, at any given moment, return a quaternion representing the current rotation.
730
 * @return   ID of the effect added, or -1 if we failed to add one. 
731
 */
732
  public long quaternion(Interpolator3D i, InterpolatorQuat iq)
733
    {   
734
    return mM.add(EffectNames.QUATERNION,i,iq);  
735
    }
736
  
737
///////////////////////////////////////////////////////////////////////////////////////////////////
738
// SHEAR
739
/**
740
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
741
 * shearing along the Y-axis, 3D one along Z axis.
742
 *
743
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
744
 * @param di     1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2- 
745
 *               or 3-tuple of shear factors.
746
 * @return       ID of the effect added, or -1 if we failed to add one. 
747
 */
748
  public long shear(Float3D point, Interpolator di)
749
    {
750
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di);  
751
    }
752

    
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754
/**
755
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
756
 * 
757
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
758
 * @param vector ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with 
759
 *               which the X,Y and Z axis get slanted) 
760
 * @return       ID of the effect added, or -1 if we failed to add one. 
761
 */
762
  public long shear(Float3D point, Float3D vector)
763
    {
764
    Interpolator3D di = new Interpolator3D(); 
765
    di.setCount(0.5f);
766
    di.setDuration(0);
767
    di.add(new Float3D(0.0f,0.0f,0.0f));              
768
    di.add(vector);                                                
769
        
770
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di );  
771
    }
772

    
773
///////////////////////////////////////////////////////////////////////////////////////////////////
774
// Fragment-based effects  
775
///////////////////////////////////////////////////////////////////////////////////////////////////
776
// MACROBLOCK
777
/**
778
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
779
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
780
 * 
781
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
782
 * @param region Region this Effect is limited to.
783
 *               Null here means 'apply the effect to the whole Bitmap'.
784
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
785
 *               current center of the effect.
786
 * @return       ID of the effect added, or -1 if we failed to add one. 
787
 */
788
  public long macroblock(Interpolator1D a, Float4D region, Interpolator2D i)
789
    {
790
    return mF.add(EffectNames.MACROBLOCK, a, region, i);
791
    }
792

    
793
///////////////////////////////////////////////////////////////////////////////////////////////////
794
/**
795
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
796
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
797
 * <p>
798
 * The difference between this and the previous method is that here the center of the Effect stays constant.
799
 *    
800
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
801
 * @param region Region this Effect is limited to. 
802
 *               Null here means 'apply the effect to the whole Bitmap'.
803
 * @param point  Center of the Effect.
804
 * @return       ID of the effect added, or -1 if we failed to add one. 
805
 */
806
  public long macroblock(Interpolator1D a, Float4D region, Float2D point)
807
    {
808
    return mF.add(EffectNames.MACROBLOCK, a, region, point.x, point.y);
809
    }
810
  
811
///////////////////////////////////////////////////////////////////////////////////////////////////
812
/**
813
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
814
 * <p>
815
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
816
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
817
 * size is 1X1, i.e. 1 pixel).   
818
 * 
819
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
820
 * @param region   Region this Effect is limited to. 
821
 *                 Null here means 'apply the effect to the whole Bitmap'.
822
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D representing the
823
 *                 current center of the effect.
824
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
825
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
826
 * @return         ID of the effect added, or -1 if we failed to add one. 
827
 */
828
  public long macroblock(int pixels, Float4D region, Interpolator2D i, int duration, float count)
829
    {
830
    Interpolator1D di = new Interpolator1D();
831
    di.setCount(count);
832
    di.setDuration(duration);
833
    di.add(new Float1D(1));                             
834
    di.add(new Float1D(pixels));                        
835

    
836
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
837
    }
838

    
839
///////////////////////////////////////////////////////////////////////////////////////////////////
840
/**
841
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
842
 * <p>
843
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
844
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
845
 * size is 1X1, i.e. 1 pixel).   
846
 * <p>
847
 * The difference between this and the previous method is that here the center of the Effect stays constant.
848
 *    
849
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
850
 * @param region   Region this Effect is limited to. 
851
 *                 Null here means 'apply the effect to the whole Bitmap'.
852
 * @param point    Center of the Effect.
853
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
854
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
855
 * @return         ID of the effect added, or -1 if we failed to add one. 
856
 */
857
  public long macroblock(int pixels, Float4D region, Float2D point, int duration, float count)
858
    {
859
    Interpolator1D di = new Interpolator1D();
860
    di.setCount(count);
861
    di.setDuration(duration);
862
    di.add(new Float1D(1));                             
863
    di.add(new Float1D(pixels));                        
864

    
865
    return mF.add(EffectNames.MACROBLOCK, di, region, point.x, point.y);
866
    }
867

    
868
///////////////////////////////////////////////////////////////////////////////////////////////////
869
/**
870
 * Creates macroblocks on the whole Bitmap. 
871
 * <p>
872
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
873
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
874
 * size is 1X1, i.e. 1 pixel).   
875
 * <p>
876
 * The difference between this and the previous method is that here there is no masking Region; thus
877
 * there is also no center of the Effect. 
878
 *    
879
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
880
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
881
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
882
 * @return         ID of the effect added, or -1 if we failed to add one. 
883
 */
884
  public long macroblock(int pixels, int duration, float count) 
885
    {
886
    Interpolator1D di = new Interpolator1D(); 
887
    di.setCount(count);
888
    di.setDuration(duration);
889
    di.add(new Float1D(1));                            
890
    di.add(new Float1D(pixels));                        
891
   
892
    return mF.add(EffectNames.MACROBLOCK, di, null, 0.0f, 0.0f);
893
    }
894

    
895
///////////////////////////////////////////////////////////////////////////////////////////////////
896
///////////////////////////////////////////////////////////////////////////////////////////////////
897
// CHROMA
898
/**
899
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
900
 *        
901
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be
902
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
903
 * @param color  Color to mix. (1,0,0) is RED.
904
 * @param region Region this Effect is limited to. 
905
 *               Null here means 'apply the Effect to the whole Bitmap'.
906
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing 
907
 *               the current center of the effect.
908
 * @return       ID of the effect added, or -1 if we failed to add one. 
909
 */
910
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
911
    {
912
    return mF.add(EffectNames.CHROMA, t, color, region, i);
913
    }
914

    
915
///////////////////////////////////////////////////////////////////////////////////////////////////
916
/**
917
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
918
 * <p>
919
 * Here the center of the Effect stays constant.
920
 *         
921
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be 
922
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
923
 * @param color  Color to mix. (1,0,0) is RED.
924
 * @param region Region this Effect is limited to. 
925
 *               Null here means 'apply the Effect to the whole Bitmap'.
926
 * @param point  Center of the Effect.
927
 * @return       ID of the effect added, or -1 if we failed to add one. 
928
 */
929
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
930
    {
931
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
932
    }
933

    
934
///////////////////////////////////////////////////////////////////////////////////////////////////  
935
/**
936
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
937
 *        
938
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
939
 *               pixel = (1-t)*pixel + t*color
940
 * @param color  Color to mix. (1,0,0) is RED.
941
 * @param region Region this Effect is limited to.
942
 *               Null here means 'apply the Effect to the whole Bitmap'.
943
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
944
 *               current center of the effect.
945
 * @return       ID of the effect added, or -1 if we failed to add one. 
946
 */
947
  public long chroma(float t, Float3D color, Float4D region, Interpolator2D i)
948
    {
949
    return mF.add(EffectNames.CHROMA, t, color, region, i);
950
    }
951

    
952
///// //////////////////////////////////////////////////////////////////////////////////////////////
953
/**
954
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
955
 * <p>
956
 * Here the center of the Effect stays constant.
957
 *         
958
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
959
 *               pixel = (1-t)*pixel + t*color
960
 * @param color  Color to mix. (1,0,0) is RED.
961
 * @param region The Region this Effect is limited to. 
962
 *               Null here means 'apply the Effect to the whole Bitmap'.
963
 * @param point  Center of the Effect.
964
 * @return       ID of the effect added, or -1 if we failed to add one. 
965
 */
966
  public long chroma(float t, Float3D color, Float4D region, Float2D point)
967
    {
968
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
969
    }
970

    
971
///////////////////////////////////////////////////////////////////////////////////////////////////
972
/**
973
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
974
 * <p>
975
 * Here the Effect applies to the whole bitmap.
976
 *         
977
 * @param t     Level of blend a given pixel will be mixed with the next parameter 'color': 
978
 *              pixel = (1-t)*pixel + t*color
979
 * @param color Color to mix. (1,0,0) is RED.
980
 * @return      ID of the effect added, or -1 if we failed to add one. 
981
 */
982
  public long chroma(float t, Float3D color)
983
    {
984
    return mF.add(EffectNames.CHROMA, t, color, null, 0, 0);
985
    }
986

    
987
///////////////////////////////////////////////////////////////////////////////////////////////////  
988
/**
989
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
990
 * 
991
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
992
 */
993
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
994
    {
995
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
996
    }
997

    
998
///////////////////////////////////////////////////////////////////////////////////////////////////
999
/**
1000
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1001
 * 
1002
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
1003
 */
1004
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
1005
    {
1006
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
1007
    }
1008
  
1009
///////////////////////////////////////////////////////////////////////////////////////////////////  
1010
/**
1011
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1012
 * 
1013
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
1014
 */
1015
  public long smooth_chroma(float t, Float3D color, Float4D region, Interpolator2D i)
1016
    {
1017
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
1018
    }
1019

    
1020
///////////////////////////////////////////////////////////////////////////////////////////////////
1021
/**
1022
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1023
 * 
1024
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
1025
 */
1026
  public long smooth_chroma(float t, Float3D color, Float4D region, Float2D point)
1027
    {
1028
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
1029
    }
1030
  
1031
///////////////////////////////////////////////////////////////////////////////////////////////////
1032
/**
1033
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1034
 * 
1035
 * See {@link #chroma(float, Float3D)}
1036
 */
1037
  public long smooth_chroma(float t, Float3D color)
1038
    {
1039
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, null, 0, 0);
1040
    }
1041
  
1042
///////////////////////////////////////////////////////////////////////////////////////////////////
1043
///////////////////////////////////////////////////////////////////////////////////////////////////
1044
// ALPHA
1045
/**
1046
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1047
 *        
1048
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
1049
 *               moment.
1050
 * @param region Region this Effect is limited to. 
1051
 *               Null here means 'apply the Effect to the whole Bitmap'.
1052
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1053
 *               current center of the effect.
1054
 * @return       ID of the effect added, or -1 if we failed to add one. 
1055
 */
1056
  public long alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1057
    {
1058
    return mF.add(EffectNames.ALPHA, a, region, i);
1059
    }
1060

    
1061
///////////////////////////////////////////////////////////////////////////////////////////////////
1062
/**
1063
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1064
 * <p>
1065
 * Here the center of the Effect stays constant.
1066
 *         
1067
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
1068
 *               moment.
1069
 * @param region Region this Effect is limited to. 
1070
 *               Null here means 'apply the Effect to the whole Bitmap'.
1071
 * @param point  Center of the Effect.
1072
 * @return       ID of the effect added, or -1 if we failed to add one. 
1073
 */
1074
  public long alpha(Interpolator1D a, Float4D region, Float2D point)
1075
    {
1076
    return mF.add(EffectNames.ALPHA, a, region, point.x, point.y);
1077
    }
1078

    
1079
///////////////////////////////////////////////////////////////////////////////////////////////////  
1080
/**
1081
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1082
 *        
1083
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1084
 * @param region Region this Effect is limited to. 
1085
 *               Null here means 'apply the Effect to the whole Bitmap'.
1086
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1087
 *               current center of the effect.
1088
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1089
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1090
 * @return       ID of the effect added, or -1 if we failed to add one. 
1091
 */
1092
  public long alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1093
    {
1094
    Interpolator1D di = new Interpolator1D(); 
1095
    di.setCount(count);
1096
    di.setDuration(duration);
1097
    di.add(new Float1D(1));                          
1098
    di.add(new Float1D(alpha));                         
1099
   
1100
    return mF.add(EffectNames.ALPHA, di, region, i);
1101
    }
1102

    
1103
///////////////////////////////////////////////////////////////////////////////////////////////////
1104
/**
1105
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1106
 * <p>
1107
 * Here the center of the Effect stays constant.
1108
 *         
1109
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1110
 * @param region Region this Effect is limited to. 
1111
 *               Null here means 'apply the Effect to the whole Bitmap'.
1112
 * @param point  Center of the Effect.
1113
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1114
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1115
 * @return       ID of the effect added, or -1 if we failed to add one. 
1116
 */
1117
  public long alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1118
    {
1119
    Interpolator1D di = new Interpolator1D(); 
1120
    di.setCount(count);
1121
    di.setDuration(duration);
1122
    di.add(new Float1D(1));                          
1123
    di.add(new Float1D(alpha));                         
1124
   
1125
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1126
    }
1127

    
1128
///////////////////////////////////////////////////////////////////////////////////////////////////
1129
/**
1130
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1131
 * <p>
1132
 * Here the center of the Effect stays constant and the effect for now change in time.
1133
 *         
1134
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1135
 * @param region Region this Effect is limited to.
1136
 *               Null here means 'apply the Effect to the whole Bitmap'.
1137
 * @param point  Center of the Effect.
1138
 * @return       ID of the effect added, or -1 if we failed to add one. 
1139
 */
1140
  public long alpha(float alpha, Float4D region, Float2D point)
1141
    {
1142
    Interpolator1D di = new Interpolator1D(); 
1143
    di.setCount(0.5f);
1144
    di.setDuration(0);
1145
    di.add(new Float1D(1));                          
1146
    di.add(new Float1D(alpha));                         
1147
   
1148
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1149
    }
1150
  
1151
///////////////////////////////////////////////////////////////////////////////////////////////////
1152
/**
1153
 * Makes the whole Bitmap change its transparency level.
1154
 * 
1155
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1156
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1157
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1158
 * @return         ID of the effect added, or -1 if we failed to add one. 
1159
 */
1160
  public long alpha(float alpha, int duration, float count) 
1161
    {
1162
    Interpolator1D di = new Interpolator1D(); 
1163
    di.setCount(count);
1164
    di.setDuration(duration);
1165
    di.add(new Float1D(1));                            
1166
    di.add(new Float1D(alpha));                        
1167
         
1168
    return mF.add(EffectNames.ALPHA, di,null, 0.0f, 0.0f);
1169
    }
1170

    
1171
///////////////////////////////////////////////////////////////////////////////////////////////////  
1172
/**
1173
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1174
 * 
1175
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1176
 */
1177
  public long smooth_alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1178
    {
1179
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, i);
1180
    }
1181

    
1182
///////////////////////////////////////////////////////////////////////////////////////////////////
1183
/**
1184
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1185
 * 
1186
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1187
 */
1188
  public long smooth_alpha(Interpolator1D a, Float4D region, Float2D point)
1189
    {
1190
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, point.x, point.y);
1191
    }
1192
  
1193
///////////////////////////////////////////////////////////////////////////////////////////////////  
1194
/**
1195
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1196
 * 
1197
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1198
 */
1199
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1200
    {
1201
    Interpolator1D di = new Interpolator1D(); 
1202
    di.setCount(count);
1203
    di.setDuration(duration);
1204
    di.add(new Float1D(1));                          
1205
    di.add(new Float1D(alpha));                         
1206
   
1207
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, i);
1208
    }
1209

    
1210
///////////////////////////////////////////////////////////////////////////////////////////////////
1211
/**
1212
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1213
 * 
1214
 * See {@link #alpha(float, Float4D, Float2D, int, float)}
1215
 */
1216
  public long smooth_alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1217
    {
1218
    Interpolator1D di = new Interpolator1D(); 
1219
    di.setCount(count);
1220
    di.setDuration(duration);
1221
    di.add(new Float1D(1));                          
1222
    di.add(new Float1D(alpha));                         
1223
   
1224
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1225
    }
1226
  
1227
///////////////////////////////////////////////////////////////////////////////////////////////////
1228
/**
1229
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1230
 * 
1231
 * See {@link #alpha(float, Float4D, Float2D)}
1232
 */
1233
  public long smooth_alpha(float alpha, Float4D region, Float2D point)
1234
    {
1235
    Interpolator1D di = new Interpolator1D(); 
1236
    di.setCount(0.5f);
1237
    di.setDuration(0);
1238
    di.add(new Float1D(1));                          
1239
    di.add(new Float1D(alpha));                         
1240
   
1241
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1242
    }
1243
  
1244
///////////////////////////////////////////////////////////////////////////////////////////////////
1245
///////////////////////////////////////////////////////////////////////////////////////////////////
1246
// BRIGHTNESS
1247
/**
1248
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1249
 *        
1250
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1251
 *               moment.
1252
 * @param region Region this Effect is limited to. 
1253
 *               Null here means 'apply the Effect to the whole Bitmap'.
1254
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1255
 *               current center of the effect.
1256
 * @return       ID of the effect added, or -1 if we failed to add one. 
1257
 */
1258
  public long brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1259
    {
1260
    return mF.add(EffectNames.BRIGHTNESS, a, region, i);
1261
    }
1262

    
1263
///////////////////////////////////////////////////////////////////////////////////////////////////
1264
/**
1265
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1266
 * <p>
1267
 * Here the center of the Effect stays constant.
1268
 *         
1269
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1270
 *               moment.
1271
 * @param region Region this Effect is limited to.
1272
 *               Null here means 'apply the Effect to the whole Bitmap'.
1273
 * @param point  Center of the Effect.
1274
 * @return       ID of the effect added, or -1 if we failed to add one. 
1275
 */
1276
  public long brightness(Interpolator1D a, Float4D region, Float2D point)
1277
    {
1278
    return mF.add(EffectNames.BRIGHTNESS, a, region, point.x, point.y);
1279
    }
1280

    
1281
///////////////////////////////////////////////////////////////////////////////////////////////////  
1282
/**
1283
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1284
 *        
1285
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1286
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1287
 *                   anything more than 1- lighten it up. 
1288
 * @param region     Region this Effect is limited to.
1289
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1290
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1291
 *                   representing the current center of the effect.
1292
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1293
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1294
 * @return           ID of the effect added, or -1 if we failed to add one. 
1295
 */
1296
  public long brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1297
    {
1298
    Interpolator1D di = new Interpolator1D(); 
1299
    di.setCount(count);
1300
    di.setDuration(duration);
1301
    di.add(new Float1D(1));                          
1302
    di.add(new Float1D(brightness));                         
1303
   
1304
    return mF.add(EffectNames.BRIGHTNESS, di, region, i);
1305
    }
1306

    
1307
///////////////////////////////////////////////////////////////////////////////////////////////////
1308
/**
1309
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1310
 * <p>
1311
 * Here the center of the Effect stays constant.
1312
 *         
1313
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1314
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1315
 *                   anything more than 1 - lighten it up.
1316
 * @param region     Region this Effect is limited to. 
1317
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1318
 * @param point      Center of the Effect.
1319
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1320
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1321
 * @return           ID of the effect added, or -1 if we failed to add one. 
1322
 */
1323
  public long brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1324
    {
1325
    Interpolator1D di = new Interpolator1D(); 
1326
    di.setCount(count);
1327
    di.setDuration(duration);
1328
    di.add(new Float1D(1));                          
1329
    di.add(new Float1D(brightness));                         
1330
   
1331
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1332
    }
1333

    
1334
///////////////////////////////////////////////////////////////////////////////////////////////////
1335
/**
1336
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1337
 * <p>
1338
 * Here the center of the Effect stays constant and the effect for now change in time.
1339
 *         
1340
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1341
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1342
 *                   anything more than 1 - lighten it up.
1343
 * @param region     Region this Effect is limited to.
1344
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1345
 * @param point      Center of the Effect.
1346
 * @return           ID of the effect added, or -1 if we failed to add one. 
1347
 */
1348
  public long brightness(float brightness, Float4D region, Float2D point)
1349
    {
1350
    Interpolator1D di = new Interpolator1D(); 
1351
    di.setCount(0.5f);
1352
    di.setDuration(0);
1353
    di.add(new Float1D(1));                          
1354
    di.add(new Float1D(brightness));                         
1355
   
1356
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1357
    }
1358
 
1359
///////////////////////////////////////////////////////////////////////////////////////////////////
1360
///////////////////////////////////////////////////////////////////////////////////////////////////
1361
// SMOOTH BRIGHTNESS
1362
/**
1363
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1364
 *        
1365
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1366
 *               any given moment.
1367
 * @param region Region this Effect is limited to. 
1368
 *               Null here means 'apply the Effect to the whole Bitmap'.
1369
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1370
 *               representing the current center of the effect.
1371
 * @return       ID of the effect added, or -1 if we failed to add one. 
1372
 */
1373
  public long smooth_brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1374
    {
1375
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, i);
1376
    }
1377

    
1378
///////////////////////////////////////////////////////////////////////////////////////////////////
1379
/**
1380
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1381
 * <p>
1382
 * Here the center of the Effect stays constant.
1383
 *         
1384
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1385
 *               any given moment.
1386
 * @param region Region this Effect is limited to. 
1387
 *               Null here means 'apply the Effect to the whole Bitmap'.
1388
 * @param point  Center of the Effect.
1389
 * @return       ID of the effect added, or -1 if we failed to add one. 
1390
 */
1391
  public long smooth_brightness(Interpolator1D a, Float4D region, Float2D point)
1392
    {
1393
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, point.x, point.y);
1394
    }
1395

    
1396
///////////////////////////////////////////////////////////////////////////////////////////////////  
1397
/**
1398
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1399
 *        
1400
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1401
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1402
 *                   anything more than 1 - lighten it up. 
1403
 * @param region     Region this Effect is limited to. 
1404
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1405
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1406
 *                   represention the current center of the effect.
1407
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1408
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1409
 * @return           ID of the effect added, or -1 if we failed to add one. 
1410
 */
1411
  public long smooth_brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1412
    {
1413
    Interpolator1D di = new Interpolator1D(); 
1414
    di.setCount(count);
1415
    di.setDuration(duration);
1416
    di.add(new Float1D(1));                          
1417
    di.add(new Float1D(brightness));                         
1418
   
1419
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, i);
1420
    }
1421

    
1422
///////////////////////////////////////////////////////////////////////////////////////////////////
1423
/**
1424
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1425
 * <p>
1426
 * Here the center of the Effect stays constant.
1427
 *         
1428
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1429
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1430
 *                   anything more than 1 - lighten it up.
1431
 * @param region     Region this Effect is limited to. 
1432
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1433
 * @param point      Center of the Effect.
1434
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1435
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1436
 * @return           ID of the effect added, or -1 if we failed to add one. 
1437
 */
1438
  public long smooth_brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1439
    {
1440
    Interpolator1D di = new Interpolator1D(); 
1441
    di.setCount(count);
1442
    di.setDuration(duration);
1443
    di.add(new Float1D(1));                          
1444
    di.add(new Float1D(brightness));                         
1445
   
1446
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1447
    }
1448

    
1449
///////////////////////////////////////////////////////////////////////////////////////////////////
1450
/**
1451
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1452
 * <p>
1453
 * Here the center of the Effect stays constant and the effect for now change in time.
1454
 *         
1455
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1456
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1457
 *                   anything more than 1 - lighten it up.
1458
 * @param region     Region this Effect is limited to. 
1459
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1460
 * @param point      Center of the Effect.
1461
 * @return           ID of the effect added, or -1 if we failed to add one. 
1462
 */
1463
  public long smooth_brightness(float brightness, Float4D region, Float2D point)
1464
    {
1465
    Interpolator1D di = new Interpolator1D(); 
1466
    di.setCount(0.5f);
1467
    di.setDuration(0);
1468
    di.add(new Float1D(1));                          
1469
    di.add(new Float1D(brightness));                         
1470
   
1471
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1472
    }
1473
    
1474
///////////////////////////////////////////////////////////////////////////////////////////////////
1475
/**
1476
 * Makes the whole Bitmap change its brightness level.
1477
 * 
1478
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1479
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1480
 *                   anything more than 1- lighten it up.
1481
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1482
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1483
 * @return           ID of the effect added, or -1 if we failed to add one. 
1484
 */
1485
  public long smooth_brightness(float brightness, int duration, float count) 
1486
    {
1487
    Interpolator1D di = new Interpolator1D(); 
1488
    di.setCount(count);
1489
    di.setDuration(duration);
1490
    di.add(new Float1D(1));                            
1491
    di.add(new Float1D(brightness));                        
1492
         
1493
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, 0.0f, 0.0f);
1494
    }
1495

    
1496
///////////////////////////////////////////////////////////////////////////////////////////////////
1497
///////////////////////////////////////////////////////////////////////////////////////////////////
1498
// CONTRAST
1499
/**
1500
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1501
 *        
1502
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1503
 *               at any given moment.
1504
 * @param region Region this Effect is limited to. 
1505
 *               Null here means 'apply the Effect to the whole Bitmap'.
1506
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1507
 *               representing the current center of the effect.
1508
 * @return       ID of the effect added, or -1 if we failed to add one. 
1509
 */
1510
  public long contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1511
    {
1512
    return mF.add(EffectNames.CONTRAST, a, region, i);
1513
    }
1514

    
1515
///////////////////////////////////////////////////////////////////////////////////////////////////
1516
/**
1517
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1518
 * <p>
1519
 * Here the center of the Effect stays constant.
1520
 *         
1521
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1522
 *               at any given moment.
1523
 * @param region Region this Effect is limited to.
1524
 *               Null here means 'apply the Effect to the whole Bitmap'.
1525
 * @param point  Center of the Effect.
1526
 * @return       ID of the effect added, or -1 if we failed to add one. 
1527
 */
1528
  public long contrast(Interpolator1D a, Float4D region, Float2D point)
1529
    {
1530
    return mF.add(EffectNames.CONTRAST, a, region, point.x, point.y);
1531
    }
1532

    
1533
///////////////////////////////////////////////////////////////////////////////////////////////////  
1534
/**
1535
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1536
 *        
1537
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1538
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1539
 *                 anything more than 1 - increase the contrast. 
1540
 * @param region   Region this Effect is limited to.
1541
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1542
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1543
 *                 represention the current center of the effect.
1544
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1545
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1546
 * @return         ID of the effect added, or -1 if we failed to add one. 
1547
 */
1548
  public long contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1549
    {
1550
    Interpolator1D di = new Interpolator1D(); 
1551
    di.setCount(count);
1552
    di.setDuration(duration);
1553
    di.add(new Float1D(1));                          
1554
    di.add(new Float1D(contrast));                         
1555
   
1556
    return mF.add(EffectNames.CONTRAST, di, region, i);
1557
    }
1558

    
1559
///////////////////////////////////////////////////////////////////////////////////////////////////
1560
/**
1561
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1562
 * <p>
1563
 * Here the center of the Effect stays constant.
1564
 *         
1565
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1566
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1567
 *                 anything more than 1 -increase the contrast. 
1568
 * @param region   Region this Effect is limited to. 
1569
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1570
 * @param point    Center of the Effect.
1571
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1572
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1573
 * @return         ID of the effect added, or -1 if we failed to add one. 
1574
 */
1575
  public long contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1576
    {
1577
    Interpolator1D di = new Interpolator1D(); 
1578
    di.setCount(count);
1579
    di.setDuration(duration);
1580
    di.add(new Float1D(1));                          
1581
    di.add(new Float1D(contrast));                         
1582
   
1583
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1584
    }
1585

    
1586
///////////////////////////////////////////////////////////////////////////////////////////////////
1587
/**
1588
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1589
 * <p>
1590
 * Here the center of the Effect stays constant and the effect for now change in time.
1591
 *         
1592
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1593
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1594
 *                 anything more than 1 - increase the contrast. 
1595
 * @param region   Region this Effect is limited to. 
1596
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1597
 * @param point    Center of the Effect.
1598
 * @return         ID of the effect added, or -1 if we failed to add one. 
1599
 */
1600
  public long contrast(float contrast, Float4D region, Float2D point)
1601
    {
1602
    Interpolator1D di = new Interpolator1D(); 
1603
    di.setCount(0.5f);
1604
    di.setDuration(0);
1605
    di.add(new Float1D(1));                          
1606
    di.add(new Float1D(contrast));                         
1607
   
1608
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1609
    }
1610
 
1611
///////////////////////////////////////////////////////////////////////////////////////////////////
1612
///////////////////////////////////////////////////////////////////////////////////////////////////
1613
// SMOOTH CONTRAST
1614
/**
1615
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1616
 *        
1617
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1618
 *               at any given moment.
1619
 * @param region Region this Effect is limited to. 
1620
 *               Null here means 'apply the Effect to the whole Bitmap'.
1621
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1622
 *               representing the current center of the effect.
1623
 * @return       ID of the effect added, or -1 if we failed to add one. 
1624
 */
1625
  public long smooth_contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1626
    {
1627
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, i);
1628
    }
1629

    
1630
///////////////////////////////////////////////////////////////////////////////////////////////////
1631
/**
1632
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1633
 * <p>
1634
 * Here the center of the Effect stays constant.
1635
 *         
1636
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1637
 *               at any given moment.
1638
 * @param region Region this Effect is limited to. 
1639
 *               Null here means 'apply the Effect to the whole Bitmap'.
1640
 * @param point  Center of the Effect.
1641
 * @return       ID of the effect added, or -1 if we failed to add one. 
1642
 */
1643
  public long smooth_contrast(Interpolator1D a, Float4D region, Float2D point)
1644
    {
1645
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, point.x, point.y);
1646
    }
1647

    
1648
///////////////////////////////////////////////////////////////////////////////////////////////////  
1649
/**
1650
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1651
 *        
1652
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1653
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1654
 *                 anything more than 1 - increase the contrast. 
1655
 * @param region   Region this Effect is limited to. 
1656
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1657
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1658
 *                 representing the current center of the effect.
1659
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1660
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1661
 * @return         ID of the effect added, or -1 if we failed to add one. 
1662
 */
1663
  public long smooth_contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1664
    {
1665
    Interpolator1D di = new Interpolator1D(); 
1666
    di.setCount(count);
1667
    di.setDuration(duration);
1668
    di.add(new Float1D(1));                          
1669
    di.add(new Float1D(contrast));                         
1670
   
1671
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, i);
1672
    }
1673

    
1674
///////////////////////////////////////////////////////////////////////////////////////////////////
1675
/**
1676
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1677
 * <p>
1678
 * Here the center of the Effect stays constant.
1679
 *         
1680
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1681
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1682
 *                 anything more than 1 - increase the contrast. 
1683
 * @param region   Region this Effect is limited to. 
1684
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1685
 * @param point    Center of the Effect.
1686
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1687
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1688
 * @return         ID of the effect added, or -1 if we failed to add one. 
1689
 */
1690
  public long smooth_contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1691
    {
1692
    Interpolator1D di = new Interpolator1D(); 
1693
    di.setCount(count);
1694
    di.setDuration(duration);
1695
    di.add(new Float1D(1));                          
1696
    di.add(new Float1D(contrast));                         
1697
   
1698
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1699
    }
1700

    
1701
///////////////////////////////////////////////////////////////////////////////////////////////////
1702
/**
1703
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1704
 * <p>
1705
 * Here the center of the Effect stays constant and the effect for now change in time.
1706
 *         
1707
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1708
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1709
 *                 anything more than 1 - increase the contrast. 
1710
 * @param region   Region this Effect is limited to. 
1711
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1712
 * @param point    Center of the Effect.
1713
 * @return         ID of the effect added, or -1 if we failed to add one. 
1714
 */
1715
  public long smooth_contrast(float contrast, Float4D region, Float2D point)
1716
    {
1717
    Interpolator1D di = new Interpolator1D(); 
1718
    di.setCount(0.5f);
1719
    di.setDuration(0);
1720
    di.add(new Float1D(1));                          
1721
    di.add(new Float1D(contrast));                         
1722
   
1723
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1724
    }
1725
    
1726
///////////////////////////////////////////////////////////////////////////////////////////////////
1727
/**
1728
 * Makes the whole Bitmap change its contrast level.
1729
 * 
1730
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1731
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1732
 *                 anything omre than 1 - increase the contrast. 
1733
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1734
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1735
 * @return         ID of the effect added, or -1 if we failed to add one. 
1736
 */
1737
  public long smooth_contrast(float contrast, int duration, float count) 
1738
    {
1739
    Interpolator1D di = new Interpolator1D(); 
1740
    di.setCount(count);
1741
    di.setDuration(duration);
1742
    di.add(new Float1D(1));                            
1743
    di.add(new Float1D(contrast));                        
1744
         
1745
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, 0.0f, 0.0f);
1746
    }
1747

    
1748

    
1749
///////////////////////////////////////////////////////////////////////////////////////////////////
1750
///////////////////////////////////////////////////////////////////////////////////////////////////
1751
// SATURATION
1752
/**
1753
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1754
 *        
1755
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1756
 *               at any given moment.
1757
 * @param region Region this Effect is limited to. 
1758
 *               Null here means 'apply the Effect to the whole Bitmap'.
1759
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1760
 *               representing the current center of the effect.
1761
 * @return       ID of the effect added, or -1 if we failed to add one. 
1762
 */
1763
  public long saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1764
    {
1765
    return mF.add(EffectNames.SATURATION, a, region, i);
1766
    }
1767

    
1768
///////////////////////////////////////////////////////////////////////////////////////////////////
1769
/**
1770
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1771
 * <p>
1772
 * Here the center of the Effect stays constant.
1773
 *         
1774
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1775
 *               at any given moment.
1776
 * @param region Region this Effect is limited to. 
1777
 *               Null here means 'apply the Effect to the whole Bitmap'.
1778
 * @param point  Center of the Effect.
1779
 * @return       ID of the effect added, or -1 if we failed to add one. 
1780
 */
1781
  public long saturation(Interpolator1D a, Float4D region, Float2D point)
1782
    {
1783
    return mF.add(EffectNames.SATURATION, a, region, point.x, point.y);
1784
    }
1785

    
1786
///////////////////////////////////////////////////////////////////////////////////////////////////  
1787
/**
1788
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1789
 *        
1790
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1791
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1792
 *                   anything more than 1 - increase the saturation. 
1793
 * @param region     Region this Effect is limited to.
1794
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1795
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1796
 *                   representing the current center of the effect.
1797
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1798
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1799
 * @return           ID of the effect added, or -1 if we failed to add one. 
1800
 */
1801
  public long saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1802
    {
1803
    Interpolator1D di = new Interpolator1D(); 
1804
    di.setCount(count);
1805
    di.setDuration(duration);
1806
    di.add(new Float1D(1));                          
1807
    di.add(new Float1D(saturation));                         
1808
   
1809
    return mF.add(EffectNames.SATURATION, di, region, i);
1810
    }
1811

    
1812
///////////////////////////////////////////////////////////////////////////////////////////////////
1813
/**
1814
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1815
 * <p>
1816
 * Here the center of the Effect stays constant.
1817
 *         
1818
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1819
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1820
 *                   anything more than 1 - increase the saturation. 
1821
 * @param region     Region this Effect is limited to. 
1822
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1823
 * @param point      Center of the Effect.
1824
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1825
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1826
 * @return           ID of the effect added, or -1 if we failed to add one. 
1827
 */
1828
  public long saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1829
    {
1830
    Interpolator1D di = new Interpolator1D(); 
1831
    di.setCount(count);
1832
    di.setDuration(duration);
1833
    di.add(new Float1D(1));                          
1834
    di.add(new Float1D(saturation));                         
1835
   
1836
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1837
    }
1838

    
1839
///////////////////////////////////////////////////////////////////////////////////////////////////
1840
/**
1841
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1842
 * <p>
1843
 * Here the center of the Effect stays constant and the effect for now change in time.
1844
 *         
1845
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1846
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1847
 *                   anything more than 1- increase the saturation. 
1848
 * @param region     Region this Effect is limited to. 
1849
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1850
 * @param point      Center of the Effect.
1851
 * @return           ID of the effect added, or -1 if we failed to add one. 
1852
 */
1853
  public long saturation(float saturation, Float4D region, Float2D point)
1854
    {
1855
    Interpolator1D di = new Interpolator1D(); 
1856
    di.setCount(0.5f);
1857
    di.setDuration(0);
1858
    di.add(new Float1D(1));                          
1859
    di.add(new Float1D(saturation));                         
1860
   
1861
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1862
    }
1863
 
1864
///////////////////////////////////////////////////////////////////////////////////////////////////
1865
///////////////////////////////////////////////////////////////////////////////////////////////////
1866
// SMOOTH_SATURATION
1867
/**
1868
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1869
 *        
1870
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1871
 *               at any given moment.
1872
 * @param region Region this Effect is limited to. 
1873
 *               Null here means 'apply the Effect to the whole Bitmap'.
1874
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D 
1875
 *               representing the current center of the effect.
1876
 * @return       ID of the effect added, or -1 if we failed to add one. 
1877
 */
1878
  public long smooth_saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1879
    {
1880
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, i);
1881
    }
1882

    
1883
///////////////////////////////////////////////////////////////////////////////////////////////////
1884
/**
1885
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1886
 * <p>
1887
 * Here the center of the Effect stays constant.
1888
 *         
1889
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1890
 *               at any given moment.
1891
 * @param region Region this Effect is limited to. 
1892
 *               Null here means 'apply the Effect to the whole Bitmap'.
1893
 * @param point  Center of the Effect.
1894
 * @return       ID of the effect added, or -1 if we failed to add one. 
1895
 */
1896
  public long smooth_saturation(Interpolator1D a, Float4D region, Float2D point)
1897
    {
1898
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, point.x, point.y);
1899
    }
1900

    
1901
///////////////////////////////////////////////////////////////////////////////////////////////////  
1902
/**
1903
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1904
 *        
1905
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1906
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1907
 *                   anything more than 1 -increase the saturation. 
1908
 * @param region     Region this Effect is limited to. 
1909
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1910
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1911
 *                   representing the current center of the effect.
1912
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1913
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1914
 * @return           ID of the effect added, or -1 if we failed to add one. 
1915
 */
1916
  public long smooth_saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1917
    {
1918
    Interpolator1D di = new Interpolator1D(); 
1919
    di.setCount(count);
1920
    di.setDuration(duration);
1921
    di.add(new Float1D(1));                          
1922
    di.add(new Float1D(saturation));                         
1923
   
1924
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, i);
1925
    }
1926

    
1927
///////////////////////////////////////////////////////////////////////////////////////////////////
1928
/**
1929
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1930
 * <p>
1931
 * Here the center of the Effect stays constant.
1932
 *         
1933
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1934
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1935
 *                   anything more than 1 - increase the saturation. 
1936
 * @param region     Region this Effect is limited to. 
1937
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1938
 * @param point      Center of the Effect.
1939
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1940
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1941
 * @return           ID of the effect added, or -1 if we failed to add one. 
1942
 */
1943
  public long smooth_saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1944
    {
1945
    Interpolator1D di = new Interpolator1D(); 
1946
    di.setCount(count);
1947
    di.setDuration(duration);
1948
    di.add(new Float1D(1));                          
1949
    di.add(new Float1D(saturation));                         
1950
   
1951
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1952
    }
1953

    
1954
///////////////////////////////////////////////////////////////////////////////////////////////////
1955
/**
1956
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1957
 * <p>
1958
 * Here the center of the Effect stays constant and the effect for now change in time.
1959
 *         
1960
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1961
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1962
 *                   anything more than 1 - increase the saturation. 
1963
 * @param region     Region this Effect is limited to. 
1964
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1965
 * @param point      Center of the Effect.
1966
 * @return           ID of the effect added, or -1 if we failed to add one. 
1967
 */
1968
  public long smooth_saturation(float saturation, Float4D region, Float2D point)
1969
    {
1970
    Interpolator1D di = new Interpolator1D(); 
1971
    di.setCount(0.5f);
1972
    di.setDuration(0);
1973
    di.add(new Float1D(1));                          
1974
    di.add(new Float1D(saturation));                         
1975
   
1976
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1977
    }
1978
    
1979
///////////////////////////////////////////////////////////////////////////////////////////////////
1980
/**
1981
 * Makes the whole Bitmap change its saturation level.
1982
 * 
1983
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1984
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1985
 *                   anything more than 1 - increase the saturation. 
1986
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1987
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1988
 * @return           ID of the effect added, or -1 if we failed to add one. 
1989
 */
1990
  public long smooth_saturation(float saturation, int duration, float count) 
1991
    {
1992
    Interpolator1D di = new Interpolator1D(); 
1993
    di.setCount(count);
1994
    di.setDuration(duration);
1995
    di.add(new Float1D(1));                            
1996
    di.add(new Float1D(saturation));                        
1997
         
1998
    return mF.add(EffectNames.SMOOTH_SATURATION, di,null, 0.0f, 0.0f);
1999
    }
2000
            
2001
///////////////////////////////////////////////////////////////////////////////////////////////////
2002
// Vertex-based effects  
2003
///////////////////////////////////////////////////////////////////////////////////////////////////
2004
// DISTORT
2005
/**
2006
 * Distort a (possibly changing in time) part of the Bitmap by a (possibly changing in time) vector of force.
2007
 * 
2008
 * @param i      2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2009
 *               represents the vector the Center of the Effect is currently being dragged with.
2010
 * @param region Region that masks the effect of the Distortion.
2011
 * @param p      2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2012
 *               the Center of the Effect.
2013
 * @return       ID of the effect added, or -1 if we failed to add one. 
2014
 */
2015
  public long distort(Interpolator i, Float4D region, Interpolator2D p)
2016
    {  
2017
    return mV.add(EffectNames.DISTORT, i, region, p);  
2018
    }
2019

    
2020
///////////////////////////////////////////////////////////////////////////////////////////////////
2021
/**
2022
 * Distort part of the Bitmap by a (possibly changing in time) vector of force.
2023
 * <p>
2024
 * Difference between this and the previous method is that here the center of the Effect stays constant.
2025
 *   
2026
 * @param i      2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2027
 *               represents the vector the Center of the Effect is currently being dragged with.
2028
 * @param region Region that masks the effect of the Distortion.
2029
 * @param point  Center of the Effect.
2030
 * @return       ID of the effect added, or -1 if we failed to add one. 
2031
 */
2032
  public long distort(Interpolator i, Float4D region, Float2D point)
2033
    {  
2034
    return mV.add(EffectNames.DISTORT, i, region, point.x, point.y);  
2035
    }
2036

    
2037
///////////////////////////////////////////////////////////////////////////////////////////////////
2038
/**
2039
 * Distort the whole Bitmap by a (possibly changing in time) vector of force.
2040
 * 
2041
 * @param i     2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2042
 *              represents the vector the Center of the Effect is currently being dragged with.
2043
 * @param point Center of the Effect.
2044
 * @return      ID of the effect added, or -1 if we failed to add one. 
2045
 */
2046
  public long distort(Interpolator i, Float2D point)
2047
    {
2048
    return mV.add(EffectNames.DISTORT, i, null, point.x, point.y);  
2049
    }
2050

    
2051
///////////////////////////////////////////////////////////////////////////////////////////////////
2052
/**
2053
 * Distort part of the Bitmap by a vector of force that changes from (0,0,0) to v.
2054
 * 
2055
 * @param vector   Maximum vector of force. 
2056
 * @param region   Region that masks the effect of the Distortion.
2057
 * @param point    Center of the Effect.
2058
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2059
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2060
 * @return         ID of the effect added, or -1 if we failed to add one. 
2061
 */
2062
  public long distort(Float3D vector, Float4D region, Float2D point, int duration, float count)
2063
    {  
2064
    Interpolator3D di = new Interpolator3D(); 
2065
    di.setCount(count);
2066
    di.setDuration(duration);
2067
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2068
    di.add(vector);                                                  
2069
           
2070
    return mV.add(EffectNames.DISTORT, di, region, point.x, point.y);  
2071
    }
2072

    
2073
///////////////////////////////////////////////////////////////////////////////////////////////////
2074
/**
2075
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
2076
 * 
2077
 * @param vector   Maximum vector of force.
2078
 * @param point    Center of the Effect.
2079
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2080
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2081
 * @return         ID of the effect added, or -1 if we failed to add one. 
2082
 */
2083
  public long distort(Float3D vector, Float2D point, int duration, float count)
2084
    {
2085
    Interpolator3D di = new Interpolator3D(); 
2086
    di.setCount(count);
2087
    di.setDuration(duration);
2088
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2089
    di.add(vector);                                                 
2090
           
2091
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2092
    }
2093

    
2094
///////////////////////////////////////////////////////////////////////////////////////////////////
2095
/**
2096
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
2097
 * <p>
2098
 * Difference between this and the previous method is that here the vector of force will get interpolated
2099
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2100
 * 
2101
 * @param vector   Maximum, final vector of force.
2102
 * @param point    Center of the Effect.
2103
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2104
 * @return         ID of the effect added, or -1 if we failed to add one. 
2105
 */
2106
  public long distort(Float3D vector, Float2D point, int duration)
2107
    {
2108
    Interpolator3D di = new Interpolator3D();  
2109
    di.setCount(0.5f);
2110
    di.setDuration(duration);
2111
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2112
    di.add(vector);                 
2113
           
2114
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2115
    }
2116

    
2117
///////////////////////////////////////////////////////////////////////////////////////////////////
2118
/**
2119
 * Distort the whole Bitmap by a vector of force v.
2120
 * <p>
2121
 * Here we apply a constant vector of force.
2122
 * 
2123
 * @param vector Vector of force.
2124
 * @param point  Center of the Effect.
2125
 * @return       ID of the effect added, or -1 if we failed to add one. 
2126
 */
2127
  public long distort(Float3D vector, Float2D point )
2128
    {
2129
    Interpolator3D di = new Interpolator3D(); 
2130
    di.setCount(0.5f);
2131
    di.setDuration(0);
2132
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2133
    di.add(vector);           
2134
           
2135
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2136
    }
2137

    
2138
///////////////////////////////////////////////////////////////////////////////////////////////////
2139
///////////////////////////////////////////////////////////////////////////////////////////////////
2140
// DEFORM
2141
/**
2142
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2143
 * a (possibly changing in time) point on the Bitmap.
2144
 *     
2145
 * @param i     Interpolator that, at any given time, returns a Point2D representing vector of 
2146
 *              force that deforms the shapre of the whole Bitmap.
2147
 * @param point 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2148
 *              the Center of the Effect.
2149
 * @return      ID of the effect added, or -1 if we failed to add one. 
2150
 */
2151
  public long deform(Interpolator i, Interpolator2D point)
2152
    {  
2153
    return mV.add(EffectNames.DEFORM, i, null, point);  
2154
    }
2155

    
2156
///////////////////////////////////////////////////////////////////////////////////////////////////
2157
/**
2158
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2159
 * a constant point on the Bitmap.
2160
 * 
2161
 * @param i     Interpolator that, at any given time, returns a Point2D representing 
2162
 *              vector of force that deforms the shapre of the whole Bitmap.
2163
 * @param point Center of the Effect.
2164
 * @return      ID of the effect added, or -1 if we failed to add one. 
2165
 */
2166
  public long deform(Interpolator i, Float2D point)
2167
    {
2168
    return mV.add(EffectNames.DEFORM, i, null, point.x, point.y);  
2169
    }
2170

    
2171
///////////////////////////////////////////////////////////////////////////////////////////////////
2172
/**
2173
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2174
 * applied to a constant point on the Bitmap. 
2175
 * 
2176
 * @param vector   Vector of force.
2177
 * @param point    Center of the Effect.
2178
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2179
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2180
 * @return         ID of the effect added, or -1 if we failed to add one. 
2181
 */
2182
  public long deform(Float3D vector, Float2D point, int duration, float count)
2183
    {
2184
    Interpolator3D di = new Interpolator3D(); 
2185
    di.setCount(count);
2186
    di.setDuration(duration);
2187
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2188
    di.add(vector);                
2189
           
2190
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2191
    }
2192

    
2193
///////////////////////////////////////////////////////////////////////////////////////////////////
2194
/**
2195
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2196
 * applied to a constant point on the Bitmap. 
2197
 * <p>
2198
 * Identical to calling the previous method with count=0.5.
2199
 * 
2200
 * @param vector   Final vector of force.
2201
 * @param point    Center of the Effect.
2202
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2203
 * @return         ID of the effect added, or -1 if we failed to add one. 
2204
 */
2205
  public long deform(Float3D vector, Float2D point, int duration)
2206
    {
2207
    Interpolator3D di = new Interpolator3D();  
2208
    di.setCount(0.5f);
2209
    di.setDuration(duration);
2210
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2211
    di.add(vector);             
2212
           
2213
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2214
    }
2215

    
2216
///////////////////////////////////////////////////////////////////////////////////////////////////
2217
/**
2218
 * Deform the shape of the whole Bitmap with a constant vector of force applied to a constant 
2219
 * point on the Bitmap. 
2220
 * 
2221
 * @param vector Vector of force.
2222
 * @param point  Center of the Effect.
2223
 * @return       ID of the effect added, or -1 if we failed to add one. 
2224
 */
2225
  public long deform(Float3D vector, Float2D point )
2226
    {
2227
    Interpolator3D di = new Interpolator3D(); 
2228
    di.setCount(0.5f);
2229
    di.setDuration(0);
2230
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2231
    di.add(vector);            
2232
           
2233
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2234
    }
2235
   
2236
///////////////////////////////////////////////////////////////////////////////////////////////////  
2237
///////////////////////////////////////////////////////////////////////////////////////////////////
2238
// SINK
2239
/**
2240
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2241
 * away from the center (degree<=1)
2242
 *    
2243
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing
2244
 *               the current degree of the effect.
2245
 * @param region Region that masks the effect of the Sink.
2246
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2247
 *               the Center of the Effect.
2248
 * @return       ID of the effect added, or -1 if we failed to add one. 
2249
 */
2250
  public long sink(Interpolator1D di, Float4D region, Interpolator2D point)
2251
    {
2252
    return mV.add(EffectNames.SINK, di, region, point);  
2253
    }
2254

    
2255
///////////////////////////////////////////////////////////////////////////////////////////////////
2256
/**
2257
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2258
 * away from the center (degree<=1).
2259
 * <p>
2260
 * Here the Center stays constant.
2261
 *      
2262
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D
2263
 *               representing the current degree of the effect.
2264
 * @param region Region that masks the effect of the Sink.
2265
 * @param point  Center of the Effect.
2266
 * @return       ID of the effect added, or -1 if we failed to add one. 
2267
 */
2268
  public long sink(Interpolator1D di, Float4D region, Float2D point)
2269
    {
2270
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2271
    }
2272
  
2273
///////////////////////////////////////////////////////////////////////////////////////////////////
2274
/**
2275
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2276
 * away from the center (degree<=1).
2277
 * <p>
2278
 * Here we can only interpolate between 1 and degree.
2279
 * 
2280
 * @param degree   How much to push or pull. Between 0 and infinity.
2281
 * @param region   Region that masks the effect of the Sink.
2282
 * @param p        2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2283
 *                 the Center of the Effect.
2284
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2285
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2286
 * @return         ID of the effect added, or -1 if we failed to add one. 
2287
 */
2288
  public long sink(float degree, Float4D region, Interpolator2D p, int duration, float count)
2289
    {
2290
    Interpolator1D di = new Interpolator1D(); 
2291
    di.setCount(count);
2292
    di.setDuration(duration);
2293
    di.add(new Float1D(1));                                
2294
    di.add(new Float1D(degree));                          
2295
    
2296
    return mV.add(EffectNames.SINK, di, region, p);  
2297
    }
2298

    
2299
///////////////////////////////////////////////////////////////////////////////////////////////////
2300
/**
2301
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2302
 * away from the center (degree<=1).
2303
 *   
2304
 * @param degree   How much to push or pull. Between 0 and infinity.
2305
 * @param region   Region that masks the effect of the Sink.
2306
 * @param point    Center of the Effect.
2307
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2308
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2309
 * @return         ID of the effect added, or -1 if we failed to add one. 
2310
 */
2311
  public long sink(float degree, Float4D region, Float2D point, int duration, float count)
2312
    {
2313
    Interpolator1D di = new Interpolator1D(); 
2314
    di.setCount(count);
2315
    di.setDuration(duration);
2316
    di.add(new Float1D(1));                                
2317
    di.add(new Float1D(degree));                          
2318
    
2319
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2320
    }
2321

    
2322
///////////////////////////////////////////////////////////////////////////////////////////////////
2323
/**
2324
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2325
 * away from the center (degree<=1).
2326
 * 
2327
 * @param degree   How much to push or pull. Between 0 and infinity.
2328
 * @param point    Center of the Effect.
2329
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2330
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2331
 * @return         ID of the effect added, or -1 if we failed to add one. 
2332
 */
2333
  public long sink(float degree, Float2D point, int duration, float count) 
2334
    {
2335
    Interpolator1D di = new Interpolator1D();  
2336
    di.setCount(count);
2337
    di.setDuration(duration);
2338
    di.add(new Float1D(1));                                
2339
    di.add(new Float1D(degree));                          
2340
         
2341
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2342
    }
2343

    
2344
///////////////////////////////////////////////////////////////////////////////////////////////////
2345
/**
2346
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2347
 * away from the center (degree<=1).
2348
 * <p>
2349
 * Equivalent to calling the previous method with count=0.5.
2350
 * 
2351
 * @param degree   How much to push or pull. Between 0 and infinity.
2352
 * @param point    Center of the Effect.
2353
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2354
 * @return         ID of the effect added, or -1 if we failed to add one. 
2355
 */
2356
  public long sink(float degree, Float2D point, int duration) 
2357
    {
2358
    Interpolator1D di = new Interpolator1D(); 
2359
    di.setCount(0.5f);
2360
    di.setDuration(duration);
2361
    di.add(new Float1D(1));                               
2362
    di.add(new Float1D(degree));                      
2363
        
2364
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2365
    }
2366

    
2367
///////////////////////////////////////////////////////////////////////////////////////////////////
2368
/**
2369
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2370
 * away from the center (degree<=1).
2371
 * <p>
2372
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2373
 * 
2374
 * @param degree How much to push or pull. Between 0 and infinity.
2375
 * @param point  Center of the Effect.
2376
 * @return       ID of the effect added, or -1 if we failed to add one. 
2377
 */
2378
  public long sink(float degree, Float2D point) 
2379
    {
2380
    Interpolator1D di = new Interpolator1D(); 
2381
    di.setCount(0.5f);
2382
    di.setDuration(0);
2383
    di.add(new Float1D(1));                               
2384
    di.add(new Float1D(degree));                      
2385
        
2386
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2387
    }
2388
  
2389
///////////////////////////////////////////////////////////////////////////////////////////////////  
2390
///////////////////////////////////////////////////////////////////////////////////////////////////
2391
// SWIRL
2392
/**
2393
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2394
 * Interpolator). 
2395
 *   
2396
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2397
 *               the degree of Swirl.
2398
 * @param region Region that masks the effect of the Swirl.
2399
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2400
 *               the Center of the Effect.
2401
 * @return       ID of the effect added, or -1 if we failed to add one. 
2402
 */
2403
  public long swirl(Interpolator1D di, Float4D region, Interpolator2D point)
2404
    {    
2405
    return mV.add(EffectNames.SWIRL, di, region, point);  
2406
    }
2407

    
2408
///////////////////////////////////////////////////////////////////////////////////////////////////
2409
/**
2410
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2411
 * Interpolator).
2412
 * <p>
2413
 * Here the Center stays constant.
2414
 *      
2415
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2416
 *               the degree of Swirl.
2417
 * @param region Region that masks the effect of the Swirl.
2418
 * @param point  Center of the Effect.
2419
 * @return       ID of the effect added, or -1 if we failed to add one. 
2420
 */
2421
  public long swirl(Interpolator1D di, Float4D region, Float2D point)
2422
    {    
2423
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2424
    }
2425
 
2426
///////////////////////////////////////////////////////////////////////////////////////////////////
2427
/**
2428
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2429
 *   
2430
 * @param degree   Angle of rotation. Unit: degrees.
2431
 * @param region   Region that masks the effect of the Swirl.
2432
 * @param point    2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2433
 *                 the Center of the Effect.
2434
 * @return         ID of the effect added, or -1 if we failed to add one.
2435
 */
2436
  public long swirl(int degree, Float4D region, Interpolator2D point)
2437
    {
2438
    Interpolator1D di = new Interpolator1D();
2439
    di.setCount(0.5f);
2440
    di.setDuration(0);
2441
    di.add(new Float1D(0));                                
2442
    di.add(new Float1D(degree));                          
2443
    
2444
    return mV.add(EffectNames.SWIRL, di, region, point);  
2445
    }
2446

    
2447
///////////////////////////////////////////////////////////////////////////////////////////////////
2448
/**
2449
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2450
 * <p>
2451
 * Here the Center stays constant.
2452
 *    
2453
 * @param degree   Angle of rotation. Unit: degrees.
2454
 * @param region   Region that masks the effect of the Swirl.
2455
 * @param point    Center of the Effect.
2456
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2457
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2458
 * @return         ID of the effect added, or -1 if we failed to add one. 
2459
 */
2460
  public long swirl(int degree, Float4D region, Float2D point, int duration, float count)
2461
    {
2462
    Interpolator1D di = new Interpolator1D(); 
2463
    di.setCount(count);
2464
    di.setDuration(duration);
2465
    di.add(new Float1D(0));                                
2466
    di.add(new Float1D(degree));                          
2467
    
2468
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2469
    }
2470

    
2471
///////////////////////////////////////////////////////////////////////////////////////////////////
2472
/**
2473
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2474
 * 
2475
 * @param degree   Angle of rotation. Unit: degrees.
2476
 * @param point    Center of the Effect.
2477
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2478
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2479
 * @return         ID of the effect added, or -1 if we failed to add one. 
2480
 */
2481
  public long swirl(int degree, Float2D point, int duration, float count) 
2482
    {
2483
    Interpolator1D di = new Interpolator1D();  
2484
    di.setCount(count);
2485
    di.setDuration(duration);
2486
    di.add(new Float1D(0));                                
2487
    di.add(new Float1D(degree));                          
2488
         
2489
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2490
    }
2491

    
2492
///////////////////////////////////////////////////////////////////////////////////////////////////
2493
/**
2494
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2495
 * <p>
2496
 * Equivalent to calling the previous method with count=0.5.
2497
 * 
2498
 * @param degree   Angle of rotation. Unit: degrees.
2499
 * @param point    Center of the Effect.
2500
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2501
 * @return         ID of the effect added, or -1 if we failed to add one. 
2502
 */
2503
  public long swirl(int degree, Float2D point, int duration) 
2504
    {
2505
    Interpolator1D di = new Interpolator1D(); 
2506
    di.setCount(0.5f);
2507
    di.setDuration(duration);
2508
    di.add(new Float1D(0));                               
2509
    di.add(new Float1D(degree));                      
2510
        
2511
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2512
    }
2513

    
2514
///////////////////////////////////////////////////////////////////////////////////////////////////
2515
/**
2516
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2517
 * <p>
2518
 * Equivalent to calling the previous method with duration=0.
2519
 * 
2520
 * @param degree Angle of rotation. Unit: degrees.
2521
 * @param point  Center of the Effect.
2522
 * @return       ID of the effect added, or -1 if we failed to add one. 
2523
 */
2524
  public long swirl(int degree, Float2D point) 
2525
    {
2526
    Interpolator1D di = new Interpolator1D(); 
2527
    di.setCount(0.5f);
2528
    di.setDuration(0);
2529
    di.add(new Float1D(0));                               
2530
    di.add(new Float1D(degree));                      
2531
        
2532
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2533
    }
2534

    
2535
///////////////////////////////////////////////////////////////////////////////////////////////////
2536
///////////////////////////////////////////////////////////////////////////////////////////////////
2537
// WAVE
2538

    
2539
///////////////////////////////////////////////////////////////////////////////////////////////////   
2540
///////////////////////////////////////////////////////////////////////////////////////////////////
2541
// Other-based effects
2542
///////////////////////////////////////////////////////////////////////////////////////////////////
2543
// SAVE_PNG
2544
/**
2545
 * Save the current state of the Bitmap that's backing up our DistortedObject to a PNG file.
2546
 *
2547
 * @param filename Full path to the file.
2548
 * @return         ID of the effect added, or -1 if we failed to add one.
2549
 */
2550
 public long savePNG(String filename, int left, int top, int width, int height)
2551
   {
2552
   return mO.add(EffectNames.SAVE_PNG, filename, left, top, width, height);
2553
   }
2554
}
(5-5/30)