Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ 437bc43e

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
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
10
 */
11
public abstract class DistortedObject 
12
{ 
13
    static final int TYPE_NUM = 3;
14
    private static final int TYPE_MASK= (1<<TYPE_NUM)-1;
15
    private static float[] mViewMatrix = new float[16];
16
   
17
    protected EffectListMatrix   mM;
18
    protected EffectListFragment mF;
19
    protected EffectListVertex   mV;
20

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
406
    return mM.add(EffectNames.MOVE,null,di);  
407
    }
408

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

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

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

    
457
    return mM.add(EffectNames.SCALE,null,di);  
458
    }
459

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

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

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

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

    
569
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z, di, 0.0f,0.0f,1.0f);  
570
    }
571

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

    
602
///////////////////////////////////////////////////////////////////////////////////////////////////
603
// QUATERNION
604
/**
605
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
606
 *   
607
 * @param point Coordinates of the Point we are rotating around.
608
 * @param qX    Quaternion: x-coordinate
609
 * @param qY    Quaternion: y-coordinate
610
 * @param qZ    Quaternion: z-coordinate
611
 * @param qW    Quaternion: w-coordinate
612
 * @return      ID of the effect added, or -1 if we failed to add one. 
613
 */
614
  public long quaternion(Float3D point, float qX, float qY, float qZ, float qW)
615
    {   
616
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,qX,qY,qZ,qW);   
617
    }
618

    
619
///////////////////////////////////////////////////////////////////////////////////////////////////
620
/**
621
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
622
 *   
623
 * @param point Coordinates of the Point we are rotating around.
624
 * @param iq    Interpolator that's going to, at any given moment, return a quaternion.
625
 * @return      ID of the effect added, or -1 if we failed to add one. 
626
 */
627
  public long quaternion(Float3D point, InterpolatorQuat iq)
628
    {   
629
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,iq);  
630
    }
631

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

    
661
///////////////////////////////////////////////////////////////////////////////////////////////////
662
/**
663
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
664
 * 
665
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
666
 * @param vector ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with 
667
 *               which the X,Y and Z axis get slanted) 
668
 * @return       ID of the effect added, or -1 if we failed to add one. 
669
 */
670
  public long shear(Float3D point, Float3D vector)
671
    {
672
    Interpolator3D di = new Interpolator3D(); 
673
    di.setCount(0.5f);
674
    di.setDuration(0);
675
    di.add(new Float3D(0.0f,0.0f,0.0f));              
676
    di.add(vector);                                                
677
        
678
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di );  
679
    }
680

    
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682
// Fragment-based effects  
683
///////////////////////////////////////////////////////////////////////////////////////////////////
684
// MACROBLOCK
685
/**
686
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
687
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
688
 * 
689
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
690
 * @param region Region this Effect is limited to.
691
 *               Null here means 'apply the effect to the whole Bitmap'.
692
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
693
 *               current center of the effect.
694
 * @return       ID of the effect added, or -1 if we failed to add one. 
695
 */
696
  public long macroblock(Interpolator1D a, Float4D region, Interpolator2D i)
697
    {
698
    return mF.add(EffectNames.MACROBLOCK, a, region, i);
699
    }
700

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

    
744
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
745
    }
746

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

    
773
    return mF.add(EffectNames.MACROBLOCK, di, region, point.x, point.y);
774
    }
775

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

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

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

    
842
///////////////////////////////////////////////////////////////////////////////////////////////////  
843
/**
844
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
845
 *        
846
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
847
 *               pixel = (1-t)*pixel + t*color
848
 * @param color  Color to mix.       
849
 * @param region Region this Effect is limited to.
850
 *               Null here means 'apply the Effect to the whole Bitmap'.
851
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
852
 *               current center of the effect.
853
 * @return       ID of the effect added, or -1 if we failed to add one. 
854
 */
855
  public long chroma(float t, Float3D color, Float4D region, Interpolator2D i)
856
    {
857
    return mF.add(EffectNames.CHROMA, t, color, region, i);
858
    }
859

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

    
879
///////////////////////////////////////////////////////////////////////////////////////////////////
880
/**
881
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
882
 * <p>
883
 * Here the Effect applies to the whole bitmap.
884
 *         
885
 * @param t     Level of blend a given pixel will be mixed with the next parameter 'color': 
886
 *              pixel = (1-t)*pixel + t*color
887
 * @param color Color to mix.       
888
 * @return      ID of the effect added, or -1 if we failed to add one. 
889
 */
890
  public long chroma(float t, Float3D color)
891
    {
892
    return mF.add(EffectNames.CHROMA, t, color, null, 0, 0);
893
    }
894

    
895
///////////////////////////////////////////////////////////////////////////////////////////////////  
896
/**
897
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
898
 * 
899
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
900
 */
901
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
902
    {
903
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
904
    }
905

    
906
///////////////////////////////////////////////////////////////////////////////////////////////////
907
/**
908
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
909
 * 
910
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
911
 */
912
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
913
    {
914
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
915
    }
916
  
917
///////////////////////////////////////////////////////////////////////////////////////////////////  
918
/**
919
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
920
 * 
921
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
922
 */
923
  public long smooth_chroma(float t, Float3D color, Float4D region, Interpolator2D i)
924
    {
925
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
926
    }
927

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

    
969
///////////////////////////////////////////////////////////////////////////////////////////////////
970
/**
971
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
972
 * <p>
973
 * Here the center of the Effect stays constant.
974
 *         
975
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
976
 *               moment.
977
 * @param region Region this Effect is limited to. 
978
 *               Null here means 'apply the Effect to the whole Bitmap'.
979
 * @param point  Center of the Effect.
980
 * @return       ID of the effect added, or -1 if we failed to add one. 
981
 */
982
  public long alpha(Interpolator1D a, Float4D region, Float2D point)
983
    {
984
    return mF.add(EffectNames.ALPHA, a, region, point.x, point.y);
985
    }
986

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

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

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

    
1079
///////////////////////////////////////////////////////////////////////////////////////////////////  
1080
/**
1081
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1082
 * 
1083
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1084
 */
1085
  public long smooth_alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1086
    {
1087
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, i);
1088
    }
1089

    
1090
///////////////////////////////////////////////////////////////////////////////////////////////////
1091
/**
1092
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1093
 * 
1094
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1095
 */
1096
  public long smooth_alpha(Interpolator1D a, Float4D region, Float2D point)
1097
    {
1098
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, point.x, point.y);
1099
    }
1100
  
1101
///////////////////////////////////////////////////////////////////////////////////////////////////  
1102
/**
1103
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1104
 * 
1105
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1106
 */
1107
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1108
    {
1109
    Interpolator1D di = new Interpolator1D(); 
1110
    di.setCount(count);
1111
    di.setDuration(duration);
1112
    di.add(new Float1D(1));                          
1113
    di.add(new Float1D(alpha));                         
1114
   
1115
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, i);
1116
    }
1117

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

    
1171
///////////////////////////////////////////////////////////////////////////////////////////////////
1172
/**
1173
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1174
 * <p>
1175
 * Here the center of the Effect stays constant.
1176
 *         
1177
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1178
 *               moment.
1179
 * @param region Region this Effect is limited to.
1180
 *               Null here means 'apply the Effect to the whole Bitmap'.
1181
 * @param point  Center of the Effect.
1182
 * @return       ID of the effect added, or -1 if we failed to add one. 
1183
 */
1184
  public long brightness(Interpolator1D a, Float4D region, Float2D point)
1185
    {
1186
    return mF.add(EffectNames.BRIGHTNESS, a, region, point.x, point.y);
1187
    }
1188

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

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

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

    
1286
///////////////////////////////////////////////////////////////////////////////////////////////////
1287
/**
1288
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1289
 * <p>
1290
 * Here the center of the Effect stays constant.
1291
 *         
1292
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1293
 *               any given moment.
1294
 * @param region Region this Effect is limited to. 
1295
 *               Null here means 'apply the Effect to the whole Bitmap'.
1296
 * @param point  Center of the Effect.
1297
 * @return       ID of the effect added, or -1 if we failed to add one. 
1298
 */
1299
  public long smooth_brightness(Interpolator1D a, Float4D region, Float2D point)
1300
    {
1301
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, point.x, point.y);
1302
    }
1303

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

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

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

    
1404
///////////////////////////////////////////////////////////////////////////////////////////////////
1405
///////////////////////////////////////////////////////////////////////////////////////////////////
1406
// CONTRAST
1407
/**
1408
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1409
 *        
1410
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1411
 *               at any given moment.
1412
 * @param region Region this Effect is limited to. 
1413
 *               Null here means 'apply the Effect to the whole Bitmap'.
1414
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1415
 *               representing the current center of the effect.
1416
 * @return       ID of the effect added, or -1 if we failed to add one. 
1417
 */
1418
  public long contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1419
    {
1420
    return mF.add(EffectNames.CONTRAST, a, region, i);
1421
    }
1422

    
1423
///////////////////////////////////////////////////////////////////////////////////////////////////
1424
/**
1425
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1426
 * <p>
1427
 * Here the center of the Effect stays constant.
1428
 *         
1429
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1430
 *               at any given moment.
1431
 * @param region Region this Effect is limited to.
1432
 *               Null here means 'apply the Effect to the whole Bitmap'.
1433
 * @param point  Center of the Effect.
1434
 * @return       ID of the effect added, or -1 if we failed to add one. 
1435
 */
1436
  public long contrast(Interpolator1D a, Float4D region, Float2D point)
1437
    {
1438
    return mF.add(EffectNames.CONTRAST, a, region, point.x, point.y);
1439
    }
1440

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

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

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

    
1538
///////////////////////////////////////////////////////////////////////////////////////////////////
1539
/**
1540
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1541
 * <p>
1542
 * Here the center of the Effect stays constant.
1543
 *         
1544
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1545
 *               at any given moment.
1546
 * @param region Region this Effect is limited to. 
1547
 *               Null here means 'apply the Effect to the whole Bitmap'.
1548
 * @param point  Center of the Effect.
1549
 * @return       ID of the effect added, or -1 if we failed to add one. 
1550
 */
1551
  public long smooth_contrast(Interpolator1D a, Float4D region, Float2D point)
1552
    {
1553
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, point.x, point.y);
1554
    }
1555

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

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

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

    
1656

    
1657
///////////////////////////////////////////////////////////////////////////////////////////////////
1658
///////////////////////////////////////////////////////////////////////////////////////////////////
1659
// SATURATION
1660
/**
1661
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1662
 *        
1663
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1664
 *               at any given moment.
1665
 * @param region Region this Effect is limited to. 
1666
 *               Null here means 'apply the Effect to the whole Bitmap'.
1667
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1668
 *               representing the current center of the effect.
1669
 * @return       ID of the effect added, or -1 if we failed to add one. 
1670
 */
1671
  public long saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1672
    {
1673
    return mF.add(EffectNames.SATURATION, a, region, i);
1674
    }
1675

    
1676
///////////////////////////////////////////////////////////////////////////////////////////////////
1677
/**
1678
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1679
 * <p>
1680
 * Here the center of the Effect stays constant.
1681
 *         
1682
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1683
 *               at any given moment.
1684
 * @param region Region this Effect is limited to. 
1685
 *               Null here means 'apply the Effect to the whole Bitmap'.
1686
 * @param point  Center of the Effect.
1687
 * @return       ID of the effect added, or -1 if we failed to add one. 
1688
 */
1689
  public long saturation(Interpolator1D a, Float4D region, Float2D point)
1690
    {
1691
    return mF.add(EffectNames.SATURATION, a, region, point.x, point.y);
1692
    }
1693

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

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

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

    
1791
///////////////////////////////////////////////////////////////////////////////////////////////////
1792
/**
1793
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1794
 * <p>
1795
 * Here the center of the Effect stays constant.
1796
 *         
1797
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1798
 *               at any given moment.
1799
 * @param region Region this Effect is limited to. 
1800
 *               Null here means 'apply the Effect to the whole Bitmap'.
1801
 * @param point  Center of the Effect.
1802
 * @return       ID of the effect added, or -1 if we failed to add one. 
1803
 */
1804
  public long smooth_saturation(Interpolator1D a, Float4D region, Float2D point)
1805
    {
1806
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, point.x, point.y);
1807
    }
1808

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

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

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

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

    
1945
///////////////////////////////////////////////////////////////////////////////////////////////////
1946
/**
1947
 * Distort the whole Bitmap by a (possibly changing in time) vector of force.
1948
 * 
1949
 * @param i     2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
1950
 *              represents the vector the Center of the Effect is currently being dragged with.
1951
 * @param point Center of the Effect.
1952
 * @return      ID of the effect added, or -1 if we failed to add one. 
1953
 */
1954
  public long distort(Interpolator i, Float2D point)
1955
    {
1956
    return mV.add(EffectNames.DISTORT, i, null, point.x, point.y);  
1957
    }
1958

    
1959
///////////////////////////////////////////////////////////////////////////////////////////////////
1960
/**
1961
 * Distort part of the Bitmap by a vector of force that changes from (0,0,0) to v.
1962
 * 
1963
 * @param vector   Maximum vector of force. 
1964
 * @param region   Region that masks the effect of the Distortion.
1965
 * @param point    Center of the Effect.
1966
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1967
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1968
 * @return         ID of the effect added, or -1 if we failed to add one. 
1969
 */
1970
  public long distort(Float3D vector, Float4D region, Float2D point, int duration, float count)
1971
    {  
1972
    Interpolator3D di = new Interpolator3D(); 
1973
    di.setCount(count);
1974
    di.setDuration(duration);
1975
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1976
    di.add(vector);                                                  
1977
           
1978
    return mV.add(EffectNames.DISTORT, di, region, point.x, point.y);  
1979
    }
1980

    
1981
///////////////////////////////////////////////////////////////////////////////////////////////////
1982
/**
1983
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
1984
 * 
1985
 * @param vector   Maximum vector of force.
1986
 * @param point    Center of the Effect.
1987
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1988
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1989
 * @return         ID of the effect added, or -1 if we failed to add one. 
1990
 */
1991
  public long distort(Float3D vector, Float2D point, int duration, float count)
1992
    {
1993
    Interpolator3D di = new Interpolator3D(); 
1994
    di.setCount(count);
1995
    di.setDuration(duration);
1996
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1997
    di.add(vector);                                                 
1998
           
1999
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2000
    }
2001

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

    
2025
///////////////////////////////////////////////////////////////////////////////////////////////////
2026
/**
2027
 * Distort the whole Bitmap by a vector of force v.
2028
 * <p>
2029
 * Here we apply a constant vector of force.
2030
 * 
2031
 * @param vector Vector of force.
2032
 * @param point  Center of the Effect.
2033
 * @return       ID of the effect added, or -1 if we failed to add one. 
2034
 */
2035
  public long distort(Float3D vector, Float2D point )
2036
    {
2037
    Interpolator3D di = new Interpolator3D(); 
2038
    di.setCount(0.5f);
2039
    di.setDuration(0);
2040
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2041
    di.add(vector);           
2042
           
2043
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2044
    }
2045

    
2046
///////////////////////////////////////////////////////////////////////////////////////////////////
2047
///////////////////////////////////////////////////////////////////////////////////////////////////
2048
// DEFORM
2049
/**
2050
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2051
 * a (possibly changing in time) point on the Bitmap.
2052
 *     
2053
 * @param i     Interpolator that, at any given time, returns a Point2D representing vector of 
2054
 *              force that deforms the shapre of the whole Bitmap.
2055
 * @param point 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2056
 *              the Center of the Effect.
2057
 * @return      ID of the effect added, or -1 if we failed to add one. 
2058
 */
2059
  public long deform(Interpolator i, Interpolator2D point)
2060
    {  
2061
    return mV.add(EffectNames.DEFORM, i, null, point);  
2062
    }
2063

    
2064
///////////////////////////////////////////////////////////////////////////////////////////////////
2065
/**
2066
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2067
 * a constant point on the Bitmap.
2068
 * 
2069
 * @param i     Interpolator that, at any given time, returns a Point2D representing 
2070
 *              vector of force that deforms the shapre of the whole Bitmap.
2071
 * @param point Center of the Effect.
2072
 * @return      ID of the effect added, or -1 if we failed to add one. 
2073
 */
2074
  public long deform(Interpolator i, Float2D point)
2075
    {
2076
    return mV.add(EffectNames.DEFORM, i, null, point.x, point.y);  
2077
    }
2078

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

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

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

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

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

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

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

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

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

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

    
2381
///////////////////////////////////////////////////////////////////////////////////////////////////
2382
/**
2383
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2384
 * 
2385
 * @param degree   Angle of rotation. Unit: degrees.
2386
 * @param point    Center of the Effect.
2387
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2388
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2389
 * @return         ID of the effect added, or -1 if we failed to add one. 
2390
 */
2391
  public long swirl(int degree, Float2D point, int duration, float count) 
2392
    {
2393
    Interpolator1D di = new Interpolator1D();  
2394
    di.setCount(count);
2395
    di.setDuration(duration);
2396
    di.add(new Float1D(0));                                
2397
    di.add(new Float1D(degree));                          
2398
         
2399
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2400
    }
2401

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

    
2424
///////////////////////////////////////////////////////////////////////////////////////////////////
2425
/**
2426
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2427
 * <p>
2428
 * Equivalent to calling the previous method with duration=0.
2429
 * 
2430
 * @param degree Angle of rotation. Unit: degrees.
2431
 * @param point  Center of the Effect.
2432
 * @return       ID of the effect added, or -1 if we failed to add one. 
2433
 */
2434
  public long swirl(int degree, Float2D point) 
2435
    {
2436
    Interpolator1D di = new Interpolator1D(); 
2437
    di.setCount(0.5f);
2438
    di.setDuration(0);
2439
    di.add(new Float1D(0));                               
2440
    di.add(new Float1D(degree));                      
2441
        
2442
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2443
    }
2444

    
2445
///////////////////////////////////////////////////////////////////////////////////////////////////
2446
///////////////////////////////////////////////////////////////////////////////////////////////////
2447
// WAVE
2448

    
2449
///////////////////////////////////////////////////////////////////////////////////////////////////   
2450
}
(5-5/28)