Project

General

Profile

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

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

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 = 4;
14
    private static final int TYPE_MASK= (1<<TYPE_NUM)-1;
15
    private static float[] mViewMatrix = new float[16];
16
   
17
    protected EffectListPreShader  mM;
18
    protected EffectListFragment   mF;
19
    protected EffectListVertex     mV;
20
    protected EffectListPostShader mP;
21

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

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

    
32
///////////////////////////////////////////////////////////////////////////////////////////////////
33

    
34
    protected abstract DistortedObject deepCopy(int flags);
35

    
36
///////////////////////////////////////////////////////////////////////////////////////////////////
37

    
38
    protected void initializeData(int size)
39
      {
40
      mID             = DistortedObjectList.add(this);
41
      mSize           = size;
42
      mTextureDataH   = new int[1];
43
      mTextureDataH[0]= 0;
44
      mBmp            = new Bitmap[1];
45
      mBmp[0]         = null;
46
      mBitmapSet      = new boolean[1];
47
      mBitmapSet[0]   = false;
48
      
49
      initializeEffectLists(this,0);
50
      
51
      if( Distorted.isInitialized() ) resetTexture();    
52
      }
53
    
54
///////////////////////////////////////////////////////////////////////////////////////////////////
55
    
56
    protected void initializeEffectLists(DistortedObject d, int flags)
57
      {
58
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
59
        {
60
        mM = d.mM;
61
        matrixCloned = true;
62
        } 
63
      else
64
        {
65
        mM = new EffectListPreShader(d);
66
        matrixCloned = false;  
67
        }
68
    
69
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
70
        {
71
        mV = d.mV;
72
        vertexCloned = true;
73
        } 
74
      else
75
        {
76
        mV = new EffectListVertex(d);
77
        vertexCloned = false;  
78
        }
79
    
80
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
81
        {
82
        mF = d.mF;
83
        fragmentCloned = true;
84
        } 
85
      else
86
        {
87
        mF = new EffectListFragment(d);
88
        fragmentCloned = false;   
89
        }
90

    
91
      mP = new EffectListPostShader(d); // PostShader effects are never cloned.
92
      }
93
    
94
///////////////////////////////////////////////////////////////////////////////////////////////////
95
// this will be called on startup and every time OpenGL context has been lost
96
// also call this from the constructor if the OpenGL context has been created already.
97
    
98
    void resetTexture()
99
      {
100
      if( mTextureDataH!=null ) 
101
        {
102
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
103

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

    
137
      mP.send();
138
      }
139

    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
   
142
    void drawNoEffectsPriv(DistortedProjection dp)
143
      {
144
      GLES20.glViewport(0, 0, dp.width, dp.height);
145
      mM.sendNoEffects(dp);
146
      mV.sendZero();
147
      mF.sendZero();
148
      mGrid.draw();
149
      }
150
    
151
///////////////////////////////////////////////////////////////////////////////////////////////////
152
   
153
    void releasePriv()
154
      {
155
      if( matrixCloned  ==false) mM.abortAll();
156
      if( vertexCloned  ==false) mV.abortAll();
157
      if( fragmentCloned==false) mF.abortAll();
158

    
159
      mP.abortAll();
160

    
161
      mBmp          = null;
162
      mGrid         = null;
163
      mM            = null;
164
      mV            = null;
165
      mF            = null;
166
      mP            = null;
167
      mTextureDataH = null;
168
      }
169
 
170
///////////////////////////////////////////////////////////////////////////////////////////////////
171

    
172
    long getBitmapID()
173
      {
174
      return mBmp==null ? 0 : mBmp.hashCode();
175
      }
176

    
177
///////////////////////////////////////////////////////////////////////////////////////////////////
178

    
179
  /**
180
   * Default empty constructor so that derived classes can call it
181
   */
182
    public DistortedObject()
183
      {
184

    
185
      }
186

    
187
///////////////////////////////////////////////////////////////////////////////////////////////////
188
  /**
189
   * Copy constructor used to create a DistortedObject based on various parts of another object.
190
   * <p>
191
   * Whatever we do not clone gets created just like in the default constructor.
192
   *
193
   * @param dc    Source object to create our object from
194
   * @param flags A bitmask of values specifying what to copy.
195
   *              For example, CLONE_BITMAP | CLONE_PRESHADER.
196
   */
197
    public DistortedObject(DistortedObject dc, int flags)
198
      {
199
      initializeEffectLists(dc,flags);
200

    
201
      mID = DistortedObjectList.add(this);
202

    
203
      mSizeX = dc.mSizeX;
204
      mSizeY = dc.mSizeY;
205
      mSizeZ = dc.mSizeZ;
206
      mSize  = dc.mSize;
207
      mGrid  = dc.mGrid;
208

    
209
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
210
        {
211
        mTextureDataH = dc.mTextureDataH;
212
        mBmp          = dc.mBmp;
213
        mBitmapSet    = dc.mBitmapSet;
214
        }
215
      else
216
        {
217
        mTextureDataH   = new int[1];
218
        mTextureDataH[0]= 0;
219
        mBitmapSet      = new boolean[1];
220
        mBitmapSet[0]   = false;
221
        mBmp            = new Bitmap[1];
222
        mBmp[0]         = null;
223

    
224
        if( Distorted.isInitialized() ) resetTexture();
225
        }
226
      }
227

    
228
///////////////////////////////////////////////////////////////////////////////////////////////////
229
/**
230
 * Draw the DistortedObject to the location specified by current Matrix effects.    
231
 *     
232
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
233
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
234
 *        Object.
235
 */
236
   public void draw(long currTime)
237
     {
238
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
239
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
240
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
241
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
242
      
243
     drawPriv(currTime, Distorted.mProjection);
244
     }
245
 
246
///////////////////////////////////////////////////////////////////////////////////////////////////
247
/**
248
 * Releases all resources.
249
 */
250
   public synchronized void release()
251
     {
252
     releasePriv();  
253
     DistortedObjectList.remove(this);
254
     }
255

    
256
///////////////////////////////////////////////////////////////////////////////////////////////////
257
/**
258
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
259
 * <p>
260
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
261
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
262
 * 
263
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
264
 */
265
   
266
   public void setBitmap(Bitmap bmp)
267
     {
268
     mBitmapSet[0] = true; 
269
      
270
     if( Distorted.isInitialized() )
271
       {
272
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
273
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
274
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
275
       }
276
     else
277
       {
278
       mBmp[0] = bmp;  
279
       }
280
     }
281
    
282
///////////////////////////////////////////////////////////////////////////////////////////////////
283
/**
284
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
285
 * to one of the Effects that are currently applied to the DistortedBitmap.
286
 * 
287
 * @param el A class implementing the EffectListener interface that wants to get notifications.
288
 */
289
   public void addEventListener(EffectListener el)
290
     {
291
     mV.addListener(el);
292
     mF.addListener(el);
293
     mM.addListener(el);
294
     mP.addListener(el);
295
     }
296

    
297
///////////////////////////////////////////////////////////////////////////////////////////////////
298
/**
299
 * Removes the calling class from the list of Listeners.
300
 * 
301
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
302
 */
303
   public void removeEventListener(EffectListener el)
304
     {
305
     mV.removeListener(el);
306
     mF.removeListener(el);
307
     mM.removeListener(el);
308
     mP.removeListener(el);
309
     }
310
   
311
///////////////////////////////////////////////////////////////////////////////////////////////////
312
/**
313
 * Returns the height of the DistortedObject.
314
 *    
315
 * @return height of the object, in pixels.
316
 */
317
   public int getWidth()
318
     {
319
     return mSizeX;   
320
     }
321

    
322
///////////////////////////////////////////////////////////////////////////////////////////////////
323
/**
324
 * Returns the width of the DistortedObject.
325
 * 
326
 * @return width of the Object, in pixels.
327
 */
328
    public int getHeight()
329
      {
330
      return mSizeY;  
331
      }
332
    
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
/**
335
 * Returns the depth of the DistortedObject.
336
 * 
337
 * @return depth of the Object, in pixels.
338
 */
339
    public int getDepth()
340
      {
341
      return mSizeZ;  
342
      }
343
        
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345
/**
346
 * Returns unique ID of this instance.
347
 * 
348
 * @return ID of the object.
349
 */
350
    public long getID()
351
      {
352
      return mID;  
353
      }
354
    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
/**
357
 * Aborts all Effects. 
358
 */
359
    public void abortAllEffects()
360
      {
361
      mM.abortAll();
362
      mV.abortAll();
363
      mF.abortAll();
364
      mP.abortAll();
365
      }
366

    
367
///////////////////////////////////////////////////////////////////////////////////////////////////
368
/**
369
 * Aborts a subset of Effects.
370
 * 
371
 * @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_PRE | TYPE_VERT | TYPE_FRAG.
372
 */
373
    public void abortAllEffects(int mask)
374
      {
375
      if( (mask & Distorted.TYPE_PRE ) != 0 ) mM.abortAll();
376
      if( (mask & Distorted.TYPE_VERT) != 0 ) mV.abortAll();
377
      if( (mask & Distorted.TYPE_FRAG) != 0 ) mF.abortAll();
378
      if( (mask & Distorted.TYPE_POST) != 0 ) mP.abortAll();
379
      }
380
    
381
///////////////////////////////////////////////////////////////////////////////////////////////////
382
/**
383
 * Aborts a single Effect.
384
 * 
385
 * @param id ID of the Effect we want to abort.
386
 * @return <code>true</code> if the Effect was found and successfully aborted.
387
 */
388
    public boolean abortEffect(long id)
389
      {
390
      switch( (int)(id&TYPE_MASK) )
391
        {
392
        case Distorted.TYPE_PRE : return mM.removeByID(id>>TYPE_NUM);
393
        case Distorted.TYPE_VERT: return mV.removeByID(id>>TYPE_NUM);
394
        case Distorted.TYPE_FRAG: return mF.removeByID(id>>TYPE_NUM);
395
        case Distorted.TYPE_POST: return mP.removeByID(id>>TYPE_NUM);
396
        default                 : return false;
397
        }
398
      }
399

    
400
///////////////////////////////////////////////////////////////////////////////////////////////////
401
/**
402
 * Abort all Effects of a given type, for example all rotations.
403
 * 
404
 * @param effectType one of the constants defined in {@link EffectNames}
405
 * @return <code>true</code> if a single Effect of type effectType has been found and aborted. 
406
 */
407
    public boolean abortEffectType(EffectNames effectType)
408
      {
409
      switch(effectType.getType())
410
        {
411
        case Distorted.TYPE_PRE : return mM.removeByType(effectType);
412
        case Distorted.TYPE_VERT: return mV.removeByType(effectType);
413
        case Distorted.TYPE_FRAG: return mF.removeByType(effectType);
414
        case Distorted.TYPE_POST: return mP.removeByType(effectType);
415
        default                 : return false;
416
        }
417
      }
418
    
419
///////////////////////////////////////////////////////////////////////////////////////////////////
420
/**
421
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
422
 * 
423
 * @param id Effect ID we want to print info about
424
 * @return <code>true</code> if a single Effect of type effectType has been found.
425
 */
426
    
427
    public boolean printEffect(long id)
428
      {
429
      switch( (int)(id&TYPE_MASK) )
430
        {
431
        case Distorted.TYPE_PRE : return mM.printByID(id>>TYPE_NUM);
432
        case Distorted.TYPE_VERT: return mV.printByID(id>>TYPE_NUM);
433
        case Distorted.TYPE_FRAG: return mF.printByID(id>>TYPE_NUM);
434
        case Distorted.TYPE_POST: return mP.printByID(id>>TYPE_NUM);
435
        default                 : return false;
436
        }
437
      }
438
   
439
///////////////////////////////////////////////////////////////////////////////////////////////////   
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441
// Individual effect functions.
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
// Matrix-based effects
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445
// MOVE
446
/**
447
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
448
 * 
449
 * @param di 3-dimensional Interpolator which at any given time will return a Float3D
450
 *           representing the current coordinates of the vector we want to move the Object with.
451
 * @return   ID of the effect added, or -1 if we failed to add one. 
452
 */
453
  public long move(Interpolator3D di)
454
    {   
455
    return mM.add(EffectNames.MOVE,null,di);  
456
    }
457

    
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459
/**
460
 * Moves the Bitmap by a vector that smoothly changes from (0,0,0) to (x,y,z).
461
 *  
462
 * @param x        The x-coordinate of the vector we want to move the Object with. 
463
 * @param y        The y-coordinate of the vector we want to move the Object with.
464
 * @param z        The z-coordinate of the vector we want to move the Object with.
465
 * @param duration The time, in milliseconds, it takes to complete the movement.
466
 * @return         ID of the effect added, or -1 if we failed to add one. 
467
 */
468
  public long move(float x,float y,float z, int duration)
469
    {   
470
    Interpolator3D di = new Interpolator3D();  
471
    di.setCount(0.5f);
472
    di.setDuration(duration);
473
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
474
    di.add(new Float3D(x,y,z));                        
475

    
476
    return mM.add(EffectNames.MOVE,null,di);  
477
    }
478

    
479
///////////////////////////////////////////////////////////////////////////////////////////////////
480
/**
481
 * Moves the Bitmap by vector (x,y,z) immediately.
482
 *   
483
 * @param x The x-coordinate of the vector we want to move the Object with. 
484
 * @param y The y-coordinate of the vector we want to move the Object with.
485
 * @param z The z-coordinate of the vector we want to move the Object with.
486
 * @return  ID of the effect added, or -1 if we failed to add one. 
487
 */
488
  public long move(float x,float y,float z)
489
    {   
490
    return mM.add(EffectNames.MOVE,0.0f,0.0f,0.0f,x,y,z,0.0f);  
491
    }
492

    
493
///////////////////////////////////////////////////////////////////////////////////////////////////
494
// SCALE
495
/**
496
 * Scales the Object by factors that change in time as returned by the Interpolator.
497
 * 
498
 * @param di 3-dimensional Interpolator which at any given time returns a Float3D
499
 *           representing the current x- , y- and z- scale factors.
500
 * @return   ID of the effect added, or -1 if we failed to add one. 
501
 */
502
  public long scale(Interpolator3D di)
503
    {   
504
    return mM.add(EffectNames.SCALE,null,di);  
505
    }
506

    
507
///////////////////////////////////////////////////////////////////////////////////////////////////
508
/**
509
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
510
 * after 'duration' milliseconds. 
511
 *    
512
 * @param xscale   After time 'duration' passes, Bitmap's width will get multiplied by xscale; e.g. if 
513
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
514
 * @param yscale   Factor to scale Object's height with.
515
 * @param zscale   Factor to scale Object's depth with.
516
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
517
 * @return         ID of the effect added, or -1 if we failed to add one. 
518
 */
519
  public long scale(float xscale,float yscale,float zscale, int duration)
520
    {   
521
    Interpolator3D di = new Interpolator3D();  
522
    di.setCount(0.5f);
523
    di.setDuration(duration);
524
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
525
    di.add(new Float3D(xscale,yscale,zscale));                        
526

    
527
    return mM.add(EffectNames.SCALE,null,di);  
528
    }
529

    
530
///////////////////////////////////////////////////////////////////////////////////////////////////
531
/**
532
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
533
 *   
534
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
535
 *               xscale=2, the Object immediately becomes twice broader.
536
 * @param yscale factor to scale Object's height with.
537
 * @param zscale factor to scale Object's depth with. 
538
 * @return       ID of the effect added, or -1 if we failed to add one. 
539
 */
540
  public long scale(float xscale,float yscale,float zscale)
541
    {   
542
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,xscale,yscale,zscale,0.0f);  
543
    }
544

    
545
///////////////////////////////////////////////////////////////////////////////////////////////////
546
/**
547
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
548
 *   
549
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
550
 *              scale=2, the Object immediately becomes twice larger.
551
 * @return      ID of the effect added, or -1 if we failed to add one. 
552
 */
553
  public long scale(float scale)
554
    {   
555
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,scale,scale,scale,0.0f);  
556
    }
557
    
558
///////////////////////////////////////////////////////////////////////////////////////////////////
559
// ROTATE
560
/**
561
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
562
 * 
563
 * @param i 3-dimensional Interpolator which at any given time will return the current center of 
564
 *          the rotation
565
 * @param v 4-dimensional Interpolator which at any given time will return a Float4D
566
 *          representing the current rotation in the (angle,axisX,axisY,axisY) form. 
567
 * @return  ID of the effect added, or -1 if we failed to add one. 
568
 */
569
  public long rotate(Interpolator3D i, Interpolator4D v)
570
    {   
571
    return mM.add(EffectNames.ROTATE, i, v);  
572
    }
573

    
574
///////////////////////////////////////////////////////////////////////////////////////////////////  
575
/**
576
 * Rotates the Object around a static point, with angle and axis that change in time.
577
 * 
578
 * @param point Center of the rotation
579
 * @param v     4-dimensional Interpolator which at any given time will return a Float4D
580
 *              representing the current rotation in the (angle,axisX,axisY,axisY) form. 
581
 * @return      ID of the effect added, or -1 if we failed to add one. 
582
 */
583
  public long rotate(Float3D point, Interpolator4D v)
584
    {   
585
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v);  
586
    }
587
  
588
///////////////////////////////////////////////////////////////////////////////////////////////////  
589
/**
590
 * Rotates the Object around a static point, with angle that changes in time, around axis 
591
 * (axisX, axisY, axisZ). 
592
 * 
593
 * @param point Center of the rotation
594
 * @param v     1-dimensional Interpolator which at any given time will return the current rotation 
595
 *              angle.
596
 * @param axisX Rotation vector: x-coordinate
597
 * @param axisY Rotation vector: y-coordinate         
598
 * @param axisZ Rotation vector: z-coordinate         
599
 * @return      ID of the effect added, or -1 if we failed to add one. 
600
 */
601
  public long rotate(Float3D point, Interpolator1D v, float axisX, float axisY, float axisZ)
602
    {   
603
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v, axisX, axisY, axisZ);  
604
    }
605
  
606
///////////////////////////////////////////////////////////////////////////////////////////////////
607
/**
608
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
609
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
610
 * 
611
 * @param i 3-dimensional Interpolator which at any given time will return the current center
612
 *          of the rotation.
613
 * @param a 1-dimensional Interpolator which returns the current rotation angle.         
614
 * @return  ID of the effect added, or -1 if we failed to add one. 
615
 */
616
  public long rotate(Interpolator3D i, Interpolator1D a)
617
    {   
618
    return mM.add(EffectNames.ROTATE, i, a, 0.0f,0.0f,1.0f);  
619
    }
620

    
621
///////////////////////////////////////////////////////////////////////////////////////////////////
622
/**
623
 * Rotates the Object around a constant point, with angle that changes in time.  
624
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
625
 *   
626
 * @param point    Coordinates of the Point we are rotating around.
627
 * @param angle    Angle that we want to rotate the Bitmap to. Unit: degrees
628
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
629
 * @return         ID of the effect added, or -1 if we failed to add one. 
630
 */
631
  public long rotate(Float3D point, int angle, int duration)
632
    {   
633
    Interpolator1D di = new Interpolator1D();  
634
    di.setCount(0.5f);
635
    di.setDuration(duration);
636
    di.add(new Float1D(    0));                             
637
    di.add(new Float1D(angle));                        
638

    
639
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z, di, 0.0f,0.0f,1.0f);  
640
    }
641

    
642
///////////////////////////////////////////////////////////////////////////////////////////////////
643
/**
644
 * Rotates the Object immediately by 'angle' degrees around point p.   
645
 * Axis of rotation is given by the last 3 floats.
646
 *   
647
 * @param point Coordinates of the Point we are rotating around.
648
 * @param angle Angle that we want to rotate the Bitmap to. Unit: degrees
649
 * @param axisX Axis of rotation: x-coordinate
650
 * @param axisY Axis of rotation: y-coordinate
651
 * @param axisZ Axis of rotation: z-coordinate
652
 * @return      ID of the effect added, or -1 if we failed to add one. 
653
 */
654
  public long rotate(Float3D point, float angle, float axisX, float axisY, float axisZ)
655
    {   
656
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z, angle, axisX, axisY, axisZ);  
657
    }
658
  
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660
/**
661
 * Rotates the Object immediately by 'angle' degrees around point p.   
662
 *   
663
 * @param point  Coordinates of the Point we are rotating around.
664
 * @param angle  The angle that we want to rotate the Bitmap to. Unit: degrees
665
 * @return       ID of the effect added, or -1 if we failed to add one. 
666
 */
667
  public long rotate(Float3D point, int angle)
668
    {   
669
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z,angle,0.0f,0.0f,1.0f);  
670
    }
671

    
672
///////////////////////////////////////////////////////////////////////////////////////////////////
673
// QUATERNION
674
/**
675
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
676
 *   
677
 * @param point Coordinates of the Point we are rotating around.
678
 * @param qX    Quaternion: x-coordinate
679
 * @param qY    Quaternion: y-coordinate
680
 * @param qZ    Quaternion: z-coordinate
681
 * @param qW    Quaternion: w-coordinate
682
 * @return      ID of the effect added, or -1 if we failed to add one. 
683
 */
684
  public long quaternion(Float3D point, float qX, float qY, float qZ, float qW)
685
    {   
686
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,qX,qY,qZ,qW);   
687
    }
688

    
689
///////////////////////////////////////////////////////////////////////////////////////////////////
690
/**
691
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
692
 *   
693
 * @param point Coordinates of the Point we are rotating around.
694
 * @param iq    Interpolator that's going to, at any given moment, return a quaternion.
695
 * @return      ID of the effect added, or -1 if we failed to add one. 
696
 */
697
  public long quaternion(Float3D point, InterpolatorQuat iq)
698
    {   
699
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,iq);  
700
    }
701

    
702
///////////////////////////////////////////////////////////////////////////////////////////////////
703
/**
704
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
705
 *   
706
 * @param i  Interpolator that returns the current center of rotation.
707
 * @param iq Interpolator that's going to, at any given moment, return a quaternion representing the current rotation.
708
 * @return   ID of the effect added, or -1 if we failed to add one. 
709
 */
710
  public long quaternion(Interpolator3D i, InterpolatorQuat iq)
711
    {   
712
    return mM.add(EffectNames.QUATERNION,i,iq);  
713
    }
714
  
715
///////////////////////////////////////////////////////////////////////////////////////////////////
716
// SHEAR
717
/**
718
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
719
 * shearing along the Y-axis, 3D one along Z axis.
720
 *
721
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
722
 * @param di     1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2- 
723
 *               or 3-tuple of shear factors.
724
 * @return       ID of the effect added, or -1 if we failed to add one. 
725
 */
726
  public long shear(Float3D point, Interpolator di)
727
    {
728
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di);  
729
    }
730

    
731
///////////////////////////////////////////////////////////////////////////////////////////////////
732
/**
733
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
734
 * 
735
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
736
 * @param vector ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with 
737
 *               which the X,Y and Z axis get slanted) 
738
 * @return       ID of the effect added, or -1 if we failed to add one. 
739
 */
740
  public long shear(Float3D point, Float3D vector)
741
    {
742
    Interpolator3D di = new Interpolator3D(); 
743
    di.setCount(0.5f);
744
    di.setDuration(0);
745
    di.add(new Float3D(0.0f,0.0f,0.0f));              
746
    di.add(vector);                                                
747
        
748
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di );  
749
    }
750

    
751
///////////////////////////////////////////////////////////////////////////////////////////////////
752
// Fragment-based effects  
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754
// MACROBLOCK
755
/**
756
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
757
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
758
 * 
759
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
760
 * @param region Region this Effect is limited to.
761
 *               Null here means 'apply the effect to the whole Bitmap'.
762
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
763
 *               current center of the effect.
764
 * @return       ID of the effect added, or -1 if we failed to add one. 
765
 */
766
  public long macroblock(Interpolator1D a, Float4D region, Interpolator2D i)
767
    {
768
    return mF.add(EffectNames.MACROBLOCK, a, region, i);
769
    }
770

    
771
///////////////////////////////////////////////////////////////////////////////////////////////////
772
/**
773
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
774
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
775
 * <p>
776
 * The difference between this and the previous method is that here the center of the Effect stays constant.
777
 *    
778
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
779
 * @param region Region this Effect is limited to. 
780
 *               Null here means 'apply the effect to the whole Bitmap'.
781
 * @param point  Center of the Effect.
782
 * @return       ID of the effect added, or -1 if we failed to add one. 
783
 */
784
  public long macroblock(Interpolator1D a, Float4D region, Float2D point)
785
    {
786
    return mF.add(EffectNames.MACROBLOCK, a, region, point.x, point.y);
787
    }
788
  
789
///////////////////////////////////////////////////////////////////////////////////////////////////
790
/**
791
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
792
 * <p>
793
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
794
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
795
 * size is 1X1, i.e. 1 pixel).   
796
 * 
797
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
798
 * @param region   Region this Effect is limited to. 
799
 *                 Null here means 'apply the effect to the whole Bitmap'.
800
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D representing the
801
 *                 current center of the effect.
802
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
803
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
804
 * @return         ID of the effect added, or -1 if we failed to add one. 
805
 */
806
  public long macroblock(int pixels, Float4D region, Interpolator2D i, int duration, float count)
807
    {
808
    Interpolator1D di = new Interpolator1D();
809
    di.setCount(count);
810
    di.setDuration(duration);
811
    di.add(new Float1D(1));                             
812
    di.add(new Float1D(pixels));                        
813

    
814
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
815
    }
816

    
817
///////////////////////////////////////////////////////////////////////////////////////////////////
818
/**
819
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
820
 * <p>
821
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
822
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
823
 * size is 1X1, i.e. 1 pixel).   
824
 * <p>
825
 * The difference between this and the previous method is that here the center of the Effect stays constant.
826
 *    
827
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
828
 * @param region   Region this Effect is limited to. 
829
 *                 Null here means 'apply the effect to the whole Bitmap'.
830
 * @param point    Center of the Effect.
831
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
832
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
833
 * @return         ID of the effect added, or -1 if we failed to add one. 
834
 */
835
  public long macroblock(int pixels, Float4D region, Float2D point, int duration, float count)
836
    {
837
    Interpolator1D di = new Interpolator1D();
838
    di.setCount(count);
839
    di.setDuration(duration);
840
    di.add(new Float1D(1));                             
841
    di.add(new Float1D(pixels));                        
842

    
843
    return mF.add(EffectNames.MACROBLOCK, di, region, point.x, point.y);
844
    }
845

    
846
///////////////////////////////////////////////////////////////////////////////////////////////////
847
/**
848
 * Creates macroblocks on the whole Bitmap. 
849
 * <p>
850
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
851
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
852
 * size is 1X1, i.e. 1 pixel).   
853
 * <p>
854
 * The difference between this and the previous method is that here there is no masking Region; thus
855
 * there is also no center of the Effect. 
856
 *    
857
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
858
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
859
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
860
 * @return         ID of the effect added, or -1 if we failed to add one. 
861
 */
862
  public long macroblock(int pixels, int duration, float count) 
863
    {
864
    Interpolator1D di = new Interpolator1D(); 
865
    di.setCount(count);
866
    di.setDuration(duration);
867
    di.add(new Float1D(1));                            
868
    di.add(new Float1D(pixels));                        
869
   
870
    return mF.add(EffectNames.MACROBLOCK, di, null, 0.0f, 0.0f);
871
    }
872

    
873
///////////////////////////////////////////////////////////////////////////////////////////////////
874
///////////////////////////////////////////////////////////////////////////////////////////////////
875
// CHROMA
876
/**
877
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
878
 *        
879
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be
880
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
881
 * @param color  Color to mix.         
882
 * @param region Region this Effect is limited to. 
883
 *               Null here means 'apply the Effect to the whole Bitmap'.
884
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing 
885
 *               the current center of the effect.
886
 * @return       ID of the effect added, or -1 if we failed to add one. 
887
 */
888
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
889
    {
890
    return mF.add(EffectNames.CHROMA, t, color, region, i);
891
    }
892

    
893
///////////////////////////////////////////////////////////////////////////////////////////////////
894
/**
895
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
896
 * <p>
897
 * Here the center of the Effect stays constant.
898
 *         
899
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be 
900
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
901
 * @param color  Color to mix.         
902
 * @param region Region this Effect is limited to. 
903
 *               Null here means 'apply the Effect to the whole Bitmap'.
904
 * @param point  Center of the Effect.
905
 * @return       ID of the effect added, or -1 if we failed to add one. 
906
 */
907
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
908
    {
909
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
910
    }
911

    
912
///////////////////////////////////////////////////////////////////////////////////////////////////  
913
/**
914
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
915
 *        
916
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
917
 *               pixel = (1-t)*pixel + t*color
918
 * @param color  Color to mix.       
919
 * @param region Region this Effect is limited to.
920
 *               Null here means 'apply the Effect to the whole Bitmap'.
921
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
922
 *               current center of the effect.
923
 * @return       ID of the effect added, or -1 if we failed to add one. 
924
 */
925
  public long chroma(float t, Float3D color, Float4D region, Interpolator2D i)
926
    {
927
    return mF.add(EffectNames.CHROMA, t, color, region, i);
928
    }
929

    
930
///// //////////////////////////////////////////////////////////////////////////////////////////////
931
/**
932
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
933
 * <p>
934
 * Here the center of the Effect stays constant.
935
 *         
936
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
937
 *               pixel = (1-t)*pixel + t*color
938
 * @param color  Color to mix.       
939
 * @param region The Region this Effect is limited to. 
940
 *               Null here means 'apply the Effect to the whole Bitmap'.
941
 * @param point  Center of the Effect.
942
 * @return       ID of the effect added, or -1 if we failed to add one. 
943
 */
944
  public long chroma(float t, Float3D color, Float4D region, Float2D point)
945
    {
946
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
947
    }
948

    
949
///////////////////////////////////////////////////////////////////////////////////////////////////
950
/**
951
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
952
 * <p>
953
 * Here the Effect applies to the whole bitmap.
954
 *         
955
 * @param t     Level of blend a given pixel will be mixed with the next parameter 'color': 
956
 *              pixel = (1-t)*pixel + t*color
957
 * @param color Color to mix.       
958
 * @return      ID of the effect added, or -1 if we failed to add one. 
959
 */
960
  public long chroma(float t, Float3D color)
961
    {
962
    return mF.add(EffectNames.CHROMA, t, color, null, 0, 0);
963
    }
964

    
965
///////////////////////////////////////////////////////////////////////////////////////////////////  
966
/**
967
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
968
 * 
969
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
970
 */
971
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
972
    {
973
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
974
    }
975

    
976
///////////////////////////////////////////////////////////////////////////////////////////////////
977
/**
978
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
979
 * 
980
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
981
 */
982
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
983
    {
984
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
985
    }
986
  
987
///////////////////////////////////////////////////////////////////////////////////////////////////  
988
/**
989
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
990
 * 
991
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
992
 */
993
  public long smooth_chroma(float t, Float3D color, Float4D region, Interpolator2D i)
994
    {
995
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
996
    }
997

    
998
///////////////////////////////////////////////////////////////////////////////////////////////////
999
/**
1000
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1001
 * 
1002
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
1003
 */
1004
  public long smooth_chroma(float t, Float3D color, Float4D region, Float2D point)
1005
    {
1006
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
1007
    }
1008
  
1009
///////////////////////////////////////////////////////////////////////////////////////////////////
1010
/**
1011
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
1012
 * 
1013
 * See {@link #chroma(float, Float3D)}
1014
 */
1015
  public long smooth_chroma(float t, Float3D color)
1016
    {
1017
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, null, 0, 0);
1018
    }
1019
  
1020
///////////////////////////////////////////////////////////////////////////////////////////////////
1021
///////////////////////////////////////////////////////////////////////////////////////////////////
1022
// ALPHA
1023
/**
1024
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1025
 *        
1026
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
1027
 *               moment.
1028
 * @param region Region this Effect is limited to. 
1029
 *               Null here means 'apply the Effect to the whole Bitmap'.
1030
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1031
 *               current center of the effect.
1032
 * @return       ID of the effect added, or -1 if we failed to add one. 
1033
 */
1034
  public long alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1035
    {
1036
    return mF.add(EffectNames.ALPHA, a, region, i);
1037
    }
1038

    
1039
///////////////////////////////////////////////////////////////////////////////////////////////////
1040
/**
1041
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1042
 * <p>
1043
 * Here the center of the Effect stays constant.
1044
 *         
1045
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
1046
 *               moment.
1047
 * @param region Region this Effect is limited to. 
1048
 *               Null here means 'apply the Effect to the whole Bitmap'.
1049
 * @param point  Center of the Effect.
1050
 * @return       ID of the effect added, or -1 if we failed to add one. 
1051
 */
1052
  public long alpha(Interpolator1D a, Float4D region, Float2D point)
1053
    {
1054
    return mF.add(EffectNames.ALPHA, a, region, point.x, point.y);
1055
    }
1056

    
1057
///////////////////////////////////////////////////////////////////////////////////////////////////  
1058
/**
1059
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1060
 *        
1061
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1062
 * @param region Region this Effect is limited to. 
1063
 *               Null here means 'apply the Effect to the whole Bitmap'.
1064
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1065
 *               current center of the effect.
1066
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1067
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1068
 * @return       ID of the effect added, or -1 if we failed to add one. 
1069
 */
1070
  public long alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1071
    {
1072
    Interpolator1D di = new Interpolator1D(); 
1073
    di.setCount(count);
1074
    di.setDuration(duration);
1075
    di.add(new Float1D(1));                          
1076
    di.add(new Float1D(alpha));                         
1077
   
1078
    return mF.add(EffectNames.ALPHA, di, region, i);
1079
    }
1080

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

    
1106
///////////////////////////////////////////////////////////////////////////////////////////////////
1107
/**
1108
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1109
 * <p>
1110
 * Here the center of the Effect stays constant and the effect for now change in time.
1111
 *         
1112
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1113
 * @param region Region this Effect is limited to.
1114
 *               Null here means 'apply the Effect to the whole Bitmap'.
1115
 * @param point  Center of the Effect.
1116
 * @return       ID of the effect added, or -1 if we failed to add one. 
1117
 */
1118
  public long alpha(float alpha, Float4D region, Float2D point)
1119
    {
1120
    Interpolator1D di = new Interpolator1D(); 
1121
    di.setCount(0.5f);
1122
    di.setDuration(0);
1123
    di.add(new Float1D(1));                          
1124
    di.add(new Float1D(alpha));                         
1125
   
1126
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1127
    }
1128
  
1129
///////////////////////////////////////////////////////////////////////////////////////////////////
1130
/**
1131
 * Makes the whole Bitmap change its transparency level.
1132
 * 
1133
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1134
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1135
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1136
 * @return         ID of the effect added, or -1 if we failed to add one. 
1137
 */
1138
  public long alpha(float alpha, int duration, float count) 
1139
    {
1140
    Interpolator1D di = new Interpolator1D(); 
1141
    di.setCount(count);
1142
    di.setDuration(duration);
1143
    di.add(new Float1D(1));                            
1144
    di.add(new Float1D(alpha));                        
1145
         
1146
    return mF.add(EffectNames.ALPHA, di,null, 0.0f, 0.0f);
1147
    }
1148

    
1149
///////////////////////////////////////////////////////////////////////////////////////////////////  
1150
/**
1151
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1152
 * 
1153
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1154
 */
1155
  public long smooth_alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1156
    {
1157
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, i);
1158
    }
1159

    
1160
///////////////////////////////////////////////////////////////////////////////////////////////////
1161
/**
1162
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1163
 * 
1164
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1165
 */
1166
  public long smooth_alpha(Interpolator1D a, Float4D region, Float2D point)
1167
    {
1168
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, point.x, point.y);
1169
    }
1170
  
1171
///////////////////////////////////////////////////////////////////////////////////////////////////  
1172
/**
1173
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1174
 * 
1175
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1176
 */
1177
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1178
    {
1179
    Interpolator1D di = new Interpolator1D(); 
1180
    di.setCount(count);
1181
    di.setDuration(duration);
1182
    di.add(new Float1D(1));                          
1183
    di.add(new Float1D(alpha));                         
1184
   
1185
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, i);
1186
    }
1187

    
1188
///////////////////////////////////////////////////////////////////////////////////////////////////
1189
/**
1190
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1191
 * 
1192
 * See {@link #alpha(float, Float4D, Float2D, int, float)}
1193
 */
1194
  public long smooth_alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1195
    {
1196
    Interpolator1D di = new Interpolator1D(); 
1197
    di.setCount(count);
1198
    di.setDuration(duration);
1199
    di.add(new Float1D(1));                          
1200
    di.add(new Float1D(alpha));                         
1201
   
1202
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1203
    }
1204
  
1205
///////////////////////////////////////////////////////////////////////////////////////////////////
1206
/**
1207
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1208
 * 
1209
 * See {@link #alpha(float, Float4D, Float2D)}
1210
 */
1211
  public long smooth_alpha(float alpha, Float4D region, Float2D point)
1212
    {
1213
    Interpolator1D di = new Interpolator1D(); 
1214
    di.setCount(0.5f);
1215
    di.setDuration(0);
1216
    di.add(new Float1D(1));                          
1217
    di.add(new Float1D(alpha));                         
1218
   
1219
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1220
    }
1221
  
1222
///////////////////////////////////////////////////////////////////////////////////////////////////
1223
///////////////////////////////////////////////////////////////////////////////////////////////////
1224
// BRIGHTNESS
1225
/**
1226
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1227
 *        
1228
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1229
 *               moment.
1230
 * @param region Region this Effect is limited to. 
1231
 *               Null here means 'apply the Effect to the whole Bitmap'.
1232
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1233
 *               current center of the effect.
1234
 * @return       ID of the effect added, or -1 if we failed to add one. 
1235
 */
1236
  public long brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1237
    {
1238
    return mF.add(EffectNames.BRIGHTNESS, a, region, i);
1239
    }
1240

    
1241
///////////////////////////////////////////////////////////////////////////////////////////////////
1242
/**
1243
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1244
 * <p>
1245
 * Here the center of the Effect stays constant.
1246
 *         
1247
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1248
 *               moment.
1249
 * @param region Region this Effect is limited to.
1250
 *               Null here means 'apply the Effect to the whole Bitmap'.
1251
 * @param point  Center of the Effect.
1252
 * @return       ID of the effect added, or -1 if we failed to add one. 
1253
 */
1254
  public long brightness(Interpolator1D a, Float4D region, Float2D point)
1255
    {
1256
    return mF.add(EffectNames.BRIGHTNESS, a, region, point.x, point.y);
1257
    }
1258

    
1259
///////////////////////////////////////////////////////////////////////////////////////////////////  
1260
/**
1261
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1262
 *        
1263
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1264
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1265
 *                   anything more than 1- lighten it up. 
1266
 * @param region     Region this Effect is limited to.
1267
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1268
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1269
 *                   representing the current center of the effect.
1270
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1271
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1272
 * @return           ID of the effect added, or -1 if we failed to add one. 
1273
 */
1274
  public long brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1275
    {
1276
    Interpolator1D di = new Interpolator1D(); 
1277
    di.setCount(count);
1278
    di.setDuration(duration);
1279
    di.add(new Float1D(1));                          
1280
    di.add(new Float1D(brightness));                         
1281
   
1282
    return mF.add(EffectNames.BRIGHTNESS, di, region, i);
1283
    }
1284

    
1285
///////////////////////////////////////////////////////////////////////////////////////////////////
1286
/**
1287
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1288
 * <p>
1289
 * Here the center of the Effect stays constant.
1290
 *         
1291
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1292
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1293
 *                   anything more than 1 - lighten it up.
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
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1298
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1299
 * @return           ID of the effect added, or -1 if we failed to add one. 
1300
 */
1301
  public long brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1302
    {
1303
    Interpolator1D di = new Interpolator1D(); 
1304
    di.setCount(count);
1305
    di.setDuration(duration);
1306
    di.add(new Float1D(1));                          
1307
    di.add(new Float1D(brightness));                         
1308
   
1309
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1310
    }
1311

    
1312
///////////////////////////////////////////////////////////////////////////////////////////////////
1313
/**
1314
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1315
 * <p>
1316
 * Here the center of the Effect stays constant and the effect for now change in time.
1317
 *         
1318
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1319
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1320
 *                   anything more than 1 - lighten it up.
1321
 * @param region     Region this Effect is limited to.
1322
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1323
 * @param point      Center of the Effect.
1324
 * @return           ID of the effect added, or -1 if we failed to add one. 
1325
 */
1326
  public long brightness(float brightness, Float4D region, Float2D point)
1327
    {
1328
    Interpolator1D di = new Interpolator1D(); 
1329
    di.setCount(0.5f);
1330
    di.setDuration(0);
1331
    di.add(new Float1D(1));                          
1332
    di.add(new Float1D(brightness));                         
1333
   
1334
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1335
    }
1336
 
1337
///////////////////////////////////////////////////////////////////////////////////////////////////
1338
///////////////////////////////////////////////////////////////////////////////////////////////////
1339
// SMOOTH BRIGHTNESS
1340
/**
1341
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1342
 *        
1343
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1344
 *               any given moment.
1345
 * @param region Region this Effect is limited to. 
1346
 *               Null here means 'apply the Effect to the whole Bitmap'.
1347
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1348
 *               representing the current center of the effect.
1349
 * @return       ID of the effect added, or -1 if we failed to add one. 
1350
 */
1351
  public long smooth_brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1352
    {
1353
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, i);
1354
    }
1355

    
1356
///////////////////////////////////////////////////////////////////////////////////////////////////
1357
/**
1358
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1359
 * <p>
1360
 * Here the center of the Effect stays constant.
1361
 *         
1362
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1363
 *               any given moment.
1364
 * @param region Region this Effect is limited to. 
1365
 *               Null here means 'apply the Effect to the whole Bitmap'.
1366
 * @param point  Center of the Effect.
1367
 * @return       ID of the effect added, or -1 if we failed to add one. 
1368
 */
1369
  public long smooth_brightness(Interpolator1D a, Float4D region, Float2D point)
1370
    {
1371
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, point.x, point.y);
1372
    }
1373

    
1374
///////////////////////////////////////////////////////////////////////////////////////////////////  
1375
/**
1376
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1377
 *        
1378
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1379
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1380
 *                   anything more than 1 - lighten it up. 
1381
 * @param region     Region this Effect is limited to. 
1382
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1383
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1384
 *                   represention the current center of the effect.
1385
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1386
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1387
 * @return           ID of the effect added, or -1 if we failed to add one. 
1388
 */
1389
  public long smooth_brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1390
    {
1391
    Interpolator1D di = new Interpolator1D(); 
1392
    di.setCount(count);
1393
    di.setDuration(duration);
1394
    di.add(new Float1D(1));                          
1395
    di.add(new Float1D(brightness));                         
1396
   
1397
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, i);
1398
    }
1399

    
1400
///////////////////////////////////////////////////////////////////////////////////////////////////
1401
/**
1402
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1403
 * <p>
1404
 * Here the center of the Effect stays constant.
1405
 *         
1406
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1407
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1408
 *                   anything more than 1 - lighten it up.
1409
 * @param region     Region this Effect is limited to. 
1410
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1411
 * @param point      Center of the Effect.
1412
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1413
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1414
 * @return           ID of the effect added, or -1 if we failed to add one. 
1415
 */
1416
  public long smooth_brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1417
    {
1418
    Interpolator1D di = new Interpolator1D(); 
1419
    di.setCount(count);
1420
    di.setDuration(duration);
1421
    di.add(new Float1D(1));                          
1422
    di.add(new Float1D(brightness));                         
1423
   
1424
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1425
    }
1426

    
1427
///////////////////////////////////////////////////////////////////////////////////////////////////
1428
/**
1429
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1430
 * <p>
1431
 * Here the center of the Effect stays constant and the effect for now change in time.
1432
 *         
1433
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1434
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1435
 *                   anything more than 1 - lighten it up.
1436
 * @param region     Region this Effect is limited to. 
1437
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1438
 * @param point      Center of the Effect.
1439
 * @return           ID of the effect added, or -1 if we failed to add one. 
1440
 */
1441
  public long smooth_brightness(float brightness, Float4D region, Float2D point)
1442
    {
1443
    Interpolator1D di = new Interpolator1D(); 
1444
    di.setCount(0.5f);
1445
    di.setDuration(0);
1446
    di.add(new Float1D(1));                          
1447
    di.add(new Float1D(brightness));                         
1448
   
1449
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1450
    }
1451
    
1452
///////////////////////////////////////////////////////////////////////////////////////////////////
1453
/**
1454
 * Makes the whole Bitmap change its brightness level.
1455
 * 
1456
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1457
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1458
 *                   anything more than 1- lighten it up.
1459
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1460
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1461
 * @return           ID of the effect added, or -1 if we failed to add one. 
1462
 */
1463
  public long smooth_brightness(float brightness, int duration, float count) 
1464
    {
1465
    Interpolator1D di = new Interpolator1D(); 
1466
    di.setCount(count);
1467
    di.setDuration(duration);
1468
    di.add(new Float1D(1));                            
1469
    di.add(new Float1D(brightness));                        
1470
         
1471
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, 0.0f, 0.0f);
1472
    }
1473

    
1474
///////////////////////////////////////////////////////////////////////////////////////////////////
1475
///////////////////////////////////////////////////////////////////////////////////////////////////
1476
// CONTRAST
1477
/**
1478
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1479
 *        
1480
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1481
 *               at any given moment.
1482
 * @param region Region this Effect is limited to. 
1483
 *               Null here means 'apply the Effect to the whole Bitmap'.
1484
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1485
 *               representing the current center of the effect.
1486
 * @return       ID of the effect added, or -1 if we failed to add one. 
1487
 */
1488
  public long contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1489
    {
1490
    return mF.add(EffectNames.CONTRAST, a, region, i);
1491
    }
1492

    
1493
///////////////////////////////////////////////////////////////////////////////////////////////////
1494
/**
1495
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1496
 * <p>
1497
 * Here the center of the Effect stays constant.
1498
 *         
1499
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1500
 *               at any given moment.
1501
 * @param region Region this Effect is limited to.
1502
 *               Null here means 'apply the Effect to the whole Bitmap'.
1503
 * @param point  Center of the Effect.
1504
 * @return       ID of the effect added, or -1 if we failed to add one. 
1505
 */
1506
  public long contrast(Interpolator1D a, Float4D region, Float2D point)
1507
    {
1508
    return mF.add(EffectNames.CONTRAST, a, region, point.x, point.y);
1509
    }
1510

    
1511
///////////////////////////////////////////////////////////////////////////////////////////////////  
1512
/**
1513
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1514
 *        
1515
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1516
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1517
 *                 anything more than 1 - increase the contrast. 
1518
 * @param region   Region this Effect is limited to.
1519
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1520
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1521
 *                 represention the current center of the effect.
1522
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1523
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1524
 * @return         ID of the effect added, or -1 if we failed to add one. 
1525
 */
1526
  public long contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1527
    {
1528
    Interpolator1D di = new Interpolator1D(); 
1529
    di.setCount(count);
1530
    di.setDuration(duration);
1531
    di.add(new Float1D(1));                          
1532
    di.add(new Float1D(contrast));                         
1533
   
1534
    return mF.add(EffectNames.CONTRAST, di, region, i);
1535
    }
1536

    
1537
///////////////////////////////////////////////////////////////////////////////////////////////////
1538
/**
1539
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1540
 * <p>
1541
 * Here the center of the Effect stays constant.
1542
 *         
1543
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1544
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1545
 *                 anything more than 1 -increase the contrast. 
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
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1550
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1551
 * @return         ID of the effect added, or -1 if we failed to add one. 
1552
 */
1553
  public long contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1554
    {
1555
    Interpolator1D di = new Interpolator1D(); 
1556
    di.setCount(count);
1557
    di.setDuration(duration);
1558
    di.add(new Float1D(1));                          
1559
    di.add(new Float1D(contrast));                         
1560
   
1561
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1562
    }
1563

    
1564
///////////////////////////////////////////////////////////////////////////////////////////////////
1565
/**
1566
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1567
 * <p>
1568
 * Here the center of the Effect stays constant and the effect for now change in time.
1569
 *         
1570
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1571
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1572
 *                 anything more than 1 - increase the contrast. 
1573
 * @param region   Region this Effect is limited to. 
1574
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1575
 * @param point    Center of the Effect.
1576
 * @return         ID of the effect added, or -1 if we failed to add one. 
1577
 */
1578
  public long contrast(float contrast, Float4D region, Float2D point)
1579
    {
1580
    Interpolator1D di = new Interpolator1D(); 
1581
    di.setCount(0.5f);
1582
    di.setDuration(0);
1583
    di.add(new Float1D(1));                          
1584
    di.add(new Float1D(contrast));                         
1585
   
1586
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1587
    }
1588
 
1589
///////////////////////////////////////////////////////////////////////////////////////////////////
1590
///////////////////////////////////////////////////////////////////////////////////////////////////
1591
// SMOOTH CONTRAST
1592
/**
1593
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1594
 *        
1595
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1596
 *               at any given moment.
1597
 * @param region Region this Effect is limited to. 
1598
 *               Null here means 'apply the Effect to the whole Bitmap'.
1599
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1600
 *               representing the current center of the effect.
1601
 * @return       ID of the effect added, or -1 if we failed to add one. 
1602
 */
1603
  public long smooth_contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1604
    {
1605
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, i);
1606
    }
1607

    
1608
///////////////////////////////////////////////////////////////////////////////////////////////////
1609
/**
1610
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1611
 * <p>
1612
 * Here the center of the Effect stays constant.
1613
 *         
1614
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1615
 *               at any given moment.
1616
 * @param region Region this Effect is limited to. 
1617
 *               Null here means 'apply the Effect to the whole Bitmap'.
1618
 * @param point  Center of the Effect.
1619
 * @return       ID of the effect added, or -1 if we failed to add one. 
1620
 */
1621
  public long smooth_contrast(Interpolator1D a, Float4D region, Float2D point)
1622
    {
1623
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, point.x, point.y);
1624
    }
1625

    
1626
///////////////////////////////////////////////////////////////////////////////////////////////////  
1627
/**
1628
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1629
 *        
1630
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1631
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1632
 *                 anything more than 1 - increase the contrast. 
1633
 * @param region   Region this Effect is limited to. 
1634
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1635
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1636
 *                 representing the current center of the effect.
1637
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1638
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1639
 * @return         ID of the effect added, or -1 if we failed to add one. 
1640
 */
1641
  public long smooth_contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1642
    {
1643
    Interpolator1D di = new Interpolator1D(); 
1644
    di.setCount(count);
1645
    di.setDuration(duration);
1646
    di.add(new Float1D(1));                          
1647
    di.add(new Float1D(contrast));                         
1648
   
1649
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, i);
1650
    }
1651

    
1652
///////////////////////////////////////////////////////////////////////////////////////////////////
1653
/**
1654
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1655
 * <p>
1656
 * Here the center of the Effect stays constant.
1657
 *         
1658
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1659
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1660
 *                 anything more than 1 - increase the contrast. 
1661
 * @param region   Region this Effect is limited to. 
1662
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1663
 * @param point    Center of the Effect.
1664
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1665
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1666
 * @return         ID of the effect added, or -1 if we failed to add one. 
1667
 */
1668
  public long smooth_contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1669
    {
1670
    Interpolator1D di = new Interpolator1D(); 
1671
    di.setCount(count);
1672
    di.setDuration(duration);
1673
    di.add(new Float1D(1));                          
1674
    di.add(new Float1D(contrast));                         
1675
   
1676
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1677
    }
1678

    
1679
///////////////////////////////////////////////////////////////////////////////////////////////////
1680
/**
1681
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1682
 * <p>
1683
 * Here the center of the Effect stays constant and the effect for now change in time.
1684
 *         
1685
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1686
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1687
 *                 anything more than 1 - increase the contrast. 
1688
 * @param region   Region this Effect is limited to. 
1689
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1690
 * @param point    Center of the Effect.
1691
 * @return         ID of the effect added, or -1 if we failed to add one. 
1692
 */
1693
  public long smooth_contrast(float contrast, Float4D region, Float2D point)
1694
    {
1695
    Interpolator1D di = new Interpolator1D(); 
1696
    di.setCount(0.5f);
1697
    di.setDuration(0);
1698
    di.add(new Float1D(1));                          
1699
    di.add(new Float1D(contrast));                         
1700
   
1701
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1702
    }
1703
    
1704
///////////////////////////////////////////////////////////////////////////////////////////////////
1705
/**
1706
 * Makes the whole Bitmap change its contrast level.
1707
 * 
1708
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1709
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1710
 *                 anything omre than 1 - increase the contrast. 
1711
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1712
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1713
 * @return         ID of the effect added, or -1 if we failed to add one. 
1714
 */
1715
  public long smooth_contrast(float contrast, int duration, float count) 
1716
    {
1717
    Interpolator1D di = new Interpolator1D(); 
1718
    di.setCount(count);
1719
    di.setDuration(duration);
1720
    di.add(new Float1D(1));                            
1721
    di.add(new Float1D(contrast));                        
1722
         
1723
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, 0.0f, 0.0f);
1724
    }
1725

    
1726

    
1727
///////////////////////////////////////////////////////////////////////////////////////////////////
1728
///////////////////////////////////////////////////////////////////////////////////////////////////
1729
// SATURATION
1730
/**
1731
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1732
 *        
1733
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1734
 *               at any given moment.
1735
 * @param region Region this Effect is limited to. 
1736
 *               Null here means 'apply the Effect to the whole Bitmap'.
1737
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1738
 *               representing the current center of the effect.
1739
 * @return       ID of the effect added, or -1 if we failed to add one. 
1740
 */
1741
  public long saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1742
    {
1743
    return mF.add(EffectNames.SATURATION, a, region, i);
1744
    }
1745

    
1746
///////////////////////////////////////////////////////////////////////////////////////////////////
1747
/**
1748
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1749
 * <p>
1750
 * Here the center of the Effect stays constant.
1751
 *         
1752
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1753
 *               at any given moment.
1754
 * @param region Region this Effect is limited to. 
1755
 *               Null here means 'apply the Effect to the whole Bitmap'.
1756
 * @param point  Center of the Effect.
1757
 * @return       ID of the effect added, or -1 if we failed to add one. 
1758
 */
1759
  public long saturation(Interpolator1D a, Float4D region, Float2D point)
1760
    {
1761
    return mF.add(EffectNames.SATURATION, a, region, point.x, point.y);
1762
    }
1763

    
1764
///////////////////////////////////////////////////////////////////////////////////////////////////  
1765
/**
1766
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1767
 *        
1768
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1769
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1770
 *                   anything more than 1 - increase the saturation. 
1771
 * @param region     Region this Effect is limited to.
1772
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1773
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1774
 *                   representing the current center of the effect.
1775
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1776
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1777
 * @return           ID of the effect added, or -1 if we failed to add one. 
1778
 */
1779
  public long saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1780
    {
1781
    Interpolator1D di = new Interpolator1D(); 
1782
    di.setCount(count);
1783
    di.setDuration(duration);
1784
    di.add(new Float1D(1));                          
1785
    di.add(new Float1D(saturation));                         
1786
   
1787
    return mF.add(EffectNames.SATURATION, di, region, i);
1788
    }
1789

    
1790
///////////////////////////////////////////////////////////////////////////////////////////////////
1791
/**
1792
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1793
 * <p>
1794
 * Here the center of the Effect stays constant.
1795
 *         
1796
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1797
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1798
 *                   anything more than 1 - increase the saturation. 
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
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1803
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1804
 * @return           ID of the effect added, or -1 if we failed to add one. 
1805
 */
1806
  public long saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1807
    {
1808
    Interpolator1D di = new Interpolator1D(); 
1809
    di.setCount(count);
1810
    di.setDuration(duration);
1811
    di.add(new Float1D(1));                          
1812
    di.add(new Float1D(saturation));                         
1813
   
1814
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1815
    }
1816

    
1817
///////////////////////////////////////////////////////////////////////////////////////////////////
1818
/**
1819
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1820
 * <p>
1821
 * Here the center of the Effect stays constant and the effect for now change in time.
1822
 *         
1823
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1824
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1825
 *                   anything more than 1- increase the saturation. 
1826
 * @param region     Region this Effect is limited to. 
1827
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1828
 * @param point      Center of the Effect.
1829
 * @return           ID of the effect added, or -1 if we failed to add one. 
1830
 */
1831
  public long saturation(float saturation, Float4D region, Float2D point)
1832
    {
1833
    Interpolator1D di = new Interpolator1D(); 
1834
    di.setCount(0.5f);
1835
    di.setDuration(0);
1836
    di.add(new Float1D(1));                          
1837
    di.add(new Float1D(saturation));                         
1838
   
1839
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1840
    }
1841
 
1842
///////////////////////////////////////////////////////////////////////////////////////////////////
1843
///////////////////////////////////////////////////////////////////////////////////////////////////
1844
// SMOOTH_SATURATION
1845
/**
1846
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1847
 *        
1848
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1849
 *               at any given moment.
1850
 * @param region Region this Effect is limited to. 
1851
 *               Null here means 'apply the Effect to the whole Bitmap'.
1852
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D 
1853
 *               representing the current center of the effect.
1854
 * @return       ID of the effect added, or -1 if we failed to add one. 
1855
 */
1856
  public long smooth_saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1857
    {
1858
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, i);
1859
    }
1860

    
1861
///////////////////////////////////////////////////////////////////////////////////////////////////
1862
/**
1863
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1864
 * <p>
1865
 * Here the center of the Effect stays constant.
1866
 *         
1867
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1868
 *               at any given moment.
1869
 * @param region Region this Effect is limited to. 
1870
 *               Null here means 'apply the Effect to the whole Bitmap'.
1871
 * @param point  Center of the Effect.
1872
 * @return       ID of the effect added, or -1 if we failed to add one. 
1873
 */
1874
  public long smooth_saturation(Interpolator1D a, Float4D region, Float2D point)
1875
    {
1876
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, point.x, point.y);
1877
    }
1878

    
1879
///////////////////////////////////////////////////////////////////////////////////////////////////  
1880
/**
1881
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1882
 *        
1883
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1884
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1885
 *                   anything more than 1 -increase the saturation. 
1886
 * @param region     Region this Effect is limited to. 
1887
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1888
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1889
 *                   representing the current center of the effect.
1890
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1891
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1892
 * @return           ID of the effect added, or -1 if we failed to add one. 
1893
 */
1894
  public long smooth_saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1895
    {
1896
    Interpolator1D di = new Interpolator1D(); 
1897
    di.setCount(count);
1898
    di.setDuration(duration);
1899
    di.add(new Float1D(1));                          
1900
    di.add(new Float1D(saturation));                         
1901
   
1902
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, i);
1903
    }
1904

    
1905
///////////////////////////////////////////////////////////////////////////////////////////////////
1906
/**
1907
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1908
 * <p>
1909
 * Here the center of the Effect stays constant.
1910
 *         
1911
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1912
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1913
 *                   anything more than 1 - increase the saturation. 
1914
 * @param region     Region this Effect is limited to. 
1915
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1916
 * @param point      Center of the Effect.
1917
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1918
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1919
 * @return           ID of the effect added, or -1 if we failed to add one. 
1920
 */
1921
  public long smooth_saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1922
    {
1923
    Interpolator1D di = new Interpolator1D(); 
1924
    di.setCount(count);
1925
    di.setDuration(duration);
1926
    di.add(new Float1D(1));                          
1927
    di.add(new Float1D(saturation));                         
1928
   
1929
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1930
    }
1931

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

    
1998
///////////////////////////////////////////////////////////////////////////////////////////////////
1999
/**
2000
 * Distort part of the Bitmap by a (possibly changing in time) vector of force.
2001
 * <p>
2002
 * Difference between this and the previous method is that here the center of the Effect stays constant.
2003
 *   
2004
 * @param i      2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2005
 *               represents the vector the Center of the Effect is currently being dragged with.
2006
 * @param region Region that masks the effect of the Distortion.
2007
 * @param point  Center of the Effect.
2008
 * @return       ID of the effect added, or -1 if we failed to add one. 
2009
 */
2010
  public long distort(Interpolator i, Float4D region, Float2D point)
2011
    {  
2012
    return mV.add(EffectNames.DISTORT, i, region, point.x, point.y);  
2013
    }
2014

    
2015
///////////////////////////////////////////////////////////////////////////////////////////////////
2016
/**
2017
 * Distort the whole Bitmap by a (possibly changing in time) vector of force.
2018
 * 
2019
 * @param i     2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2020
 *              represents the vector the Center of the Effect is currently being dragged with.
2021
 * @param point Center of the Effect.
2022
 * @return      ID of the effect added, or -1 if we failed to add one. 
2023
 */
2024
  public long distort(Interpolator i, Float2D point)
2025
    {
2026
    return mV.add(EffectNames.DISTORT, i, null, point.x, point.y);  
2027
    }
2028

    
2029
///////////////////////////////////////////////////////////////////////////////////////////////////
2030
/**
2031
 * Distort part of the Bitmap by a vector of force that changes from (0,0,0) to v.
2032
 * 
2033
 * @param vector   Maximum vector of force. 
2034
 * @param region   Region that masks the effect of the Distortion.
2035
 * @param point    Center of the Effect.
2036
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2037
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2038
 * @return         ID of the effect added, or -1 if we failed to add one. 
2039
 */
2040
  public long distort(Float3D vector, Float4D region, Float2D point, int duration, float count)
2041
    {  
2042
    Interpolator3D di = new Interpolator3D(); 
2043
    di.setCount(count);
2044
    di.setDuration(duration);
2045
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2046
    di.add(vector);                                                  
2047
           
2048
    return mV.add(EffectNames.DISTORT, di, region, point.x, point.y);  
2049
    }
2050

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

    
2072
///////////////////////////////////////////////////////////////////////////////////////////////////
2073
/**
2074
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
2075
 * <p>
2076
 * Difference between this and the previous method is that here the vector of force will get interpolated
2077
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2078
 * 
2079
 * @param vector   Maximum, final vector of force.
2080
 * @param point    Center of the Effect.
2081
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2082
 * @return         ID of the effect added, or -1 if we failed to add one. 
2083
 */
2084
  public long distort(Float3D vector, Float2D point, int duration)
2085
    {
2086
    Interpolator3D di = new Interpolator3D();  
2087
    di.setCount(0.5f);
2088
    di.setDuration(duration);
2089
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2090
    di.add(vector);                 
2091
           
2092
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2093
    }
2094

    
2095
///////////////////////////////////////////////////////////////////////////////////////////////////
2096
/**
2097
 * Distort the whole Bitmap by a vector of force v.
2098
 * <p>
2099
 * Here we apply a constant vector of force.
2100
 * 
2101
 * @param vector Vector of force.
2102
 * @param point  Center of the Effect.
2103
 * @return       ID of the effect added, or -1 if we failed to add one. 
2104
 */
2105
  public long distort(Float3D vector, Float2D point )
2106
    {
2107
    Interpolator3D di = new Interpolator3D(); 
2108
    di.setCount(0.5f);
2109
    di.setDuration(0);
2110
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2111
    di.add(vector);           
2112
           
2113
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2114
    }
2115

    
2116
///////////////////////////////////////////////////////////////////////////////////////////////////
2117
///////////////////////////////////////////////////////////////////////////////////////////////////
2118
// DEFORM
2119
/**
2120
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2121
 * a (possibly changing in time) point on the Bitmap.
2122
 *     
2123
 * @param i     Interpolator that, at any given time, returns a Point2D representing vector of 
2124
 *              force that deforms the shapre of the whole Bitmap.
2125
 * @param point 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2126
 *              the Center of the Effect.
2127
 * @return      ID of the effect added, or -1 if we failed to add one. 
2128
 */
2129
  public long deform(Interpolator i, Interpolator2D point)
2130
    {  
2131
    return mV.add(EffectNames.DEFORM, i, null, point);  
2132
    }
2133

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

    
2149
///////////////////////////////////////////////////////////////////////////////////////////////////
2150
/**
2151
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2152
 * applied to a constant point on the Bitmap. 
2153
 * 
2154
 * @param vector   Vector of force.
2155
 * @param point    Center of the Effect.
2156
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2157
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2158
 * @return         ID of the effect added, or -1 if we failed to add one. 
2159
 */
2160
  public long deform(Float3D vector, Float2D point, int duration, float count)
2161
    {
2162
    Interpolator3D di = new Interpolator3D(); 
2163
    di.setCount(count);
2164
    di.setDuration(duration);
2165
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2166
    di.add(vector);                
2167
           
2168
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2169
    }
2170

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

    
2194
///////////////////////////////////////////////////////////////////////////////////////////////////
2195
/**
2196
 * Deform the shape of the whole Bitmap with a constant vector of force applied to a constant 
2197
 * point on the Bitmap. 
2198
 * 
2199
 * @param vector Vector of force.
2200
 * @param point  Center of the Effect.
2201
 * @return       ID of the effect added, or -1 if we failed to add one. 
2202
 */
2203
  public long deform(Float3D vector, Float2D point )
2204
    {
2205
    Interpolator3D di = new Interpolator3D(); 
2206
    di.setCount(0.5f);
2207
    di.setDuration(0);
2208
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2209
    di.add(vector);            
2210
           
2211
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2212
    }
2213
   
2214
///////////////////////////////////////////////////////////////////////////////////////////////////  
2215
///////////////////////////////////////////////////////////////////////////////////////////////////
2216
// SINK
2217
/**
2218
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2219
 * away from the center (degree<=1)
2220
 *    
2221
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing
2222
 *               the current degree of the effect.
2223
 * @param region Region that masks the effect of the Sink.
2224
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2225
 *               the Center of the Effect.
2226
 * @return       ID of the effect added, or -1 if we failed to add one. 
2227
 */
2228
  public long sink(Interpolator1D di, Float4D region, Interpolator2D point)
2229
    {
2230
    return mV.add(EffectNames.SINK, di, region, point);  
2231
    }
2232

    
2233
///////////////////////////////////////////////////////////////////////////////////////////////////
2234
/**
2235
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2236
 * away from the center (degree<=1).
2237
 * <p>
2238
 * Here the Center stays constant.
2239
 *      
2240
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D
2241
 *               representing the current degree of the effect.
2242
 * @param region Region that masks the effect of the Sink.
2243
 * @param point  Center of the Effect.
2244
 * @return       ID of the effect added, or -1 if we failed to add one. 
2245
 */
2246
  public long sink(Interpolator1D di, Float4D region, Float2D point)
2247
    {
2248
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2249
    }
2250
  
2251
///////////////////////////////////////////////////////////////////////////////////////////////////
2252
/**
2253
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2254
 * away from the center (degree<=1).
2255
 * <p>
2256
 * Here we can only interpolate between 1 and degree.
2257
 * 
2258
 * @param degree   How much to push or pull. Between 0 and infinity.
2259
 * @param region   Region that masks the effect of the Sink.
2260
 * @param p        2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2261
 *                 the Center of the Effect.
2262
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2263
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2264
 * @return         ID of the effect added, or -1 if we failed to add one. 
2265
 */
2266
  public long sink(float degree, Float4D region, Interpolator2D p, int duration, float count)
2267
    {
2268
    Interpolator1D di = new Interpolator1D(); 
2269
    di.setCount(count);
2270
    di.setDuration(duration);
2271
    di.add(new Float1D(1));                                
2272
    di.add(new Float1D(degree));                          
2273
    
2274
    return mV.add(EffectNames.SINK, di, region, p);  
2275
    }
2276

    
2277
///////////////////////////////////////////////////////////////////////////////////////////////////
2278
/**
2279
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2280
 * away from the center (degree<=1).
2281
 *   
2282
 * @param degree   How much to push or pull. Between 0 and infinity.
2283
 * @param region   Region that masks the effect of the Sink.
2284
 * @param point    Center of the Effect.
2285
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2286
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2287
 * @return         ID of the effect added, or -1 if we failed to add one. 
2288
 */
2289
  public long sink(float degree, Float4D region, Float2D point, int duration, float count)
2290
    {
2291
    Interpolator1D di = new Interpolator1D(); 
2292
    di.setCount(count);
2293
    di.setDuration(duration);
2294
    di.add(new Float1D(1));                                
2295
    di.add(new Float1D(degree));                          
2296
    
2297
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2298
    }
2299

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

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

    
2345
///////////////////////////////////////////////////////////////////////////////////////////////////
2346
/**
2347
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2348
 * away from the center (degree<=1).
2349
 * <p>
2350
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2351
 * 
2352
 * @param degree How much to push or pull. Between 0 and infinity.
2353
 * @param point  Center of the Effect.
2354
 * @return       ID of the effect added, or -1 if we failed to add one. 
2355
 */
2356
  public long sink(float degree, Float2D point) 
2357
    {
2358
    Interpolator1D di = new Interpolator1D(); 
2359
    di.setCount(0.5f);
2360
    di.setDuration(0);
2361
    di.add(new Float1D(1));                               
2362
    di.add(new Float1D(degree));                      
2363
        
2364
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2365
    }
2366
  
2367
///////////////////////////////////////////////////////////////////////////////////////////////////  
2368
///////////////////////////////////////////////////////////////////////////////////////////////////
2369
// SWIRL
2370
/**
2371
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2372
 * Interpolator). 
2373
 *   
2374
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2375
 *               the degree of Swirl.
2376
 * @param region Region that masks the effect of the Swirl.
2377
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2378
 *               the Center of the Effect.
2379
 * @return       ID of the effect added, or -1 if we failed to add one. 
2380
 */
2381
  public long swirl(Interpolator1D di, Float4D region, Interpolator2D point)
2382
    {    
2383
    return mV.add(EffectNames.SWIRL, di, region, point);  
2384
    }
2385

    
2386
///////////////////////////////////////////////////////////////////////////////////////////////////
2387
/**
2388
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2389
 * Interpolator).
2390
 * <p>
2391
 * Here the Center stays constant.
2392
 *      
2393
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2394
 *               the degree of Swirl.
2395
 * @param region Region that masks the effect of the Swirl.
2396
 * @param point  Center of the Effect.
2397
 * @return       ID of the effect added, or -1 if we failed to add one. 
2398
 */
2399
  public long swirl(Interpolator1D di, Float4D region, Float2D point)
2400
    {    
2401
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2402
    }
2403
 
2404
///////////////////////////////////////////////////////////////////////////////////////////////////
2405
/**
2406
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2407
 *   
2408
 * @param degree   Angle of rotation. Unit: degrees.
2409
 * @param region   Region that masks the effect of the Swirl.
2410
 * @param point    2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2411
 *                 the Center of the Effect.
2412
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2413
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2414
 * @return         ID of the effect added, or -1 if we failed to add one. 
2415
 */
2416
  public long swirl(int degree, Float4D region, Interpolator2D point, int duration, float count)
2417
    {
2418
    Interpolator1D di = new Interpolator1D(); 
2419
    di.setCount(count);
2420
    di.setDuration(duration);
2421
    di.add(new Float1D(0));                                
2422
    di.add(new Float1D(degree));                          
2423
    
2424
    return mV.add(EffectNames.SWIRL, di, region, point);  
2425
    }
2426

    
2427
///////////////////////////////////////////////////////////////////////////////////////////////////
2428
/**
2429
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2430
 * <p>
2431
 * Here the Center stays constant.
2432
 *    
2433
 * @param degree   Angle of rotation. Unit: degrees.
2434
 * @param region   Region that masks the effect of the Swirl.
2435
 * @param point    Center of the Effect.
2436
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2437
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2438
 * @return         ID of the effect added, or -1 if we failed to add one. 
2439
 */
2440
  public long swirl(int degree, Float4D region, Float2D point, int duration, float count)
2441
    {
2442
    Interpolator1D di = new Interpolator1D(); 
2443
    di.setCount(count);
2444
    di.setDuration(duration);
2445
    di.add(new Float1D(0));                                
2446
    di.add(new Float1D(degree));                          
2447
    
2448
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2449
    }
2450

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

    
2472
///////////////////////////////////////////////////////////////////////////////////////////////////
2473
/**
2474
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2475
 * <p>
2476
 * Equivalent to calling the previous method with count=0.5.
2477
 * 
2478
 * @param degree   Angle of rotation. Unit: degrees.
2479
 * @param point    Center of the Effect.
2480
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2481
 * @return         ID of the effect added, or -1 if we failed to add one. 
2482
 */
2483
  public long swirl(int degree, Float2D point, int duration) 
2484
    {
2485
    Interpolator1D di = new Interpolator1D(); 
2486
    di.setCount(0.5f);
2487
    di.setDuration(duration);
2488
    di.add(new Float1D(0));                               
2489
    di.add(new Float1D(degree));                      
2490
        
2491
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2492
    }
2493

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

    
2515
///////////////////////////////////////////////////////////////////////////////////////////////////
2516
///////////////////////////////////////////////////////////////////////////////////////////////////
2517
// WAVE
2518

    
2519
///////////////////////////////////////////////////////////////////////////////////////////////////   
2520
}
(5-5/29)