Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ 6a06a912

1
package org.distorted.library;
2

    
3
import android.graphics.Bitmap;
4
import android.opengl.GLES20;
5
import android.opengl.GLUtils;
6

    
7
///////////////////////////////////////////////////////////////////////////////////////////////////
8

    
9
public abstract class DistortedObject 
10
{ 
11
    static final int TYPE_NUM = 3;
12
    private static final int TYPE_MASK= (1<<TYPE_NUM)-1;
13
    private static float[] mViewMatrix = new float[16];
14
   
15
    protected EffectListMatrix   mM;
16
    protected EffectListFragment mF;
17
    protected EffectListVertex   mV;
18

    
19
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
20
 
21
    protected GridObject mGrid = null;
22
    protected long mID;
23
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
24

    
25
    protected Bitmap[] mBmp= null; // 
26
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
27
    boolean[] mBitmapSet;          // 
28
 
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
    protected void initializeData(int size)
32
      {
33
      mID             = DistortedObjectList.add(this);
34
      mSize           = size;
35
      mTextureDataH   = new int[1];
36
      mTextureDataH[0]= 0;
37
      mBmp            = new Bitmap[1];
38
      mBmp[0]         = null;
39
      mBitmapSet      = new boolean[1];
40
      mBitmapSet[0]   = false;
41
      
42
      initializeEffectLists(this,0);
43
      
44
      if( Distorted.isInitialized() ) resetTexture();    
45
      }
46
    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
    
49
    protected void initializeEffectLists(DistortedObject d, int flags)
50
      {
51
      if( (flags & Distorted.CLONE_MATRIX) != 0 )
52
        {
53
        mM = d.mM;
54
        matrixCloned = true;
55
        } 
56
      else
57
        {
58
        mM = new EffectListMatrix(d);
59
        matrixCloned = false;  
60
        }
61
    
62
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
63
        {
64
        mV = d.mV;
65
        vertexCloned = true;
66
        } 
67
      else
68
        {
69
        mV = new EffectListVertex(d);
70
        vertexCloned = false;  
71
        }
72
    
73
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
74
        {
75
        mF = d.mF;
76
        fragmentCloned = true;
77
        } 
78
      else
79
        {
80
        mF = new EffectListFragment(d);
81
        fragmentCloned = false;   
82
        }
83
      }
84
    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
// this will be called on startup and every time OpenGL context has been lost
87
// also call this from the constructor if the OpenGL context has been created already.
88
    
89
    void resetTexture()
90
      {
91
      if( mTextureDataH!=null ) 
92
        {
93
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
94

    
95
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
96
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
97
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
98
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
99
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
100
       
101
        if( mBmp!=null && mBmp[0]!=null)
102
          {
103
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
104
          mBmp[0] = null;
105
          }
106
        }
107
      }
108
  
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
   
111
    void drawPriv(long currTime, DistortedProjection dp)
112
      {
113
      GLES20.glViewport(0, 0, dp.width, dp.height); 
114
      
115
      mM.compute(currTime);
116
      mM.send(mViewMatrix, dp);
117
      
118
      mV.compute(currTime);
119
      mV.postprocess();
120
      mV.send();
121
        
122
      mF.compute(currTime);
123
      mF.postprocess(mViewMatrix);
124
      mF.send();
125
       
126
      mGrid.draw();
127
      }
128

    
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130
   
131
    void drawNoEffectsPriv(DistortedProjection dp)
132
      {
133
      GLES20.glViewport(0, 0, dp.width, dp.height);
134
      mM.sendNoEffects(dp);
135
      mV.sendZero();
136
      mF.sendZero();
137
      mGrid.draw();
138
      }
139
    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
   
142
    void releasePriv()
143
      {
144
      if( matrixCloned  ==false) mM.abortAll();
145
      if( vertexCloned  ==false) mV.abortAll();
146
      if( fragmentCloned==false) mF.abortAll();
147

    
148
      mBmp          = null;
149
      mGrid         = null;
150
      mM            = null;
151
      mV            = null;
152
      mF            = null;
153
      mTextureDataH = null;
154
      }
155
 
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157

    
158
    long getBitmapID()
159
      {
160
      return mBmp==null ? 0 : mBmp.hashCode();
161
      }
162

    
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164
/**
165
 * Draw the DistortedObject to the location specified by current Matrix effects.    
166
 *     
167
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
168
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
169
 *        Object.
170
 */
171
   public void draw(long currTime)
172
     {
173
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
174
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
175
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
176
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
177
      
178
     drawPriv(currTime, Distorted.mProjection);
179
     }
180
 
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
/**
183
 * Releases all resources.
184
 */
185
   public synchronized void release()
186
     {
187
     releasePriv();  
188
     DistortedObjectList.remove(this);
189
     }
190

    
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192
/**
193
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
194
 * <p>
195
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
196
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
197
 * 
198
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
199
 */
200
   
201
   public void setBitmap(Bitmap bmp)
202
     {
203
     mBitmapSet[0] = true; 
204
      
205
     if( Distorted.isInitialized() )
206
       {
207
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
208
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
209
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
210
       }
211
     else
212
       {
213
       mBmp[0] = bmp;  
214
       }
215
     }
216
    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218
/**
219
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
220
 * to one of the Effects that are currently applied to the DistortedBitmap.
221
 * 
222
 * @param el A class implementing the EffectListener interface that wants to get notifications.
223
 */
224
   public void addEventListener(EffectListener el)
225
     {
226
     mV.addListener(el);
227
     mF.addListener(el);
228
     mM.addListener(el);
229
     }
230

    
231
///////////////////////////////////////////////////////////////////////////////////////////////////
232
/**
233
 * Removes the calling class from the list of Listeners.
234
 * 
235
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
236
 */
237
   public void removeEventListener(EffectListener el)
238
     {
239
     mV.removeListener(el);
240
     mF.removeListener(el);
241
     mM.removeListener(el);
242
     }
243
   
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245
/**
246
 * Returns the height of the DistortedObject.
247
 *    
248
 * @return height of the object, in pixels.
249
 */
250
   public int getWidth()
251
     {
252
     return mSizeX;   
253
     }
254

    
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
/**
257
 * Returns the width of the DistortedObject.
258
 * 
259
 * @return width of the Object, in pixels.
260
 */
261
    public int getHeight()
262
      {
263
      return mSizeY;  
264
      }
265
    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267
/**
268
 * Returns the depth of the DistortedObject.
269
 * 
270
 * @return depth of the Object, in pixels.
271
 */
272
    public int getDepth()
273
      {
274
      return mSizeZ;  
275
      }
276
        
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278
/**
279
 * Returns unique ID of this instance.
280
 * 
281
 * @return ID of the object.
282
 */
283
    public long getID()
284
      {
285
      return mID;  
286
      }
287
    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
/**
290
 * Aborts all Effects. 
291
 */
292
    public void abortAllEffects()
293
      {
294
      mM.abortAll();
295
      mV.abortAll();
296
      mF.abortAll();
297
      }
298

    
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300
/**
301
 * Aborts a subset of Effects.
302
 * 
303
 * @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_MATR | TYPE_VERT | TYPE_FRAG.
304
 */
305
    public void abortAllEffects(int mask)
306
      {
307
      if( (mask & Distorted.TYPE_MATR) != 0 ) mM.abortAll();
308
      if( (mask & Distorted.TYPE_VERT) != 0 ) mV.abortAll();
309
      if( (mask & Distorted.TYPE_FRAG) != 0 ) mF.abortAll();
310
      }
311
    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313
/**
314
 * Aborts a single Effect.
315
 * 
316
 * @param id ID of the Effect we want to abort.
317
 * @return <code>true</code> if the Effect was found and successfully aborted.
318
 */
319
    public boolean abortEffect(long id)
320
      {
321
      switch( (int)(id&TYPE_MASK) )
322
        {
323
        case Distorted.TYPE_MATR: return mM.removeByID(id>>TYPE_NUM);
324
        case Distorted.TYPE_VERT: return mV.removeByID(id>>TYPE_NUM);
325
        case Distorted.TYPE_FRAG: return mF.removeByID(id>>TYPE_NUM);
326
        default                 : return false;
327
        }
328
      }
329

    
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331
/**
332
 * Abort all Effects of a given type, for example all rotations.
333
 * 
334
 * @param effectType one of the constants defined in {@link EffectNames}
335
 * @return <code>true</code> if a single Effect of type effectType has been found and aborted. 
336
 */
337
    public boolean abortEffectType(EffectNames effectType)
338
      {
339
      switch(effectType.getType())
340
        {
341
        case Distorted.TYPE_MATR: return mM.removeByType(effectType);
342
        case Distorted.TYPE_VERT: return mV.removeByType(effectType);
343
        case Distorted.TYPE_FRAG: return mF.removeByType(effectType);
344
        default                 : return false;
345
        }
346
      }
347
    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349
/**
350
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
351
 * 
352
 * @param id Effect ID we want to print info about
353
 * @return <code>true</code> if a single Effect of type effectType has been found.
354
 */
355
    
356
    public boolean printEffect(long id)
357
      {
358
      switch( (int)(id&TYPE_MASK) )
359
        {
360
        case Distorted.TYPE_MATR: return mM.printByID(id>>TYPE_NUM);
361
        case Distorted.TYPE_VERT: return mV.printByID(id>>TYPE_NUM);
362
        case Distorted.TYPE_FRAG: return mF.printByID(id>>TYPE_NUM);
363
        default                 : return false;
364
        }
365
      }
366
   
367
///////////////////////////////////////////////////////////////////////////////////////////////////   
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
// Individual effect functions.
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
// Matrix-based effects
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// MOVE
374
/**
375
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
376
 * 
377
 * @param di a 3-dimensional Interpolator which at any given time will return a Float3D
378
 *           representing the current coordinates of the vector we want to move the Object with.
379
 * @return ID of the effect added, or -1 if we failed to add one. 
380
 */
381
  public long move(Interpolator3D di)
382
    {   
383
    return mM.add(EffectNames.MOVE,null,di);  
384
    }
385

    
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
/**
388
 * Moves the Bitmap by a vector that smoothly changes from (0,0,0) to (x,y,z).
389
 *  
390
 * @param x The x-coordinate of the vector we want to move the Object with. 
391
 * @param y The y-coordinate of the vector we want to move the Object with.
392
 * @param z The z-coordinate of the vector we want to move the Object with.
393
 * @param duration The time, in milliseconds, it takes to complete the movement.
394
 * @return ID of the effect added, or -1 if we failed to add one. 
395
 */
396
  public long move(float x,float y,float z, int duration)
397
    {   
398
    Interpolator3D di = new Interpolator3D();  
399
    di.setCount(0.5f);
400
    di.setDuration(duration);
401
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
402
    di.add(new Float3D(x,y,z));                        
403

    
404
    return mM.add(EffectNames.MOVE,null,di);  
405
    }
406

    
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
/**
409
 * Moves the Bitmap by vector (x,y,z) immediately.
410
 *   
411
 * @param x The x-coordinate of the vector we want to move the Object with. 
412
 * @param y The y-coordinate of the vector we want to move the Object with.
413
 * @param z The z-coordinate of the vector we want to move the Object with.
414
 * @return ID of the effect added, or -1 if we failed to add one. 
415
 */
416
  public long move(float x,float y,float z)
417
    {   
418
    return mM.add(EffectNames.MOVE,0.0f,0.0f,0.0f,x,y,z,0.0f);  
419
    }
420

    
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
// SCALE
423
/**
424
 * Scales the Object by factors that change in time as returned by the Interpolator.
425
 * 
426
 * @param di a 3-dimensional Interpolator which at any given time returns a Float3D
427
 *           representing the current x- , y- and z- scale factors.
428
 * @return ID of the effect added, or -1 if we failed to add one. 
429
 */
430
  public long scale(Interpolator3D di)
431
    {   
432
    return mM.add(EffectNames.SCALE,null,di);  
433
    }
434

    
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436
/**
437
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
438
 * after 'duration' milliseconds. 
439
 *    
440
 * @param xscale After time 'duration' passes, Bitmap's width will get multiplied by xscale; e.g. if 
441
 *               xscale=2, after 'duration' milliseconds the Object will become twice broader.
442
 * @param yscale factor to scale Object's height with.
443
 * @param zscale factor to scale Object's depth with.
444
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
445
 * @return ID of the effect added, or -1 if we failed to add one. 
446
 */
447
  public long scale(float xscale,float yscale,float zscale, int duration)
448
    {   
449
    Interpolator3D di = new Interpolator3D();  
450
    di.setCount(0.5f);
451
    di.setDuration(duration);
452
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
453
    di.add(new Float3D(xscale,yscale,zscale));                        
454

    
455
    return mM.add(EffectNames.SCALE,null,di);  
456
    }
457

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459
/**
460
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
461
 *   
462
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
463
 *               xscale=2, the Object immediately becomes twice broader.
464
 * @param yscale factor to scale Object's height with.
465
 * @param zscale factor to scale Object's depth with. 
466
 * @return ID of the effect added, or -1 if we failed to add one. 
467
 */
468
  public long scale(float xscale,float yscale,float zscale)
469
    {   
470
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,xscale,yscale,zscale,0.0f);  
471
    }
472

    
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474
/**
475
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
476
 *   
477
 * @param scale all 3 Object's dimensions gets multiplied by this factor; e.g. if 
478
 *              scale=2, the Object immediately becomes twice larger.
479
 * @return ID of the effect added, or -1 if we failed to add one. 
480
 */
481
  public long scale(float scale)
482
    {   
483
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,scale,scale,scale,0.0f);  
484
    }
485
    
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487
// ROTATE
488
/**
489
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
490
 * 
491
 * @param i 3-dimensional Interpolator which at any given time will return the current center of 
492
 *          the rotation
493
 * @param v 4-dimensional Interpolator which at any given time will return a Float4D
494
 *          representing the current rotation in the (angle,axisX,axisY,axisY) form. 
495
 * @return ID of the effect added, or -1 if we failed to add one. 
496
 */
497
  public long rotate(Interpolator3D i, Interpolator4D v)
498
    {   
499
    return mM.add(EffectNames.ROTATE, i, v);  
500
    }
501

    
502
///////////////////////////////////////////////////////////////////////////////////////////////////  
503
/**
504
 * Rotates the Object around a static point, with angle and axis that change in time.
505
 * 
506
 * @param p the center of the rotation
507
 * @param v 4-dimensional Interpolator which at any given time will return a Float4D
508
 *          representing the current rotation in the (angle,axisX,axisY,axisY) form. 
509
 * @return ID of the effect added, or -1 if we failed to add one. 
510
 */
511
  public long rotate(Float3D point, Interpolator4D v)
512
    {   
513
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v);  
514
    }
515
  
516
///////////////////////////////////////////////////////////////////////////////////////////////////  
517
/**
518
 * Rotates the Object around a static point, with angle that changes in time.
519
 * 
520
 * @param p the center of the rotation
521
 * @param v 1-dimensional Interpolator which at any given time will return the current rotation 
522
 *          angle.
523
 * @param (axisX, axisY, axisZ) the rotation vector          
524
 * @return ID of the effect added, or -1 if we failed to add one. 
525
 */
526
  public long rotate(Float3D point, Interpolator1D v, float axisX, float axisY, float axisZ)
527
    {   
528
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v, axisX, axisY, axisZ);  
529
    }
530
  
531
///////////////////////////////////////////////////////////////////////////////////////////////////
532
/**
533
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
534
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
535
 * 
536
 * @param i 3-dimensional Interpolator which at any given time will return the current center
537
 *          of the rotation.
538
 * @param a 1-dimensional Interpolator which returns the current rotation angle.         
539
 * @return ID of the effect added, or -1 if we failed to add one. 
540
 */
541
  public long rotate(Interpolator3D i, Interpolator1D a)
542
    {   
543
    return mM.add(EffectNames.ROTATE, i, a, 0.0f,0.0f,1.0f);  
544
    }
545

    
546
///////////////////////////////////////////////////////////////////////////////////////////////////
547
/**
548
 * Rotates the Object around a constant point, with angle that changes in time.  
549
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
550
 *   
551
 * @param p Coordinates of the Point we are rotating around.
552
 * @param angle The angle, in degrees, that we want to rotate the Bitmap to.
553
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
554
 * @return ID of the effect added, or -1 if we failed to add one. 
555
 */
556
  public long rotate(Float3D point, int angle, int duration)
557
    {   
558
    Interpolator1D di = new Interpolator1D();  
559
    di.setCount(0.5f);
560
    di.setDuration(duration);
561
    di.add(new Float1D(    0));                             
562
    di.add(new Float1D(angle));                        
563

    
564
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z, di, 0.0f,0.0f,1.0f);  
565
    }
566

    
567
///////////////////////////////////////////////////////////////////////////////////////////////////
568
/**
569
 * Rotates the Object immediately by 'angle' degrees around point p.   
570
 * Axis of rotation is given by the last 3 floats.
571
 *   
572
 * @param p Coordinates of the Point we are rotating around.
573
 * @param angle The angle, in degrees, that we want to rotate the Bitmap to.
574
 * @param (axisX,axisY,axisZ) - axis of rotation.
575
 * @return ID of the effect added, or -1 if we failed to add one. 
576
 */
577
  public long rotate(Float3D point, float angle, float axisX, float axisY, float axisZ)
578
    {   
579
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z, angle, axisX, axisY, axisZ);  
580
    }
581
  
582
///////////////////////////////////////////////////////////////////////////////////////////////////
583
/**
584
 * Rotates the Object immediately by 'angle' degrees around point p.   
585
 *   
586
 * @param p      Coordinates of the Point we are rotating around.
587
 * @param angle  The angle, in degrees, that we want to rotate the Bitmap to.
588
 * @return       ID of the effect added, or -1 if we failed to add one. 
589
 */
590
  public long rotate(Float3D point, int angle)
591
    {   
592
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z,angle,0.0f,0.0f,1.0f);  
593
    }
594

    
595
///////////////////////////////////////////////////////////////////////////////////////////////////
596
// QUATERNION
597
/**
598
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
599
 *   
600
 * @param p Coordinates of the Point we are rotating around.
601
 * @param (qX,qY,qZ,qW) - the quaternion.
602
 * @return ID of the effect added, or -1 if we failed to add one. 
603
 */
604
  public long quaternion(Float3D point, float qX, float qY, float qZ, float qW)
605
    {   
606
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,qX,qY,qZ,qW);   
607
    }
608

    
609
///////////////////////////////////////////////////////////////////////////////////////////////////
610
/**
611
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
612
 *   
613
 * @param p Coordinates of the Point we are rotating around.
614
 * @param iq - Interpolator that's going to, at any given moment, return a quaternion.
615
 * @return ID of the effect added, or -1 if we failed to add one. 
616
 */
617
  public long quaternion(Float3D point, InterpolatorQuat iq)
618
    {   
619
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,iq);  
620
    }
621

    
622
///////////////////////////////////////////////////////////////////////////////////////////////////
623
/**
624
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
625
 *   
626
 * @param i Interpolator that returns the current center of rotation.
627
 * @param iq Interpolator that's going to, at any given moment, return a quaternion representing the current rotation.
628
 * @return ID of the effect added, or -1 if we failed to add one. 
629
 */
630
  public long quaternion(Interpolator3D i, InterpolatorQuat iq)
631
    {   
632
    return mM.add(EffectNames.QUATERNION,i,iq);  
633
    }
634
  
635
///////////////////////////////////////////////////////////////////////////////////////////////////
636
// SHEAR
637
/**
638
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
639
 * shearing along the Y-axis, 3D one along Z axis.
640
 *
641
 * @param p  Center of shearing, i.e. the point which stays unmoved. 
642
 * @param di 1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2- or 3-tuple 
643
 *           of shear factors.
644
 * @return   ID of the effect added, or -1 if we failed to add one. 
645
 */
646
  public long shear(Float3D point, Interpolator di)
647
    {
648
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di);  
649
    }
650

    
651
///////////////////////////////////////////////////////////////////////////////////////////////////
652
/**
653
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
654
 * 
655
 * @param p  Center of shearing, i.e. the point which stays unmoved. 
656
 * @param v  ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with 
657
 *           which the X,Y and Z axis get slanted) 
658
 * @return   ID of the effect added, or -1 if we failed to add one. 
659
 */
660
  public long shear(Float3D point, Float3D vector)
661
    {
662
    Interpolator3D di = new Interpolator3D(); 
663
    di.setCount(0.5f);
664
    di.setDuration(0);
665
    di.add(new Float3D(0.0f,0.0f,0.0f));              
666
    di.add(vector);                                                
667
        
668
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di );  
669
    }
670

    
671
///////////////////////////////////////////////////////////////////////////////////////////////////
672
// Fragment-based effects  
673
///////////////////////////////////////////////////////////////////////////////////////////////////
674
// MACROBLOCK
675
/**
676
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
677
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
678
 * 
679
 * @param a a 1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
680
 * @param r The Region this Effect is limited to.
681
 *          Null here means 'apply the effect to the whole Bitmap'.
682
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
683
 *          current center of the effect.
684
 * @return ID of the effect added, or -1 if we failed to add one. 
685
 */
686
  public long macroblock(Interpolator1D a, Float4D region, Interpolator2D i)
687
    {
688
    return mF.add(EffectNames.MACROBLOCK, a, region, i);
689
    }
690

    
691
///////////////////////////////////////////////////////////////////////////////////////////////////
692
/**
693
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
694
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
695
 * <p>
696
 * The difference between this and the previous method is that here the center of the Effect stays constant.
697
 *    
698
 * @param a a 1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
699
 * @param r The Region this Effect is limited to. 
700
 *          Null here means 'apply the effect to the whole Bitmap'.
701
 * @param p Center of the Effect.
702
 * @return ID of the effect added, or -1 if we failed to add one. 
703
 */
704
  public long macroblock(Interpolator1D a, Float4D region, Float2D point)
705
    {
706
    return mF.add(EffectNames.MACROBLOCK, a, region, point.x, point.y);
707
    }
708
  
709
///////////////////////////////////////////////////////////////////////////////////////////////////
710
/**
711
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
712
 * <p>
713
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
714
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
715
 * size is 1X1, i.e. 1 pixel).   
716
 * 
717
 * @param pixels The maximum size, in pixels, of the Macroblocks we want to see.
718
 * @param r The Region this Effect is limited to. 
719
 *          Null here means 'apply the effect to the whole Bitmap'.
720
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
721
 *          current center of the effect.
722
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
723
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
724
 * @return ID of the effect added, or -1 if we failed to add one. 
725
 */
726
  public long macroblock(int pixels, Float4D region, Interpolator2D i, int duration, float count)
727
    {
728
    Interpolator1D di = new Interpolator1D();
729
    di.setCount(count);
730
    di.setDuration(duration);
731
    di.add(new Float1D(1));                             
732
    di.add(new Float1D(pixels));                        
733

    
734
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
735
    }
736

    
737
///////////////////////////////////////////////////////////////////////////////////////////////////
738
/**
739
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
740
 * <p>
741
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
742
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
743
 * size is 1X1, i.e. 1 pixel).   
744
 * <p>
745
 * The difference between this and the previous method is that here the center of the Effect stays constant.
746
 *    
747
 * @param pixels The maximum size, in pixels, of the Macroblocks we want to see.
748
 * @param r The Region this Effect is limited to. 
749
 *          Null here means 'apply the effect to the whole Bitmap'.
750
 * @param p Center of the Effect.
751
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
752
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
753
 * @return ID of the effect added, or -1 if we failed to add one. 
754
 */
755
  public long macroblock(int pixels, Float4D region, Float2D point, int duration, float count)
756
    {
757
    Interpolator1D di = new Interpolator1D();
758
    di.setCount(count);
759
    di.setDuration(duration);
760
    di.add(new Float1D(1));                             
761
    di.add(new Float1D(pixels));                        
762

    
763
    return mF.add(EffectNames.MACROBLOCK, di, region, point.x, point.y);
764
    }
765

    
766
///////////////////////////////////////////////////////////////////////////////////////////////////
767
/**
768
 * Creates macroblocks on the whole Bitmap. 
769
 * <p>
770
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
771
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
772
 * size is 1X1, i.e. 1 pixel).   
773
 * <p>
774
 * The difference between this and the previous method is that here there is no masking Region; thus
775
 * there is also no center of the Effect. 
776
 *    
777
 * @param pixels The maximum size, in pixels, of the Macroblocks we want to see.
778
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
779
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
780
 * @return ID of the effect added, or -1 if we failed to add one. 
781
 */
782
  public long macroblock(int pixels, int duration, float count) 
783
    {
784
    Interpolator1D di = new Interpolator1D(); 
785
    di.setCount(count);
786
    di.setDuration(duration);
787
    di.add(new Float1D(1));                            
788
    di.add(new Float1D(pixels));                        
789
   
790
    return mF.add(EffectNames.MACROBLOCK, di, null, 0.0f, 0.0f);
791
    }
792

    
793
///////////////////////////////////////////////////////////////////////////////////////////////////
794
///////////////////////////////////////////////////////////////////////////////////////////////////
795
// CHROMA
796
/**
797
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
798
 *        
799
 * @param a a 1-dimensional Interpolator that returns the level of blend a given pixel will be mixed with 
800
 *          the next parameter 'color': pixel = (1-level)*pixel + level*color
801
 * @param color The color to mix.         
802
 * @param r The Region this Effect is limited to. 
803
 *          Null here means 'apply the Effect to the whole Bitmap'.
804
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
805
 *          current center of the effect.
806
 * @return ID of the effect added, or -1 if we failed to add one. 
807
 */
808
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
809
    {
810
    return mF.add(EffectNames.CHROMA, t, color, region, i);
811
    }
812

    
813
///////////////////////////////////////////////////////////////////////////////////////////////////
814
/**
815
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
816
 * <p>
817
 * Here the center of the Effect stays constant.
818
 *         
819
 * @param a a 1-dimensional Interpolator that returns the level of blend a given pixel will be mixed with 
820
 *          the next parameter 'color': pixel = (1-level)*pixel + level*color
821
 * @param color The color to mix.         
822
 * @param r The Region this Effect is limited to. 
823
 *          Null here means 'apply the Effect to the whole Bitmap'.
824
 * @param p Center of the Effect.
825
 * @return ID of the effect added, or -1 if we failed to add one. 
826
 */
827
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
828
    {
829
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
830
    }
831

    
832
///////////////////////////////////////////////////////////////////////////////////////////////////  
833
/**
834
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
835
 *        
836
 * @param t the level of blend a given pixel will be mixed with the next parameter 'color': 
837
 *          pixel = (1-t)*pixel + t*color
838
 * @param color The color to mix.       
839
 * @param reg The Region this Effect is limited to.
840
 *          Null here means 'apply the Effect to the whole Bitmap'.
841
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
842
 *          current center of the effect.
843
 * @return ID of the effect added, or -1 if we failed to add one. 
844
 */
845
  public long chroma(float t, Float3D color, Float4D region, Interpolator2D i)
846
    {
847
    return mF.add(EffectNames.CHROMA, t, color, region, i);
848
    }
849

    
850
///////////////////////////////////////////////////////////////////////////////////////////////////
851
/**
852
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
853
 * <p>
854
 * Here the center of the Effect stays constant.
855
 *         
856
 * @param t the level of blend a given pixel will be mixed with the next parameter 'color': 
857
 *          pixel = (1-t)*pixel + t*color
858
 * @param color The color to mix.       
859
 * @param reg The Region this Effect is limited to. 
860
 *          Null here means 'apply the Effect to the whole Bitmap'.
861
 * @param p Center of the Effect.
862
 * @return ID of the effect added, or -1 if we failed to add one. 
863
 */
864
  public long chroma(float t, Float3D color, Float4D region, Float2D point)
865
    {
866
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
867
    }
868

    
869
///////////////////////////////////////////////////////////////////////////////////////////////////
870
/**
871
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
872
 * <p>
873
 * Here the Effect applies to the whole bitmap.
874
 *         
875
 * @param t the level of blend a given pixel will be mixed with the next parameter 'color': 
876
 *          pixel = (1-t)*pixel + t*color
877
 * @param color The color to mix.       
878
 * @return ID of the effect added, or -1 if we failed to add one. 
879
 */
880
  public long chroma(float t, Float3D color)
881
    {
882
    return mF.add(EffectNames.CHROMA, t, color, null, 0, 0);
883
    }
884

    
885
///////////////////////////////////////////////////////////////////////////////////////////////////  
886
/**
887
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
888
 * 
889
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
890
 */
891
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
892
    {
893
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
894
    }
895

    
896
///////////////////////////////////////////////////////////////////////////////////////////////////
897
/**
898
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
899
 * 
900
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
901
 */
902
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
903
    {
904
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
905
    }
906
  
907
///////////////////////////////////////////////////////////////////////////////////////////////////  
908
/**
909
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
910
 * 
911
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
912
 */
913
  public long smooth_chroma(float t, Float3D color, Float4D region, Interpolator2D i)
914
    {
915
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
916
    }
917

    
918
///////////////////////////////////////////////////////////////////////////////////////////////////
919
/**
920
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
921
 * 
922
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
923
 */
924
  public long smooth_chroma(float t, Float3D color, Float4D region, Float2D point)
925
    {
926
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
927
    }
928
  
929
///////////////////////////////////////////////////////////////////////////////////////////////////
930
/**
931
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
932
 * 
933
 * See {@link #chroma(float, Float3D)}
934
 */
935
  public long smooth_chroma(float t, Float3D color)
936
    {
937
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, null, 0, 0);
938
    }
939
  
940
///////////////////////////////////////////////////////////////////////////////////////////////////
941
///////////////////////////////////////////////////////////////////////////////////////////////////
942
// ALPHA
943
/**
944
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
945
 *        
946
 * @param a a 1-dimensional Interpolator that returns the level of transparency we want to have at any given 
947
 *          moment.
948
 * @param r The Region this Effect is limited to. 
949
 *          Null here means 'apply the Effect to the whole Bitmap'.
950
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
951
 *          current center of the effect.
952
 * @return ID of the effect added, or -1 if we failed to add one. 
953
 */
954
  public long alpha(Interpolator1D a, Float4D region, Interpolator2D i)
955
    {
956
    return mF.add(EffectNames.ALPHA, a, region, i);
957
    }
958

    
959
///////////////////////////////////////////////////////////////////////////////////////////////////
960
/**
961
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
962
 * <p>
963
 * Here the center of the Effect stays constant.
964
 *         
965
 * @param a a 1-dimensional Interpolator that returns the level of transparency we want to have at any given 
966
 *          moment.
967
 * @param r The Region this Effect is limited to. 
968
 *          Null here means 'apply the Effect to the whole Bitmap'.
969
 * @param p Center of the Effect.
970
 * @return ID of the effect added, or -1 if we failed to add one. 
971
 */
972
  public long alpha(Interpolator1D a, Float4D region, Float2D point)
973
    {
974
    return mF.add(EffectNames.ALPHA, a, region, point.x, point.y);
975
    }
976

    
977
///////////////////////////////////////////////////////////////////////////////////////////////////  
978
/**
979
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
980
 *        
981
 * @param alpha Level of Alpha (0<=Alpha<=1) we want to interpolate to.
982
 * @param r The Region this Effect is limited to. 
983
 *          Null here means 'apply the Effect to the whole Bitmap'.
984
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
985
 *          current center of the effect.
986
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
987
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
988
 * @return ID of the effect added, or -1 if we failed to add one. 
989
 */
990
  public long alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
991
    {
992
    Interpolator1D di = new Interpolator1D(); 
993
    di.setCount(count);
994
    di.setDuration(duration);
995
    di.add(new Float1D(1));                          
996
    di.add(new Float1D(alpha));                         
997
   
998
    return mF.add(EffectNames.ALPHA, di, region, i);
999
    }
1000

    
1001
///////////////////////////////////////////////////////////////////////////////////////////////////
1002
/**
1003
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1004
 * <p>
1005
 * Here the center of the Effect stays constant.
1006
 *         
1007
 * @param alpha Level of Alpha (0<=Alpha<=1) we want to interpolate to.
1008
 * @param r The Region this Effect is limited to. 
1009
 *          Null here means 'apply the Effect to the whole Bitmap'.
1010
 * @param p Center of the Effect.
1011
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1012
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1013
 * @return ID of the effect added, or -1 if we failed to add one. 
1014
 */
1015
  public long alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1016
    {
1017
    Interpolator1D di = new Interpolator1D(); 
1018
    di.setCount(count);
1019
    di.setDuration(duration);
1020
    di.add(new Float1D(1));                          
1021
    di.add(new Float1D(alpha));                         
1022
   
1023
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1024
    }
1025

    
1026
///////////////////////////////////////////////////////////////////////////////////////////////////
1027
/**
1028
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1029
 * <p>
1030
 * Here the center of the Effect stays constant and the effect for now change in time.
1031
 *         
1032
 * @param alpha Level of Alpha (0<=Alpha<=1) we want to interpolate to.
1033
 * @param r The Region this Effect is limited to.
1034
 *          Null here means 'apply the Effect to the whole Bitmap'.
1035
 * @param p Center of the Effect.
1036
 * @return ID of the effect added, or -1 if we failed to add one. 
1037
 */
1038
  public long alpha(float alpha, Float4D region, Float2D point)
1039
    {
1040
    Interpolator1D di = new Interpolator1D(); 
1041
    di.setCount(0.5f);
1042
    di.setDuration(0);
1043
    di.add(new Float1D(1));                          
1044
    di.add(new Float1D(alpha));                         
1045
   
1046
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1047
    }
1048
  
1049
///////////////////////////////////////////////////////////////////////////////////////////////////
1050
/**
1051
 * Makes the whole Bitmap change its transparency level.
1052
 * 
1053
 * @param alpha Level of Alpha (0<=Alpha<=1) we want to interpolate to.
1054
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1055
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1056
 * @return ID of the effect added, or -1 if we failed to add one. 
1057
 */
1058
  public long alpha(float alpha, int duration, float count) 
1059
    {
1060
    Interpolator1D di = new Interpolator1D(); 
1061
    di.setCount(count);
1062
    di.setDuration(duration);
1063
    di.add(new Float1D(1));                            
1064
    di.add(new Float1D(alpha));                        
1065
         
1066
    return mF.add(EffectNames.ALPHA, di,null, 0.0f, 0.0f);
1067
    }
1068

    
1069
///////////////////////////////////////////////////////////////////////////////////////////////////  
1070
/**
1071
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1072
 * 
1073
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1074
 */
1075
  public long smooth_alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1076
    {
1077
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, i);
1078
    }
1079

    
1080
///////////////////////////////////////////////////////////////////////////////////////////////////
1081
/**
1082
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1083
 * 
1084
 * See {@link #alpha(int, Float4D, Float2D, int, float)}
1085
 */
1086
  public long smooth_alpha(Interpolator1D a, Float4D region, Float2D point)
1087
    {
1088
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, point.x, point.y);
1089
    }
1090
  
1091
///////////////////////////////////////////////////////////////////////////////////////////////////  
1092
/**
1093
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1094
 * 
1095
 * See {@link #alpha(int, Float4D, Interpolator2D, int, float)}
1096
 */
1097
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1098
    {
1099
    Interpolator1D di = new Interpolator1D(); 
1100
    di.setCount(count);
1101
    di.setDuration(duration);
1102
    di.add(new Float1D(1));                          
1103
    di.add(new Float1D(alpha));                         
1104
   
1105
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, i);
1106
    }
1107

    
1108
///////////////////////////////////////////////////////////////////////////////////////////////////
1109
/**
1110
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1111
 * 
1112
 * See {@link #alpha(int, Float4D, Float2D, int, float)}
1113
 */
1114
  public long smooth_alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1115
    {
1116
    Interpolator1D di = new Interpolator1D(); 
1117
    di.setCount(count);
1118
    di.setDuration(duration);
1119
    di.add(new Float1D(1));                          
1120
    di.add(new Float1D(alpha));                         
1121
   
1122
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1123
    }
1124
  
1125
///////////////////////////////////////////////////////////////////////////////////////////////////
1126
/**
1127
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1128
 * 
1129
 * See {@link #alpha(int, Float4D, Float2D)}
1130
 */
1131
  public long smooth_alpha(float alpha, Float4D region, Float2D point)
1132
    {
1133
    Interpolator1D di = new Interpolator1D(); 
1134
    di.setCount(0.5f);
1135
    di.setDuration(0);
1136
    di.add(new Float1D(1));                          
1137
    di.add(new Float1D(alpha));                         
1138
   
1139
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1140
    }
1141
  
1142
///////////////////////////////////////////////////////////////////////////////////////////////////
1143
///////////////////////////////////////////////////////////////////////////////////////////////////
1144
// BRIGHTNESS
1145
/**
1146
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1147
 *        
1148
 * @param a a 1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1149
 *          moment.
1150
 * @param r The Region this Effect is limited to. 
1151
 *          Null here means 'apply the Effect to the whole Bitmap'.
1152
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1153
 *          current center of the effect.
1154
 * @return ID of the effect added, or -1 if we failed to add one. 
1155
 */
1156
  public long brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1157
    {
1158
    return mF.add(EffectNames.BRIGHTNESS, a, region, i);
1159
    }
1160

    
1161
///////////////////////////////////////////////////////////////////////////////////////////////////
1162
/**
1163
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1164
 * <p>
1165
 * Here the center of the Effect stays constant.
1166
 *         
1167
 * @param a a 1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1168
 *          moment.
1169
 * @param r The Region this Effect is limited to.
1170
 *          Null here means 'apply the Effect to the whole Bitmap'.
1171
 * @param p Center of the Effect.
1172
 * @return ID of the effect added, or -1 if we failed to add one. 
1173
 */
1174
  public long brightness(Interpolator1D a, Float4D region, Float2D point)
1175
    {
1176
    return mF.add(EffectNames.BRIGHTNESS, a, region, point.x, point.y);
1177
    }
1178

    
1179
///////////////////////////////////////////////////////////////////////////////////////////////////  
1180
/**
1181
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1182
 *        
1183
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1184
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1185
 *        lighten it up. 
1186
 * @param r The Region this Effect is limited to.
1187
 *          Null here means 'apply the Effect to the whole Bitmap'.
1188
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1189
 *          current center of the effect.
1190
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1191
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1192
 * @return ID of the effect added, or -1 if we failed to add one. 
1193
 */
1194
  public long brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1195
    {
1196
    Interpolator1D di = new Interpolator1D(); 
1197
    di.setCount(count);
1198
    di.setDuration(duration);
1199
    di.add(new Float1D(1));                          
1200
    di.add(new Float1D(brightness));                         
1201
   
1202
    return mF.add(EffectNames.BRIGHTNESS, di, region, i);
1203
    }
1204

    
1205
///////////////////////////////////////////////////////////////////////////////////////////////////
1206
/**
1207
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1208
 * <p>
1209
 * Here the center of the Effect stays constant.
1210
 *         
1211
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1212
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1213
 *        lighten it up.
1214
 * @param r The Region this Effect is limited to. 
1215
 *          Null here means 'apply the Effect to the whole Bitmap'.
1216
 * @param p Center of the Effect.
1217
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1218
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1219
 * @return ID of the effect added, or -1 if we failed to add one. 
1220
 */
1221
  public long brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1222
    {
1223
    Interpolator1D di = new Interpolator1D(); 
1224
    di.setCount(count);
1225
    di.setDuration(duration);
1226
    di.add(new Float1D(1));                          
1227
    di.add(new Float1D(brightness));                         
1228
   
1229
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1230
    }
1231

    
1232
///////////////////////////////////////////////////////////////////////////////////////////////////
1233
/**
1234
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1235
 * <p>
1236
 * Here the center of the Effect stays constant and the effect for now change in time.
1237
 *         
1238
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1239
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1240
 *        lighten it up.
1241
 * @param r The Region this Effect is limited to.
1242
 *          Null here means 'apply the Effect to the whole Bitmap'.
1243
 * @param p Center of the Effect.
1244
 * @return ID of the effect added, or -1 if we failed to add one. 
1245
 */
1246
  public long brightness(float brightness, Float4D region, Float2D point)
1247
    {
1248
    Interpolator1D di = new Interpolator1D(); 
1249
    di.setCount(0.5f);
1250
    di.setDuration(0);
1251
    di.add(new Float1D(1));                          
1252
    di.add(new Float1D(brightness));                         
1253
   
1254
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1255
    }
1256
 
1257
///////////////////////////////////////////////////////////////////////////////////////////////////
1258
///////////////////////////////////////////////////////////////////////////////////////////////////
1259
// SMOOTH BRIGHTNESS
1260
/**
1261
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1262
 *        
1263
 * @param a a 1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1264
 *          moment.
1265
 * @param r The Region this Effect is limited to. 
1266
 *          Null here means 'apply the Effect to the whole Bitmap'.
1267
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1268
 *          current center of the effect.
1269
 * @return ID of the effect added, or -1 if we failed to add one. 
1270
 */
1271
  public long smooth_brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1272
    {
1273
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, i);
1274
    }
1275

    
1276
///////////////////////////////////////////////////////////////////////////////////////////////////
1277
/**
1278
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1279
 * <p>
1280
 * Here the center of the Effect stays constant.
1281
 *         
1282
 * @param a a 1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1283
 *          moment.
1284
 * @param r The Region this Effect is limited to. 
1285
 *          Null here means 'apply the Effect to the whole Bitmap'.
1286
 * @param p Center of the Effect.
1287
 * @return ID of the effect added, or -1 if we failed to add one. 
1288
 */
1289
  public long smooth_brightness(Interpolator1D a, Float4D region, Float2D point)
1290
    {
1291
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, point.x, point.y);
1292
    }
1293

    
1294
///////////////////////////////////////////////////////////////////////////////////////////////////  
1295
/**
1296
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1297
 *        
1298
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1299
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1300
 *        lighten it up. 
1301
 * @param r The Region this Effect is limited to. 
1302
 *          Null here means 'apply the Effect to the whole Bitmap'.
1303
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1304
 *          current center of the effect.
1305
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1306
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1307
 * @return ID of the effect added, or -1 if we failed to add one. 
1308
 */
1309
  public long smooth_brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1310
    {
1311
    Interpolator1D di = new Interpolator1D(); 
1312
    di.setCount(count);
1313
    di.setDuration(duration);
1314
    di.add(new Float1D(1));                          
1315
    di.add(new Float1D(brightness));                         
1316
   
1317
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, i);
1318
    }
1319

    
1320
///////////////////////////////////////////////////////////////////////////////////////////////////
1321
/**
1322
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1323
 * <p>
1324
 * Here the center of the Effect stays constant.
1325
 *         
1326
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1327
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1328
 *        lighten it up.
1329
 * @param r The Region this Effect is limited to. 
1330
 *          Null here means 'apply the Effect to the whole Bitmap'.
1331
 * @param p Center of the Effect.
1332
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1333
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1334
 * @return ID of the effect added, or -1 if we failed to add one. 
1335
 */
1336
  public long smooth_brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1337
    {
1338
    Interpolator1D di = new Interpolator1D(); 
1339
    di.setCount(count);
1340
    di.setDuration(duration);
1341
    di.add(new Float1D(1));                          
1342
    di.add(new Float1D(brightness));                         
1343
   
1344
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1345
    }
1346

    
1347
///////////////////////////////////////////////////////////////////////////////////////////////////
1348
/**
1349
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1350
 * <p>
1351
 * Here the center of the Effect stays constant and the effect for now change in time.
1352
 *         
1353
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1354
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1355
 *        lighten it up.
1356
 * @param r The Region this Effect is limited to. 
1357
 *          Null here means 'apply the Effect to the whole Bitmap'.
1358
 * @param p Center of the Effect.
1359
 * @return ID of the effect added, or -1 if we failed to add one. 
1360
 */
1361
  public long smooth_brightness(float brightness, Float4D region, Float2D point)
1362
    {
1363
    Interpolator1D di = new Interpolator1D(); 
1364
    di.setCount(0.5f);
1365
    di.setDuration(0);
1366
    di.add(new Float1D(1));                          
1367
    di.add(new Float1D(brightness));                         
1368
   
1369
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1370
    }
1371
    
1372
///////////////////////////////////////////////////////////////////////////////////////////////////
1373
/**
1374
 * Makes the whole Bitmap change its brightness level.
1375
 * 
1376
 * @param brightness Level of Brightness (0<=brightness<=infinity) we want to interpolate to.
1377
 *        1 - level of brightness unchanged, anything less than 1 - 'darken the image', anything more than 1-
1378
 *        lighten it up.
1379
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1380
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1381
 * @return ID of the effect added, or -1 if we failed to add one. 
1382
 */
1383
  public long smooth_brightness(float brightness, int duration, float count) 
1384
    {
1385
    Interpolator1D di = new Interpolator1D(); 
1386
    di.setCount(count);
1387
    di.setDuration(duration);
1388
    di.add(new Float1D(1));                            
1389
    di.add(new Float1D(brightness));                        
1390
         
1391
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, 0.0f, 0.0f);
1392
    }
1393

    
1394
///////////////////////////////////////////////////////////////////////////////////////////////////
1395
///////////////////////////////////////////////////////////////////////////////////////////////////
1396
// CONTRAST
1397
/**
1398
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1399
 *        
1400
 * @param a a 1-dimensional Interpolator that returns the level of contrast we want to have at any given 
1401
 *          moment.
1402
 * @param r The Region this Effect is limited to. 
1403
 *          Null here means 'apply the Effect to the whole Bitmap'.
1404
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1405
 *          current center of the effect.
1406
 * @return ID of the effect added, or -1 if we failed to add one. 
1407
 */
1408
  public long contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1409
    {
1410
    return mF.add(EffectNames.CONTRAST, a, region, i);
1411
    }
1412

    
1413
///////////////////////////////////////////////////////////////////////////////////////////////////
1414
/**
1415
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1416
 * <p>
1417
 * Here the center of the Effect stays constant.
1418
 *         
1419
 * @param a a 1-dimensional Interpolator that returns the level of contrast we want to have at any given 
1420
 *          moment.
1421
 * @param r The Region this Effect is limited to.
1422
 *          Null here means 'apply the Effect to the whole Bitmap'.
1423
 * @param p Center of the Effect.
1424
 * @return ID of the effect added, or -1 if we failed to add one. 
1425
 */
1426
  public long contrast(Interpolator1D a, Float4D region, Float2D point)
1427
    {
1428
    return mF.add(EffectNames.CONTRAST, a, region, point.x, point.y);
1429
    }
1430

    
1431
///////////////////////////////////////////////////////////////////////////////////////////////////  
1432
/**
1433
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1434
 *        
1435
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1436
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1437
 *        increase the contrast. 
1438
 * @param r The Region this Effect is limited to.
1439
 *          Null here means 'apply the Effect to the whole Bitmap'.
1440
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1441
 *          current center of the effect.
1442
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1443
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1444
 * @return ID of the effect added, or -1 if we failed to add one. 
1445
 */
1446
  public long contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1447
    {
1448
    Interpolator1D di = new Interpolator1D(); 
1449
    di.setCount(count);
1450
    di.setDuration(duration);
1451
    di.add(new Float1D(1));                          
1452
    di.add(new Float1D(contrast));                         
1453
   
1454
    return mF.add(EffectNames.CONTRAST, di, region, i);
1455
    }
1456

    
1457
///////////////////////////////////////////////////////////////////////////////////////////////////
1458
/**
1459
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1460
 * <p>
1461
 * Here the center of the Effect stays constant.
1462
 *         
1463
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1464
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1465
 *        increase the contrast. 
1466
 * @param r The Region this Effect is limited to. 
1467
 *          Null here means 'apply the Effect to the whole Bitmap'.
1468
 * @param p Center of the Effect.
1469
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1470
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1471
 * @return ID of the effect added, or -1 if we failed to add one. 
1472
 */
1473
  public long contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1474
    {
1475
    Interpolator1D di = new Interpolator1D(); 
1476
    di.setCount(count);
1477
    di.setDuration(duration);
1478
    di.add(new Float1D(1));                          
1479
    di.add(new Float1D(contrast));                         
1480
   
1481
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1482
    }
1483

    
1484
///////////////////////////////////////////////////////////////////////////////////////////////////
1485
/**
1486
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1487
 * <p>
1488
 * Here the center of the Effect stays constant and the effect for now change in time.
1489
 *         
1490
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1491
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1492
 *        increase the contrast. 
1493
 * @param r The Region this Effect is limited to. 
1494
 *          Null here means 'apply the Effect to the whole Bitmap'.
1495
 * @param p Center of the Effect.
1496
 * @return ID of the effect added, or -1 if we failed to add one. 
1497
 */
1498
  public long contrast(float contrast, Float4D region, Float2D point)
1499
    {
1500
    Interpolator1D di = new Interpolator1D(); 
1501
    di.setCount(0.5f);
1502
    di.setDuration(0);
1503
    di.add(new Float1D(1));                          
1504
    di.add(new Float1D(contrast));                         
1505
   
1506
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1507
    }
1508
 
1509
///////////////////////////////////////////////////////////////////////////////////////////////////
1510
///////////////////////////////////////////////////////////////////////////////////////////////////
1511
// SMOOTH CONTRAST
1512
/**
1513
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1514
 *        
1515
 * @param a a 1-dimensional Interpolator that returns the level of contrast we want to have at any given 
1516
 *          moment.
1517
 * @param r The Region this Effect is limited to. 
1518
 *          Null here means 'apply the Effect to the whole Bitmap'.
1519
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1520
 *          current center of the effect.
1521
 * @return ID of the effect added, or -1 if we failed to add one. 
1522
 */
1523
  public long smooth_contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1524
    {
1525
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, i);
1526
    }
1527

    
1528
///////////////////////////////////////////////////////////////////////////////////////////////////
1529
/**
1530
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1531
 * <p>
1532
 * Here the center of the Effect stays constant.
1533
 *         
1534
 * @param a a 1-dimensional Interpolator that returns the level of contrast we want to have at any given 
1535
 *          moment.
1536
 * @param r The Region this Effect is limited to. 
1537
 *          Null here means 'apply the Effect to the whole Bitmap'.
1538
 * @param p Center of the Effect.
1539
 * @return ID of the effect added, or -1 if we failed to add one. 
1540
 */
1541
  public long smooth_contrast(Interpolator1D a, Float4D region, Float2D point)
1542
    {
1543
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, point.x, point.y);
1544
    }
1545

    
1546
///////////////////////////////////////////////////////////////////////////////////////////////////  
1547
/**
1548
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1549
 *        
1550
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1551
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1552
 *        increase the contrast. 
1553
 * @param r The Region this Effect is limited to. 
1554
 *          Null here means 'apply the Effect to the whole Bitmap'.
1555
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1556
 *          current center of the effect.
1557
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1558
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1559
 * @return ID of the effect added, or -1 if we failed to add one. 
1560
 */
1561
  public long smooth_contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1562
    {
1563
    Interpolator1D di = new Interpolator1D(); 
1564
    di.setCount(count);
1565
    di.setDuration(duration);
1566
    di.add(new Float1D(1));                          
1567
    di.add(new Float1D(contrast));                         
1568
   
1569
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, i);
1570
    }
1571

    
1572
///////////////////////////////////////////////////////////////////////////////////////////////////
1573
/**
1574
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1575
 * <p>
1576
 * Here the center of the Effect stays constant.
1577
 *         
1578
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1579
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1580
 *        increase the contrast. 
1581
 * @param r The Region this Effect is limited to. 
1582
 *          Null here means 'apply the Effect to the whole Bitmap'.
1583
 * @param p Center of the Effect.
1584
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1585
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1586
 * @return ID of the effect added, or -1 if we failed to add one. 
1587
 */
1588
  public long smooth_contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1589
    {
1590
    Interpolator1D di = new Interpolator1D(); 
1591
    di.setCount(count);
1592
    di.setDuration(duration);
1593
    di.add(new Float1D(1));                          
1594
    di.add(new Float1D(contrast));                         
1595
   
1596
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1597
    }
1598

    
1599
///////////////////////////////////////////////////////////////////////////////////////////////////
1600
/**
1601
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1602
 * <p>
1603
 * Here the center of the Effect stays constant and the effect for now change in time.
1604
 *         
1605
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1606
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1607
 *        increase the contrast. 
1608
 * @param r The Region this Effect is limited to. 
1609
 *          Null here means 'apply the Effect to the whole Bitmap'.
1610
 * @param p Center of the Effect.
1611
 * @return ID of the effect added, or -1 if we failed to add one. 
1612
 */
1613
  public long smooth_contrast(float contrast, Float4D region, Float2D point)
1614
    {
1615
    Interpolator1D di = new Interpolator1D(); 
1616
    di.setCount(0.5f);
1617
    di.setDuration(0);
1618
    di.add(new Float1D(1));                          
1619
    di.add(new Float1D(contrast));                         
1620
   
1621
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1622
    }
1623
    
1624
///////////////////////////////////////////////////////////////////////////////////////////////////
1625
/**
1626
 * Makes the whole Bitmap change its contrast level.
1627
 * 
1628
 * @param contrast Level of contrast (0<=contrast<=infinity) we want to interpolate to.
1629
 *        1 - level of contrast unchanged, anything less than 1 - reduce contrast, anything more than 1-
1630
 *        increase the contrast. 
1631
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1632
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1633
 * @return ID of the effect added, or -1 if we failed to add one. 
1634
 */
1635
  public long smooth_contrast(float contrast, int duration, float count) 
1636
    {
1637
    Interpolator1D di = new Interpolator1D(); 
1638
    di.setCount(count);
1639
    di.setDuration(duration);
1640
    di.add(new Float1D(1));                            
1641
    di.add(new Float1D(contrast));                        
1642
         
1643
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, 0.0f, 0.0f);
1644
    }
1645

    
1646

    
1647
///////////////////////////////////////////////////////////////////////////////////////////////////
1648
///////////////////////////////////////////////////////////////////////////////////////////////////
1649
// SATURATION
1650
/**
1651
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1652
 *        
1653
 * @param a a 1-dimensional Interpolator that returns the level of saturation we want to have at any given 
1654
 *          moment.
1655
 * @param r The 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 representing the
1658
 *          current center of the effect.
1659
 * @return ID of the effect added, or -1 if we failed to add one. 
1660
 */
1661
  public long saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1662
    {
1663
    return mF.add(EffectNames.SATURATION, a, region, i);
1664
    }
1665

    
1666
///////////////////////////////////////////////////////////////////////////////////////////////////
1667
/**
1668
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1669
 * <p>
1670
 * Here the center of the Effect stays constant.
1671
 *         
1672
 * @param a a 1-dimensional Interpolator that returns the level of saturation we want to have at any given 
1673
 *          moment.
1674
 * @param r The Region this Effect is limited to. 
1675
 *          Null here means 'apply the Effect to the whole Bitmap'.
1676
 * @param p Center of the Effect.
1677
 * @return ID of the effect added, or -1 if we failed to add one. 
1678
 */
1679
  public long saturation(Interpolator1D a, Float4D region, Float2D point)
1680
    {
1681
    return mF.add(EffectNames.SATURATION, a, region, point.x, point.y);
1682
    }
1683

    
1684
///////////////////////////////////////////////////////////////////////////////////////////////////  
1685
/**
1686
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1687
 *        
1688
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1689
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1690
 *        increase the saturation. 
1691
 * @param r The Region this Effect is limited to.
1692
 *          Null here means 'apply the Effect to the whole Bitmap'.
1693
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1694
 *          current center of the effect.
1695
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1696
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1697
 * @return ID of the effect added, or -1 if we failed to add one. 
1698
 */
1699
  public long saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1700
    {
1701
    Interpolator1D di = new Interpolator1D(); 
1702
    di.setCount(count);
1703
    di.setDuration(duration);
1704
    di.add(new Float1D(1));                          
1705
    di.add(new Float1D(saturation));                         
1706
   
1707
    return mF.add(EffectNames.SATURATION, di, region, i);
1708
    }
1709

    
1710
///////////////////////////////////////////////////////////////////////////////////////////////////
1711
/**
1712
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1713
 * <p>
1714
 * Here the center of the Effect stays constant.
1715
 *         
1716
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1717
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1718
 *        increase the saturation. 
1719
 * @param r The Region this Effect is limited to. 
1720
 *          Null here means 'apply the Effect to the whole Bitmap'.
1721
 * @param p Center of the Effect.
1722
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1723
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1724
 * @return ID of the effect added, or -1 if we failed to add one. 
1725
 */
1726
  public long saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1727
    {
1728
    Interpolator1D di = new Interpolator1D(); 
1729
    di.setCount(count);
1730
    di.setDuration(duration);
1731
    di.add(new Float1D(1));                          
1732
    di.add(new Float1D(saturation));                         
1733
   
1734
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1735
    }
1736

    
1737
///////////////////////////////////////////////////////////////////////////////////////////////////
1738
/**
1739
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1740
 * <p>
1741
 * Here the center of the Effect stays constant and the effect for now change in time.
1742
 *         
1743
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1744
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1745
 *        increase the saturation. 
1746
 * @param r The Region this Effect is limited to. 
1747
 *          Null here means 'apply the Effect to the whole Bitmap'.
1748
 * @param p Center of the Effect.
1749
 * @return ID of the effect added, or -1 if we failed to add one. 
1750
 */
1751
  public long saturation(float saturation, Float4D region, Float2D point)
1752
    {
1753
    Interpolator1D di = new Interpolator1D(); 
1754
    di.setCount(0.5f);
1755
    di.setDuration(0);
1756
    di.add(new Float1D(1));                          
1757
    di.add(new Float1D(saturation));                         
1758
   
1759
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1760
    }
1761
 
1762
///////////////////////////////////////////////////////////////////////////////////////////////////
1763
///////////////////////////////////////////////////////////////////////////////////////////////////
1764
// SMOOTH_SATURATION
1765
/**
1766
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1767
 *        
1768
 * @param a a 1-dimensional Interpolator that returns the level of saturation we want to have at any given 
1769
 *          moment.
1770
 * @param r The Region this Effect is limited to. 
1771
 *          Null here means 'apply the Effect to the whole Bitmap'.
1772
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1773
 *          current center of the effect.
1774
 * @return ID of the effect added, or -1 if we failed to add one. 
1775
 */
1776
  public long smooth_saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1777
    {
1778
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, i);
1779
    }
1780

    
1781
///////////////////////////////////////////////////////////////////////////////////////////////////
1782
/**
1783
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1784
 * <p>
1785
 * Here the center of the Effect stays constant.
1786
 *         
1787
 * @param a a 1-dimensional Interpolator that returns the level of saturation we want to have at any given 
1788
 *          moment.
1789
 * @param r The Region this Effect is limited to. 
1790
 *          Null here means 'apply the Effect to the whole Bitmap'.
1791
 * @param p Center of the Effect.
1792
 * @return ID of the effect added, or -1 if we failed to add one. 
1793
 */
1794
  public long smooth_saturation(Interpolator1D a, Float4D region, Float2D point)
1795
    {
1796
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, point.x, point.y);
1797
    }
1798

    
1799
///////////////////////////////////////////////////////////////////////////////////////////////////  
1800
/**
1801
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1802
 *        
1803
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1804
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1805
 *        increase the saturation. 
1806
 * @param r The Region this Effect is limited to. 
1807
 *          Null here means 'apply the Effect to the whole Bitmap'.
1808
 * @param i 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1809
 *          current center of the effect.
1810
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1811
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1812
 * @return ID of the effect added, or -1 if we failed to add one. 
1813
 */
1814
  public long smooth_saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1815
    {
1816
    Interpolator1D di = new Interpolator1D(); 
1817
    di.setCount(count);
1818
    di.setDuration(duration);
1819
    di.add(new Float1D(1));                          
1820
    di.add(new Float1D(saturation));                         
1821
   
1822
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, i);
1823
    }
1824

    
1825
///////////////////////////////////////////////////////////////////////////////////////////////////
1826
/**
1827
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1828
 * <p>
1829
 * Here the center of the Effect stays constant.
1830
 *         
1831
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1832
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1833
 *        increase the saturation. 
1834
 * @param r The Region this Effect is limited to. 
1835
 *          Null here means 'apply the Effect to the whole Bitmap'.
1836
 * @param p Center of the Effect.
1837
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1838
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1839
 * @return ID of the effect added, or -1 if we failed to add one. 
1840
 */
1841
  public long smooth_saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1842
    {
1843
    Interpolator1D di = new Interpolator1D(); 
1844
    di.setCount(count);
1845
    di.setDuration(duration);
1846
    di.add(new Float1D(1));                          
1847
    di.add(new Float1D(saturation));                         
1848
   
1849
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1850
    }
1851

    
1852
///////////////////////////////////////////////////////////////////////////////////////////////////
1853
/**
1854
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1855
 * <p>
1856
 * Here the center of the Effect stays constant and the effect for now change in time.
1857
 *         
1858
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1859
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1860
 *        increase the saturation. 
1861
 * @param r The Region this Effect is limited to. 
1862
 *          Null here means 'apply the Effect to the whole Bitmap'.
1863
 * @param p Center of the Effect.
1864
 * @return ID of the effect added, or -1 if we failed to add one. 
1865
 */
1866
  public long smooth_saturation(float saturation, Float4D region, Float2D point)
1867
    {
1868
    Interpolator1D di = new Interpolator1D(); 
1869
    di.setCount(0.5f);
1870
    di.setDuration(0);
1871
    di.add(new Float1D(1));                          
1872
    di.add(new Float1D(saturation));                         
1873
   
1874
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1875
    }
1876
    
1877
///////////////////////////////////////////////////////////////////////////////////////////////////
1878
/**
1879
 * Makes the whole Bitmap change its saturation level.
1880
 * 
1881
 * @param saturation Level of saturation (0<=saturation<=infinity) we want to interpolate to.
1882
 *        1 - level of saturation unchanged, anything less than 1 - reduce saturation, anything more than 1-
1883
 *        increase the saturation. 
1884
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1885
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1886
 * @return ID of the effect added, or -1 if we failed to add one. 
1887
 */
1888
  public long smooth_saturation(float saturation, int duration, float count) 
1889
    {
1890
    Interpolator1D di = new Interpolator1D(); 
1891
    di.setCount(count);
1892
    di.setDuration(duration);
1893
    di.add(new Float1D(1));                            
1894
    di.add(new Float1D(saturation));                        
1895
         
1896
    return mF.add(EffectNames.SMOOTH_SATURATION, di,null, 0.0f, 0.0f);
1897
    }
1898
            
1899
///////////////////////////////////////////////////////////////////////////////////////////////////
1900
// Vertex-based effects  
1901
///////////////////////////////////////////////////////////////////////////////////////////////////
1902
// DISTORT
1903
/**
1904
 * Distort a (possibly changing in time) part of the Bitmap by a (possibly changing in time) vector of force.
1905
 * 
1906
 * @param i A 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which represents
1907
 *          the vector the Center of the Effect is currently being dragged with.
1908
 * @param r Region that masks the effect of the Distortion.
1909
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
1910
 *          the Center of the Effect.
1911
 * @return ID of the effect added, or -1 if we failed to add one. 
1912
 */
1913
  public long distort(Interpolator i, Float4D region, Interpolator2D p)
1914
    {  
1915
    return mV.add(EffectNames.DISTORT, i, region, p);  
1916
    }
1917

    
1918
///////////////////////////////////////////////////////////////////////////////////////////////////
1919
/**
1920
 * Distort part of the Bitmap by a (possibly changing in time) vector of force.
1921
 * <p>
1922
 * Difference between this and the previous method is that here the center of the Effect stays constant.
1923
 *   
1924
 * @param i A 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which represents
1925
 *          the vector the Center of the Effect is currently being dragged with.
1926
 * @param r Region that masks the effect of the Distortion.
1927
 * @param p Center of the Effect.
1928
 * @return ID of the effect added, or -1 if we failed to add one. 
1929
 */
1930
  public long distort(Interpolator i, Float4D region, Float2D point)
1931
    {  
1932
    return mV.add(EffectNames.DISTORT, i, region, point.x, point.y);  
1933
    }
1934

    
1935
///////////////////////////////////////////////////////////////////////////////////////////////////
1936
/**
1937
 * Distort the whole Bitmap by a (possibly changing in time) vector of force.
1938
 * 
1939
 * @param i A 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which represents
1940
 *          the vector the Center of the Effect is currently being dragged with.
1941
 * @param p Center of the Effect.
1942
 * @return ID of the effect added, or -1 if we failed to add one. 
1943
 */
1944
  public long distort(Interpolator i, Float2D point)
1945
    {
1946
    return mV.add(EffectNames.DISTORT, i, null, point.x, point.y);  
1947
    }
1948

    
1949
///////////////////////////////////////////////////////////////////////////////////////////////////
1950
/**
1951
 * Distort part of the Bitmap by a vector of force that changes from (0,0,0) to v.
1952
 * 
1953
 * @param v The maximum vector of force. 
1954
 * @param r Region that masks the effect of the Distortion.
1955
 * @param p Center of the Effect.
1956
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1957
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1958
 * @return ID of the effect added, or -1 if we failed to add one. 
1959
 */
1960
  public long distort(Float3D vector, Float4D region, Float2D point, int duration, float count)
1961
    {  
1962
    Interpolator3D di = new Interpolator3D(); 
1963
    di.setCount(count);
1964
    di.setDuration(duration);
1965
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1966
    di.add(vector);                                                  
1967
           
1968
    return mV.add(EffectNames.DISTORT, di, region, point.x, point.y);  
1969
    }
1970

    
1971
///////////////////////////////////////////////////////////////////////////////////////////////////
1972
/**
1973
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
1974
 * 
1975
 * @param v The maximum vector of force.
1976
 * @param p Center of the Effect.
1977
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1978
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1979
 * @return ID of the effect added, or -1 if we failed to add one. 
1980
 */
1981
  public long distort(Float3D vector, Float2D point, int duration, float count)
1982
    {
1983
    Interpolator3D di = new Interpolator3D(); 
1984
    di.setCount(count);
1985
    di.setDuration(duration);
1986
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1987
    di.add(vector);                                                 
1988
           
1989
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
1990
    }
1991

    
1992
///////////////////////////////////////////////////////////////////////////////////////////////////
1993
/**
1994
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
1995
 * <p>
1996
 * Difference between this and the previous method is that here the vector of force will get interpolated
1997
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
1998
 * 
1999
 * @param v The maximum, final vector of force.
2000
 * @param p Center of the Effect.
2001
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2002
 * @return ID of the effect added, or -1 if we failed to add one. 
2003
 */
2004
  public long distort(Float3D vector, Float2D point, int duration)
2005
    {
2006
    Interpolator3D di = new Interpolator3D();  
2007
    di.setCount(0.5f);
2008
    di.setDuration(duration);
2009
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2010
    di.add(vector);                 
2011
           
2012
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2013
    }
2014

    
2015
///////////////////////////////////////////////////////////////////////////////////////////////////
2016
/**
2017
 * Distort the whole Bitmap by a vector of force v.
2018
 * <p>
2019
 * Here we apply a constant vector of force.
2020
 * 
2021
 * @param v The vector of force.
2022
 * @param p Center of the Effect.
2023
 * @return ID of the effect added, or -1 if we failed to add one. 
2024
 */
2025
  public long distort(Float3D vector, Float2D point )
2026
    {
2027
    Interpolator3D di = new Interpolator3D(); 
2028
    di.setCount(0.5f);
2029
    di.setDuration(0);
2030
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2031
    di.add(vector);           
2032
           
2033
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2034
    }
2035

    
2036
///////////////////////////////////////////////////////////////////////////////////////////////////
2037
///////////////////////////////////////////////////////////////////////////////////////////////////
2038
// DEFORM
2039
/**
2040
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2041
 * a (possibly changing in time) point on the Bitmap.
2042
 *     
2043
 * @param i A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2044
 *          vector of force that deforms the shapre of the whole Bitmap.
2045
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2046
 *          the Center of the Effect.
2047
 * @return ID of the effect added, or -1 if we failed to add one. 
2048
 */
2049
  public long deform(Interpolator i, Interpolator2D point)
2050
    {  
2051
    return mV.add(EffectNames.DEFORM, i, null, point);  
2052
    }
2053

    
2054
///////////////////////////////////////////////////////////////////////////////////////////////////
2055
/**
2056
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2057
 * a constant point on the Bitmap.
2058
 * 
2059
 * @param i A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2060
 *          vector of force that deforms the shapre of the whole Bitmap.
2061
 * @param p Center of the Effect.
2062
 * @return ID of the effect added, or -1 if we failed to add one. 
2063
 */
2064
  public long deform(Interpolator i, Float2D point)
2065
    {
2066
    return mV.add(EffectNames.DEFORM, i, null, point.x, point.y);  
2067
    }
2068

    
2069
///////////////////////////////////////////////////////////////////////////////////////////////////
2070
/**
2071
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2072
 * applied to a constant point on the Bitmap. 
2073
 * 
2074
 * @param v Vector of force.
2075
 * @param p Center of the Effect.
2076
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2077
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2078
 * @return ID of the effect added, or -1 if we failed to add one. 
2079
 */
2080
  public long deform(Float3D vector, Float2D point, int duration, float count)
2081
    {
2082
    Interpolator3D di = new Interpolator3D(); 
2083
    di.setCount(count);
2084
    di.setDuration(duration);
2085
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2086
    di.add(vector);                
2087
           
2088
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2089
    }
2090

    
2091
///////////////////////////////////////////////////////////////////////////////////////////////////
2092
/**
2093
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2094
 * applied to a constant point on the Bitmap. 
2095
 * <p>
2096
 * Identical to calling the previous method with count=0.5.
2097
 * 
2098
 * @param v Final vector of force.
2099
 * @param p Center of the Effect.
2100
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2101
 * @return ID of the effect added, or -1 if we failed to add one. 
2102
 */
2103
  public long deform(Float3D vector, Float2D point, int duration)
2104
    {
2105
    Interpolator3D di = new Interpolator3D();  
2106
    di.setCount(0.5f);
2107
    di.setDuration(duration);
2108
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2109
    di.add(vector);             
2110
           
2111
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2112
    }
2113

    
2114
///////////////////////////////////////////////////////////////////////////////////////////////////
2115
/**
2116
 * Deform the shape of the whole Bitmap with a constant vector of force applied to a constant 
2117
 * point on the Bitmap. 
2118
 * 
2119
 * @param v Vector of force.
2120
 * @param p Center of the Effect.
2121
 * @return ID of the effect added, or -1 if we failed to add one. 
2122
 */
2123
  public long deform(Float3D vector, Float2D point )
2124
    {
2125
    Interpolator3D di = new Interpolator3D(); 
2126
    di.setCount(0.5f);
2127
    di.setDuration(0);
2128
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2129
    di.add(vector);            
2130
           
2131
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2132
    }
2133
   
2134
///////////////////////////////////////////////////////////////////////////////////////////////////  
2135
///////////////////////////////////////////////////////////////////////////////////////////////////
2136
// SINK
2137
/**
2138
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2139
 * away from the center (degree<=1)
2140
 *    
2141
 * @param di A 1-dimensional Interpolator which, at any given time, returns a Point1D representing
2142
 *          the current degree of the effect.
2143
 * @param r Region that masks the effect of the Sink.
2144
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2145
 *          the Center of the Effect.
2146
 * @return ID of the effect added, or -1 if we failed to add one. 
2147
 */
2148
  public long sink(Interpolator1D di, Float4D region, Interpolator2D point)
2149
    {
2150
    return mV.add(EffectNames.SINK, di, region, point);  
2151
    }
2152

    
2153
///////////////////////////////////////////////////////////////////////////////////////////////////
2154
/**
2155
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2156
 * away from the center (degree<=1).
2157
 * <p>
2158
 * Here the Center stays constant.
2159
 *      
2160
 * @param di A 1-dimensional Interpolator which, at any given time, returns a Point1D representing
2161
 *          the current degree of the effect.
2162
 * @param r Region that masks the effect of the Sink.
2163
 * @param p Center of the Effect.
2164
 * @return ID of the effect added, or -1 if we failed to add one. 
2165
 */
2166
  public long sink(Interpolator1D di, Float4D region, Float2D point)
2167
    {
2168
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2169
    }
2170
  
2171
///////////////////////////////////////////////////////////////////////////////////////////////////
2172
/**
2173
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2174
 * away from the center (degree<=1).
2175
 * <p>
2176
 * Here we can only interpolate between 1 and degree.
2177
 * 
2178
 * @param degree How much to push or pull. 0<=degree<=infinity.
2179
 * @param r Region that masks the effect of the Sink.
2180
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2181
 *          the Center of the Effect.
2182
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2183
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2184
 * @return ID of the effect added, or -1 if we failed to add one. 
2185
 */
2186
  public long sink(float degree, Float4D region, Interpolator2D p, int duration, float count)
2187
    {
2188
    Interpolator1D di = new Interpolator1D(); 
2189
    di.setCount(count);
2190
    di.setDuration(duration);
2191
    di.add(new Float1D(1));                                
2192
    di.add(new Float1D(degree));                          
2193
    
2194
    return mV.add(EffectNames.SINK, di, region, p);  
2195
    }
2196

    
2197
///////////////////////////////////////////////////////////////////////////////////////////////////
2198
/**
2199
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2200
 * away from the center (degree<=1).
2201
 *   
2202
 * @param degree How much to push or pull. 0<=degree<=infinity.
2203
 * @param r Region that masks the effect of the Sink.
2204
 * @param p Center of the Effect.
2205
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2206
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2207
 * @return ID of the effect added, or -1 if we failed to add one. 
2208
 */
2209
  public long sink(float degree, Float4D region, Float2D point, int duration, float count)
2210
    {
2211
    Interpolator1D di = new Interpolator1D(); 
2212
    di.setCount(count);
2213
    di.setDuration(duration);
2214
    di.add(new Float1D(1));                                
2215
    di.add(new Float1D(degree));                          
2216
    
2217
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2218
    }
2219

    
2220
///////////////////////////////////////////////////////////////////////////////////////////////////
2221
/**
2222
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2223
 * away from the center (degree<=1).
2224
 * 
2225
 * @param degree How much to push or pull. 0<=degree<=infinity.
2226
 * @param p Center of the Effect.
2227
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2228
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2229
 * @return ID of the effect added, or -1 if we failed to add one. 
2230
 */
2231
  public long sink(float degree, Float2D point, int duration, float count) 
2232
    {
2233
    Interpolator1D di = new Interpolator1D();  
2234
    di.setCount(count);
2235
    di.setDuration(duration);
2236
    di.add(new Float1D(1));                                
2237
    di.add(new Float1D(degree));                          
2238
         
2239
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2240
    }
2241

    
2242
///////////////////////////////////////////////////////////////////////////////////////////////////
2243
/**
2244
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2245
 * away from the center (degree<=1).
2246
 * <p>
2247
 * Equivalent to calling the previous method with count=0.5.
2248
 * 
2249
 * @param degree How much to push or pull. 0<=degree<=infinity.
2250
 * @param p Center of the Effect.
2251
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2252
 * @return ID of the effect added, or -1 if we failed to add one. 
2253
 */
2254
  public long sink(float degree, Float2D point, int duration) 
2255
    {
2256
    Interpolator1D di = new Interpolator1D(); 
2257
    di.setCount(0.5f);
2258
    di.setDuration(duration);
2259
    di.add(new Float1D(1));                               
2260
    di.add(new Float1D(degree));                      
2261
        
2262
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2263
    }
2264

    
2265
///////////////////////////////////////////////////////////////////////////////////////////////////
2266
/**
2267
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2268
 * away from the center (degree<=1).
2269
 * <p>
2270
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2271
 * 
2272
 * @param degree How much to push or pull. 0<=degree<=infinity.
2273
 * @param p Center of the Effect.
2274
 * @return ID of the effect added, or -1 if we failed to add one. 
2275
 */
2276
  public long sink(float degree, Float2D point) 
2277
    {
2278
    Interpolator1D di = new Interpolator1D(); 
2279
    di.setCount(0.5f);
2280
    di.setDuration(0);
2281
    di.add(new Float1D(1));                               
2282
    di.add(new Float1D(degree));                      
2283
        
2284
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2285
    }
2286
  
2287
///////////////////////////////////////////////////////////////////////////////////////////////////  
2288
///////////////////////////////////////////////////////////////////////////////////////////////////
2289
// SWIRL
2290
/**
2291
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2292
 * Interpolator). 
2293
 *   
2294
 * @param di A 1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2295
 *           the degree of Swirl.
2296
 * @param r Region that masks the effect of the Swirl.
2297
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2298
 *          the Center of the Effect.
2299
 * @return ID of the effect added, or -1 if we failed to add one. 
2300
 */
2301
  public long swirl(Interpolator1D di, Float4D region, Interpolator2D point)
2302
    {    
2303
    return mV.add(EffectNames.SWIRL, di, region, point);  
2304
    }
2305

    
2306
///////////////////////////////////////////////////////////////////////////////////////////////////
2307
/**
2308
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2309
 * Interpolator).
2310
 * <p>
2311
 * Here the Center stays constant.
2312
 *      
2313
 * @param di A 1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2314
 *           the degree of Swirl.
2315
 * @param r Region that masks the effect of the Swirl.
2316
 * @param p Center of the Effect.
2317
 * @return ID of the effect added, or -1 if we failed to add one. 
2318
 */
2319
  public long swirl(Interpolator1D di, Float4D region, Float2D point)
2320
    {    
2321
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2322
    }
2323
 
2324
///////////////////////////////////////////////////////////////////////////////////////////////////
2325
/**
2326
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2327
 *   
2328
 * @param degree Angle, in degrees, of rotation.
2329
 * @param r Region that masks the effect of the Swirl.
2330
 * @param p A 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2331
 *          the Center of the Effect.
2332
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2333
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2334
 * @return ID of the effect added, or -1 if we failed to add one. 
2335
 */
2336
  public long swirl(int degree, Float4D region, Interpolator2D point, int duration, float count)
2337
    {
2338
    Interpolator1D di = new Interpolator1D(); 
2339
    di.setCount(count);
2340
    di.setDuration(duration);
2341
    di.add(new Float1D(0));                                
2342
    di.add(new Float1D(degree));                          
2343
    
2344
    return mV.add(EffectNames.SWIRL, di, region, point);  
2345
    }
2346

    
2347
///////////////////////////////////////////////////////////////////////////////////////////////////
2348
/**
2349
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2350
 * <p>
2351
 * Here the Center stays constant.
2352
 *    
2353
 * @param degree Angle, in degrees, of rotation.
2354
 * @param r Region that masks the effect of the Swirl.
2355
 * @param p Center of the Effect.
2356
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2357
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2358
 * @return ID of the effect added, or -1 if we failed to add one. 
2359
 */
2360
  public long swirl(int degree, Float4D region, Float2D point, int duration, float count)
2361
    {
2362
    Interpolator1D di = new Interpolator1D(); 
2363
    di.setCount(count);
2364
    di.setDuration(duration);
2365
    di.add(new Float1D(0));                                
2366
    di.add(new Float1D(degree));                          
2367
    
2368
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2369
    }
2370

    
2371
///////////////////////////////////////////////////////////////////////////////////////////////////
2372
/**
2373
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2374
 * 
2375
 * @param degree Angle, in degrees, of rotation.
2376
 * @param p Center of the Effect.
2377
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2378
 * @param count Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2379
 * @return ID of the effect added, or -1 if we failed to add one. 
2380
 */
2381
  public long swirl(int degree, Float2D point, int duration, float count) 
2382
    {
2383
    Interpolator1D di = new Interpolator1D();  
2384
    di.setCount(count);
2385
    di.setDuration(duration);
2386
    di.add(new Float1D(0));                                
2387
    di.add(new Float1D(degree));                          
2388
         
2389
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2390
    }
2391

    
2392
///////////////////////////////////////////////////////////////////////////////////////////////////
2393
/**
2394
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2395
 * <p>
2396
 * Equivalent to calling the previous method with count=0.5.
2397
 * 
2398
 * @param degree Angle, in degrees, of rotation.
2399
 * @param p Center of the Effect.
2400
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2401
 * @return ID of the effect added, or -1 if we failed to add one. 
2402
 */
2403
  public long swirl(int degree, Float2D point, int duration) 
2404
    {
2405
    Interpolator1D di = new Interpolator1D(); 
2406
    di.setCount(0.5f);
2407
    di.setDuration(duration);
2408
    di.add(new Float1D(0));                               
2409
    di.add(new Float1D(degree));                      
2410
        
2411
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2412
    }
2413

    
2414
///////////////////////////////////////////////////////////////////////////////////////////////////
2415
/**
2416
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2417
 * <p>
2418
 * Equivalent to calling the previous method with duration=0.
2419
 * 
2420
 * @param degree Angle, in degrees, of rotation.
2421
 * @param p Center of the Effect.
2422
 * @return ID of the effect added, or -1 if we failed to add one. 
2423
 */
2424
  public long swirl(int degree, Float2D point) 
2425
    {
2426
    Interpolator1D di = new Interpolator1D(); 
2427
    di.setCount(0.5f);
2428
    di.setDuration(0);
2429
    di.add(new Float1D(0));                               
2430
    di.add(new Float1D(degree));                      
2431
        
2432
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2433
    }
2434

    
2435
///////////////////////////////////////////////////////////////////////////////////////////////////
2436
///////////////////////////////////////////////////////////////////////////////////////////////////
2437
// WAVE
2438

    
2439
///////////////////////////////////////////////////////////////////////////////////////////////////   
2440
}
(5-5/28)