Project

General

Profile

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

library / src / main / java / org / distorted / library / DistortedObject.java @ 1e438fc7

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
    private static float[] mViewMatrix = new float[16];
14
   
15
    protected EffectListMatrix     mM;
16
    protected EffectListFragment   mF;
17
    protected EffectListVertex     mV;
18
    protected EffectListOther      mO;
19

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

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

    
30
///////////////////////////////////////////////////////////////////////////////////////////////////
31

    
32
    protected abstract DistortedObject deepCopy(int flags);
33

    
34
///////////////////////////////////////////////////////////////////////////////////////////////////
35

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

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

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

    
135
      mO.send();
136
      }
137

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

    
157
      mO.abortAll();
158

    
159
      mBmp          = null;
160
      mGrid         = null;
161
      mM            = null;
162
      mV            = null;
163
      mF            = null;
164
      mO            = null;
165
      mTextureDataH = null;
166
      }
167
 
168
///////////////////////////////////////////////////////////////////////////////////////////////////
169

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

    
175
///////////////////////////////////////////////////////////////////////////////////////////////////
176

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

    
183
      }
184

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

    
199
      mID = DistortedObjectList.add(this);
200

    
201
      mSizeX = dc.mSizeX;
202
      mSizeY = dc.mSizeY;
203
      mSizeZ = dc.mSizeZ;
204
      mSize  = dc.mSize;
205
      mGrid  = dc.mGrid;
206

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

    
222
        if( Distorted.isInitialized() ) resetTexture();
223
        }
224
      }
225

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

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

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

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

    
365
///////////////////////////////////////////////////////////////////////////////////////////////////
366
/**
367
 * Aborts a subset of Effects.
368
 * 
369
 * @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_PRE | TYPE_VERT | TYPE_FRAG.
370
 */
371
    public void abortAllEffects(int mask)
372
      {
373
      if( (mask & EffectTypes.MATRIX.type   ) != 0 ) mM.abortAll();
374
      if( (mask & EffectTypes.VERTEX.type   ) != 0 ) mV.abortAll();
375
      if( (mask & EffectTypes.FRAGMENT.type ) != 0 ) mF.abortAll();
376
      if( (mask & EffectTypes.OTHER.type    ) != 0 ) mO.abortAll();
377
      }
378
    
379
///////////////////////////////////////////////////////////////////////////////////////////////////
380
/**
381
 * Aborts a single Effect.
382
 * 
383
 * @param id ID of the Effect we want to abort.
384
 * @return <code>true</code> if the Effect was found and successfully aborted.
385
 */
386
    public boolean abortEffect(long id)
387
      {
388
      int type = (int)(id&EffectTypes.MASK);
389

    
390
      if( type==EffectTypes.MATRIX.type   )  return mM.removeByID(id>>EffectTypes.LENGTH);
391
      if( type==EffectTypes.VERTEX.type   )  return mV.removeByID(id>>EffectTypes.LENGTH);
392
      if( type==EffectTypes.FRAGMENT.type )  return mF.removeByID(id>>EffectTypes.LENGTH);
393
      if( type==EffectTypes.OTHER.type    )  return mO.removeByID(id>>EffectTypes.LENGTH);
394

    
395
      return false;
396
      }
397

    
398
///////////////////////////////////////////////////////////////////////////////////////////////////
399
/**
400
 * Abort all Effects of a given type, for example all rotations.
401
 * 
402
 * @param effectType one of the constants defined in {@link EffectNames}
403
 * @return <code>true</code> if a single Effect of type effectType has been found and aborted. 
404
 */
405
    public boolean abortEffectType(EffectNames effectType)
406
      {
407
      switch(effectType.getType())
408
        {
409
        case MATRIX  : return mM.removeByType(effectType);
410
        case VERTEX  : return mV.removeByType(effectType);
411
        case FRAGMENT: return mF.removeByType(effectType);
412
        case OTHER   : return mO.removeByType(effectType);
413
        default           : return false;
414
        }
415
      }
416
    
417
///////////////////////////////////////////////////////////////////////////////////////////////////
418
/**
419
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
420
 * 
421
 * @param id Effect ID we want to print info about
422
 * @return <code>true</code> if a single Effect of type effectType has been found.
423
 */
424
    
425
    public boolean printEffect(long id)
426
      {
427
      int type = (int)(id&EffectTypes.MASK);
428

    
429
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
430
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
431
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
432
      if( type==EffectTypes.OTHER.type    )  return mO.printByID(id>>EffectTypes.LENGTH);
433

    
434
      return false;
435
      }
436
   
437
///////////////////////////////////////////////////////////////////////////////////////////////////   
438
///////////////////////////////////////////////////////////////////////////////////////////////////
439
// Individual effect functions.
440
///////////////////////////////////////////////////////////////////////////////////////////////////
441
// Matrix-based effects
442
///////////////////////////////////////////////////////////////////////////////////////////////////
443
// MOVE
444
/**
445
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
446
 * 
447
 * @param di 3-dimensional Interpolator which at any given time will return a Float3D
448
 *           representing the current coordinates of the vector we want to move the Object with.
449
 * @return   ID of the effect added, or -1 if we failed to add one. 
450
 */
451
  public long move(Interpolator3D di)
452
    {   
453
    return mM.add(EffectNames.MOVE,null,di);  
454
    }
455

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

    
474
    return mM.add(EffectNames.MOVE,null,di);  
475
    }
476

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

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

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

    
525
    return mM.add(EffectNames.SCALE,null,di);  
526
    }
527

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

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

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

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

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

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

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

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

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

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

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

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

    
812
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
813
    }
814

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
1724

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
2513
///////////////////////////////////////////////////////////////////////////////////////////////////
2514
///////////////////////////////////////////////////////////////////////////////////////////////////
2515
// WAVE
2516

    
2517
///////////////////////////////////////////////////////////////////////////////////////////////////   
2518
}
(5-5/30)