Project

General

Profile

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

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

1 6a06a912 Leszek Koltunski
package org.distorted.library;
2
3
import android.graphics.Bitmap;
4
import android.opengl.GLES20;
5
import android.opengl.GLUtils;
6
7
///////////////////////////////////////////////////////////////////////////////////////////////////
8
9
public abstract class DistortedObject 
10
{ 
11
    static final int TYPE_NUM = 3;
12
    private static final int TYPE_MASK= (1<<TYPE_NUM)-1;
13
    private static float[] mViewMatrix = new float[16];
14
   
15
    protected EffectListMatrix   mM;
16
    protected EffectListFragment mF;
17
    protected EffectListVertex   mV;
18
19
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
20
 
21
    protected GridObject mGrid = null;
22
    protected long mID;
23
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
24
25
    protected Bitmap[] mBmp= null; // 
26
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
27
    boolean[] mBitmapSet;          // 
28
 
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30
31
    protected void initializeData(int size)
32
      {
33
      mID             = DistortedObjectList.add(this);
34
      mSize           = size;
35
      mTextureDataH   = new int[1];
36
      mTextureDataH[0]= 0;
37
      mBmp            = new Bitmap[1];
38
      mBmp[0]         = null;
39
      mBitmapSet      = new boolean[1];
40
      mBitmapSet[0]   = false;
41
      
42
      initializeEffectLists(this,0);
43
      
44
      if( Distorted.isInitialized() ) resetTexture();    
45
      }
46
    
47
///////////////////////////////////////////////////////////////////////////////////////////////////
48
    
49
    protected void initializeEffectLists(DistortedObject d, int flags)
50
      {
51
      if( (flags & Distorted.CLONE_MATRIX) != 0 )
52
        {
53
        mM = d.mM;
54
        matrixCloned = true;
55
        } 
56
      else
57
        {
58
        mM = new EffectListMatrix(d);
59
        matrixCloned = false;  
60
        }
61
    
62
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
63
        {
64
        mV = d.mV;
65
        vertexCloned = true;
66
        } 
67
      else
68
        {
69
        mV = new EffectListVertex(d);
70
        vertexCloned = false;  
71
        }
72
    
73
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
74
        {
75
        mF = d.mF;
76
        fragmentCloned = true;
77
        } 
78
      else
79
        {
80
        mF = new EffectListFragment(d);
81
        fragmentCloned = false;   
82
        }
83
      }
84
    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86
// this will be called on startup and every time OpenGL context has been lost
87
// also call this from the constructor if the OpenGL context has been created already.
88
    
89
    void resetTexture()
90
      {
91
      if( mTextureDataH!=null ) 
92
        {
93
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
94
95
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
96
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
97
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
98
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
99
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
100
       
101
        if( mBmp!=null && mBmp[0]!=null)
102
          {
103
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
104
          mBmp[0] = null;
105
          }
106
        }
107
      }
108
  
109
///////////////////////////////////////////////////////////////////////////////////////////////////
110
   
111
    void drawPriv(long currTime, DistortedProjection dp)
112
      {
113
      GLES20.glViewport(0, 0, dp.width, dp.height); 
114
      
115
      mM.compute(currTime);
116
      mM.send(mViewMatrix, dp);
117
      
118
      mV.compute(currTime);
119
      mV.postprocess();
120
      mV.send();
121
        
122
      mF.compute(currTime);
123
      mF.postprocess(mViewMatrix);
124
      mF.send();
125
       
126
      mGrid.draw();
127
      }
128
129
///////////////////////////////////////////////////////////////////////////////////////////////////
130
   
131
    void drawNoEffectsPriv(DistortedProjection dp)
132
      {
133
      GLES20.glViewport(0, 0, dp.width, dp.height);
134
      mM.sendNoEffects(dp);
135
      mV.sendZero();
136
      mF.sendZero();
137
      mGrid.draw();
138
      }
139
    
140
///////////////////////////////////////////////////////////////////////////////////////////////////
141
   
142
    void releasePriv()
143
      {
144
      if( matrixCloned  ==false) mM.abortAll();
145
      if( vertexCloned  ==false) mV.abortAll();
146
      if( fragmentCloned==false) mF.abortAll();
147
148
      mBmp          = null;
149
      mGrid         = null;
150
      mM            = null;
151
      mV            = null;
152
      mF            = null;
153
      mTextureDataH = null;
154
      }
155
 
156
///////////////////////////////////////////////////////////////////////////////////////////////////
157
158
    long getBitmapID()
159
      {
160
      return mBmp==null ? 0 : mBmp.hashCode();
161
      }
162
163
///////////////////////////////////////////////////////////////////////////////////////////////////
164
/**
165
 * Draw the DistortedObject to the location specified by current Matrix effects.    
166
 *     
167
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
168
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
169
 *        Object.
170
 */
171
   public void draw(long currTime)
172
     {
173
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
174
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
175
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
176
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
177
      
178
     drawPriv(currTime, Distorted.mProjection);
179
     }
180
 
181
///////////////////////////////////////////////////////////////////////////////////////////////////
182
/**
183
 * Releases all resources.
184
 */
185
   public synchronized void release()
186
     {
187
     releasePriv();  
188
     DistortedObjectList.remove(this);
189
     }
190
191
///////////////////////////////////////////////////////////////////////////////////////////////////
192
/**
193
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
194
 * <p>
195
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
196
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
197
 * 
198
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
199
 */
200
   
201
   public void setBitmap(Bitmap bmp)
202
     {
203
     mBitmapSet[0] = true; 
204
      
205
     if( Distorted.isInitialized() )
206
       {
207
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
208
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
209
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
210
       }
211
     else
212
       {
213
       mBmp[0] = bmp;  
214
       }
215
     }
216
    
217
///////////////////////////////////////////////////////////////////////////////////////////////////
218
/**
219
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
220
 * to one of the Effects that are currently applied to the DistortedBitmap.
221
 * 
222
 * @param el A class implementing the EffectListener interface that wants to get notifications.
223
 */
224
   public void addEventListener(EffectListener el)
225
     {
226
     mV.addListener(el);
227
     mF.addListener(el);
228
     mM.addListener(el);
229
     }
230
231
///////////////////////////////////////////////////////////////////////////////////////////////////
232
/**
233
 * Removes the calling class from the list of Listeners.
234
 * 
235
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
236
 */
237
   public void removeEventListener(EffectListener el)
238
     {
239
     mV.removeListener(el);
240
     mF.removeListener(el);
241
     mM.removeListener(el);
242
     }
243
   
244
///////////////////////////////////////////////////////////////////////////////////////////////////
245
/**
246
 * Returns the height of the DistortedObject.
247
 *    
248
 * @return height of the object, in pixels.
249
 */
250
   public int getWidth()
251
     {
252
     return mSizeX;   
253
     }
254
255
///////////////////////////////////////////////////////////////////////////////////////////////////
256
/**
257
 * Returns the width of the DistortedObject.
258
 * 
259
 * @return width of the Object, in pixels.
260
 */
261
    public int getHeight()
262
      {
263
      return mSizeY;  
264
      }
265
    
266
///////////////////////////////////////////////////////////////////////////////////////////////////
267
/**
268
 * Returns the depth of the DistortedObject.
269
 * 
270
 * @return depth of the Object, in pixels.
271
 */
272
    public int getDepth()
273
      {
274
      return mSizeZ;  
275
      }
276
        
277
///////////////////////////////////////////////////////////////////////////////////////////////////
278
/**
279
 * Returns unique ID of this instance.
280
 * 
281
 * @return ID of the object.
282
 */
283
    public long getID()
284
      {
285
      return mID;  
286
      }
287
    
288
///////////////////////////////////////////////////////////////////////////////////////////////////
289
/**
290
 * Aborts all Effects. 
291
 */
292
    public void abortAllEffects()
293
      {
294
      mM.abortAll();
295
      mV.abortAll();
296
      mF.abortAll();
297
      }
298
299
///////////////////////////////////////////////////////////////////////////////////////////////////
300
/**
301
 * Aborts a subset of Effects.
302
 * 
303
 * @param mask Bitmask of the types of effects we want to abort, e.g. TYPE_MATR | TYPE_VERT | TYPE_FRAG.
304
 */
305
    public void abortAllEffects(int mask)
306
      {
307
      if( (mask & Distorted.TYPE_MATR) != 0 ) mM.abortAll();
308
      if( (mask & Distorted.TYPE_VERT) != 0 ) mV.abortAll();
309
      if( (mask & Distorted.TYPE_FRAG) != 0 ) mF.abortAll();
310
      }
311
    
312
///////////////////////////////////////////////////////////////////////////////////////////////////
313
/**
314
 * Aborts a single Effect.
315
 * 
316
 * @param id ID of the Effect we want to abort.
317
 * @return <code>true</code> if the Effect was found and successfully aborted.
318
 */
319
    public boolean abortEffect(long id)
320
      {
321
      switch( (int)(id&TYPE_MASK) )
322
        {
323
        case Distorted.TYPE_MATR: return mM.removeByID(id>>TYPE_NUM);
324
        case Distorted.TYPE_VERT: return mV.removeByID(id>>TYPE_NUM);
325
        case Distorted.TYPE_FRAG: return mF.removeByID(id>>TYPE_NUM);
326
        default                 : return false;
327
        }
328
      }
329
330
///////////////////////////////////////////////////////////////////////////////////////////////////
331
/**
332
 * Abort all Effects of a given type, for example all rotations.
333
 * 
334
 * @param effectType one of the constants defined in {@link EffectNames}
335
 * @return <code>true</code> if a single Effect of type effectType has been found and aborted. 
336
 */
337
    public boolean abortEffectType(EffectNames effectType)
338
      {
339
      switch(effectType.getType())
340
        {
341
        case Distorted.TYPE_MATR: return mM.removeByType(effectType);
342
        case Distorted.TYPE_VERT: return mV.removeByType(effectType);
343
        case Distorted.TYPE_FRAG: return mF.removeByType(effectType);
344
        default                 : return false;
345
        }
346
      }
347
    
348
///////////////////////////////////////////////////////////////////////////////////////////////////
349
/**
350
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
351
 * 
352
 * @param id Effect ID we want to print info about
353
 * @return <code>true</code> if a single Effect of type effectType has been found.
354
 */
355
    
356
    public boolean printEffect(long id)
357
      {
358
      switch( (int)(id&TYPE_MASK) )
359
        {
360
        case Distorted.TYPE_MATR: return mM.printByID(id>>TYPE_NUM);
361
        case Distorted.TYPE_VERT: return mV.printByID(id>>TYPE_NUM);
362
        case Distorted.TYPE_FRAG: return mF.printByID(id>>TYPE_NUM);
363
        default                 : return false;
364
        }
365
      }
366
   
367
///////////////////////////////////////////////////////////////////////////////////////////////////   
368
///////////////////////////////////////////////////////////////////////////////////////////////////
369
// Individual effect functions.
370
///////////////////////////////////////////////////////////////////////////////////////////////////
371
// Matrix-based effects
372
///////////////////////////////////////////////////////////////////////////////////////////////////
373
// MOVE
374
/**
375
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
376
 * 
377 d7bbef2f Leszek Koltunski
 * @param di 3-dimensional Interpolator which at any given time will return a Float3D
378 6a06a912 Leszek Koltunski
 *           representing the current coordinates of the vector we want to move the Object with.
379 d7bbef2f Leszek Koltunski
 * @return   ID of the effect added, or -1 if we failed to add one. 
380 6a06a912 Leszek Koltunski
 */
381
  public long move(Interpolator3D di)
382
    {   
383
    return mM.add(EffectNames.MOVE,null,di);  
384
    }
385
386
///////////////////////////////////////////////////////////////////////////////////////////////////
387
/**
388
 * Moves the Bitmap by a vector that smoothly changes from (0,0,0) to (x,y,z).
389
 *  
390 d7bbef2f Leszek Koltunski
 * @param x        The x-coordinate of the vector we want to move the Object with. 
391
 * @param y        The y-coordinate of the vector we want to move the Object with.
392
 * @param z        The z-coordinate of the vector we want to move the Object with.
393 6a06a912 Leszek Koltunski
 * @param duration The time, in milliseconds, it takes to complete the movement.
394 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
395 6a06a912 Leszek Koltunski
 */
396
  public long move(float x,float y,float z, int duration)
397
    {   
398
    Interpolator3D di = new Interpolator3D();  
399
    di.setCount(0.5f);
400
    di.setDuration(duration);
401
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
402
    di.add(new Float3D(x,y,z));                        
403
404
    return mM.add(EffectNames.MOVE,null,di);  
405
    }
406
407
///////////////////////////////////////////////////////////////////////////////////////////////////
408
/**
409
 * Moves the Bitmap by vector (x,y,z) immediately.
410
 *   
411
 * @param x The x-coordinate of the vector we want to move the Object with. 
412
 * @param y The y-coordinate of the vector we want to move the Object with.
413
 * @param z The z-coordinate of the vector we want to move the Object with.
414 d7bbef2f Leszek Koltunski
 * @return  ID of the effect added, or -1 if we failed to add one. 
415 6a06a912 Leszek Koltunski
 */
416
  public long move(float x,float y,float z)
417
    {   
418
    return mM.add(EffectNames.MOVE,0.0f,0.0f,0.0f,x,y,z,0.0f);  
419
    }
420
421
///////////////////////////////////////////////////////////////////////////////////////////////////
422
// SCALE
423
/**
424
 * Scales the Object by factors that change in time as returned by the Interpolator.
425
 * 
426 d7bbef2f Leszek Koltunski
 * @param di 3-dimensional Interpolator which at any given time returns a Float3D
427 6a06a912 Leszek Koltunski
 *           representing the current x- , y- and z- scale factors.
428 d7bbef2f Leszek Koltunski
 * @return   ID of the effect added, or -1 if we failed to add one. 
429 6a06a912 Leszek Koltunski
 */
430
  public long scale(Interpolator3D di)
431
    {   
432
    return mM.add(EffectNames.SCALE,null,di);  
433
    }
434
435
///////////////////////////////////////////////////////////////////////////////////////////////////
436
/**
437
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
438
 * after 'duration' milliseconds. 
439
 *    
440 d7bbef2f Leszek Koltunski
 * @param xscale   After time 'duration' passes, Bitmap's width will get multiplied by xscale; e.g. if 
441
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
442
 * @param yscale   Factor to scale Object's height with.
443
 * @param zscale   Factor to scale Object's depth with.
444 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
445 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
446 6a06a912 Leszek Koltunski
 */
447
  public long scale(float xscale,float yscale,float zscale, int duration)
448
    {   
449
    Interpolator3D di = new Interpolator3D();  
450
    di.setCount(0.5f);
451
    di.setDuration(duration);
452
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
453
    di.add(new Float3D(xscale,yscale,zscale));                        
454
455
    return mM.add(EffectNames.SCALE,null,di);  
456
    }
457
458
///////////////////////////////////////////////////////////////////////////////////////////////////
459
/**
460
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
461
 *   
462
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
463
 *               xscale=2, the Object immediately becomes twice broader.
464
 * @param yscale factor to scale Object's height with.
465
 * @param zscale factor to scale Object's depth with. 
466 d7bbef2f Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
467 6a06a912 Leszek Koltunski
 */
468
  public long scale(float xscale,float yscale,float zscale)
469
    {   
470
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,xscale,yscale,zscale,0.0f);  
471
    }
472
473
///////////////////////////////////////////////////////////////////////////////////////////////////
474
/**
475
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
476
 *   
477 d7bbef2f Leszek Koltunski
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
478 6a06a912 Leszek Koltunski
 *              scale=2, the Object immediately becomes twice larger.
479 d7bbef2f Leszek Koltunski
 * @return      ID of the effect added, or -1 if we failed to add one. 
480 6a06a912 Leszek Koltunski
 */
481
  public long scale(float scale)
482
    {   
483
    return mM.add(EffectNames.SCALE,0.0f,0.0f,0.0f,scale,scale,scale,0.0f);  
484
    }
485
    
486
///////////////////////////////////////////////////////////////////////////////////////////////////
487
// ROTATE
488
/**
489
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
490
 * 
491
 * @param i 3-dimensional Interpolator which at any given time will return the current center of 
492
 *          the rotation
493
 * @param v 4-dimensional Interpolator which at any given time will return a Float4D
494
 *          representing the current rotation in the (angle,axisX,axisY,axisY) form. 
495 d7bbef2f Leszek Koltunski
 * @return  ID of the effect added, or -1 if we failed to add one. 
496 6a06a912 Leszek Koltunski
 */
497
  public long rotate(Interpolator3D i, Interpolator4D v)
498
    {   
499
    return mM.add(EffectNames.ROTATE, i, v);  
500
    }
501
502
///////////////////////////////////////////////////////////////////////////////////////////////////  
503
/**
504
 * Rotates the Object around a static point, with angle and axis that change in time.
505
 * 
506 d7bbef2f Leszek Koltunski
 * @param point Center of the rotation
507
 * @param v     4-dimensional Interpolator which at any given time will return a Float4D
508
 *              representing the current rotation in the (angle,axisX,axisY,axisY) form. 
509
 * @return      ID of the effect added, or -1 if we failed to add one. 
510 6a06a912 Leszek Koltunski
 */
511
  public long rotate(Float3D point, Interpolator4D v)
512
    {   
513
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v);  
514
    }
515
  
516
///////////////////////////////////////////////////////////////////////////////////////////////////  
517
/**
518 d7bbef2f Leszek Koltunski
 * Rotates the Object around a static point, with angle that changes in time, around axis 
519
 * (axisX, axisY, axisZ). 
520 6a06a912 Leszek Koltunski
 * 
521 d7bbef2f Leszek Koltunski
 * @param point Center of the rotation
522
 * @param v     1-dimensional Interpolator which at any given time will return the current rotation 
523
 *              angle.
524
 * @param axisX Rotation vector: x-coordinate
525
 * @param axisY Rotation vector: y-coordinate         
526
 * @param axisZ Rotation vector: z-coordinate         
527
 * @return      ID of the effect added, or -1 if we failed to add one. 
528 6a06a912 Leszek Koltunski
 */
529
  public long rotate(Float3D point, Interpolator1D v, float axisX, float axisY, float axisZ)
530
    {   
531
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z , v, axisX, axisY, axisZ);  
532
    }
533
  
534
///////////////////////////////////////////////////////////////////////////////////////////////////
535
/**
536
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
537
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
538
 * 
539
 * @param i 3-dimensional Interpolator which at any given time will return the current center
540
 *          of the rotation.
541
 * @param a 1-dimensional Interpolator which returns the current rotation angle.         
542 d7bbef2f Leszek Koltunski
 * @return  ID of the effect added, or -1 if we failed to add one. 
543 6a06a912 Leszek Koltunski
 */
544
  public long rotate(Interpolator3D i, Interpolator1D a)
545
    {   
546
    return mM.add(EffectNames.ROTATE, i, a, 0.0f,0.0f,1.0f);  
547
    }
548
549
///////////////////////////////////////////////////////////////////////////////////////////////////
550
/**
551
 * Rotates the Object around a constant point, with angle that changes in time.  
552
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
553
 *   
554 d7bbef2f Leszek Koltunski
 * @param point    Coordinates of the Point we are rotating around.
555
 * @param angle    Angle that we want to rotate the Bitmap to. Unit: degrees
556 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
557 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
558 6a06a912 Leszek Koltunski
 */
559
  public long rotate(Float3D point, int angle, int duration)
560
    {   
561
    Interpolator1D di = new Interpolator1D();  
562
    di.setCount(0.5f);
563
    di.setDuration(duration);
564
    di.add(new Float1D(    0));                             
565
    di.add(new Float1D(angle));                        
566
567
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z, di, 0.0f,0.0f,1.0f);  
568
    }
569
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571
/**
572
 * Rotates the Object immediately by 'angle' degrees around point p.   
573
 * Axis of rotation is given by the last 3 floats.
574
 *   
575 d7bbef2f Leszek Koltunski
 * @param point Coordinates of the Point we are rotating around.
576
 * @param angle Angle that we want to rotate the Bitmap to. Unit: degrees
577
 * @param axisX Axis of rotation: x-coordinate
578
 * @param axisY Axis of rotation: y-coordinate
579
 * @param axisZ Axis of rotation: z-coordinate
580
 * @return      ID of the effect added, or -1 if we failed to add one. 
581 6a06a912 Leszek Koltunski
 */
582
  public long rotate(Float3D point, float angle, float axisX, float axisY, float axisZ)
583
    {   
584
    return mM.add(EffectNames.ROTATE, point.x, point.y, point.z, angle, axisX, axisY, axisZ);  
585
    }
586
  
587
///////////////////////////////////////////////////////////////////////////////////////////////////
588
/**
589
 * Rotates the Object immediately by 'angle' degrees around point p.   
590
 *   
591 d7bbef2f Leszek Koltunski
 * @param point  Coordinates of the Point we are rotating around.
592
 * @param angle  The angle that we want to rotate the Bitmap to. Unit: degrees
593 6a06a912 Leszek Koltunski
 * @return       ID of the effect added, or -1 if we failed to add one. 
594
 */
595
  public long rotate(Float3D point, int angle)
596
    {   
597
    return mM.add(EffectNames.ROTATE,point.x,point.y,point.z,angle,0.0f,0.0f,1.0f);  
598
    }
599
600
///////////////////////////////////////////////////////////////////////////////////////////////////
601
// QUATERNION
602
/**
603
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
604
 *   
605 d7bbef2f Leszek Koltunski
 * @param point Coordinates of the Point we are rotating around.
606
 * @param qX    Quaternion: x-coordinate
607
 * @param qY    Quaternion: y-coordinate
608
 * @param qZ    Quaternion: z-coordinate
609
 * @param qW    Quaternion: w-coordinate
610
 * @return      ID of the effect added, or -1 if we failed to add one. 
611 6a06a912 Leszek Koltunski
 */
612
  public long quaternion(Float3D point, float qX, float qY, float qZ, float qW)
613
    {   
614
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,qX,qY,qZ,qW);   
615
    }
616
617
///////////////////////////////////////////////////////////////////////////////////////////////////
618
/**
619
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
620
 *   
621 d7bbef2f Leszek Koltunski
 * @param point Coordinates of the Point we are rotating around.
622
 * @param iq    Interpolator that's going to, at any given moment, return a quaternion.
623
 * @return      ID of the effect added, or -1 if we failed to add one. 
624 6a06a912 Leszek Koltunski
 */
625
  public long quaternion(Float3D point, InterpolatorQuat iq)
626
    {   
627
    return mM.add(EffectNames.QUATERNION,point.x,point.y,point.z,iq);  
628
    }
629
630
///////////////////////////////////////////////////////////////////////////////////////////////////
631
/**
632
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
633
 *   
634 d7bbef2f Leszek Koltunski
 * @param i  Interpolator that returns the current center of rotation.
635 6a06a912 Leszek Koltunski
 * @param iq Interpolator that's going to, at any given moment, return a quaternion representing the current rotation.
636 d7bbef2f Leszek Koltunski
 * @return   ID of the effect added, or -1 if we failed to add one. 
637 6a06a912 Leszek Koltunski
 */
638
  public long quaternion(Interpolator3D i, InterpolatorQuat iq)
639
    {   
640
    return mM.add(EffectNames.QUATERNION,i,iq);  
641
    }
642
  
643
///////////////////////////////////////////////////////////////////////////////////////////////////
644
// SHEAR
645
/**
646
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
647
 * shearing along the Y-axis, 3D one along Z axis.
648
 *
649 d7bbef2f Leszek Koltunski
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
650
 * @param di     1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2- 
651
 *               or 3-tuple of shear factors.
652
 * @return       ID of the effect added, or -1 if we failed to add one. 
653 6a06a912 Leszek Koltunski
 */
654
  public long shear(Float3D point, Interpolator di)
655
    {
656
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di);  
657
    }
658
659
///////////////////////////////////////////////////////////////////////////////////////////////////
660
/**
661
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
662
 * 
663 d7bbef2f Leszek Koltunski
 * @param point  Center of shearing, i.e. the point which stays unmoved. 
664
 * @param vector ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with 
665
 *               which the X,Y and Z axis get slanted) 
666
 * @return       ID of the effect added, or -1 if we failed to add one. 
667 6a06a912 Leszek Koltunski
 */
668
  public long shear(Float3D point, Float3D vector)
669
    {
670
    Interpolator3D di = new Interpolator3D(); 
671
    di.setCount(0.5f);
672
    di.setDuration(0);
673
    di.add(new Float3D(0.0f,0.0f,0.0f));              
674
    di.add(vector);                                                
675
        
676
    return mM.add(EffectNames.SHEAR, point.x, point.y, point.z, di );  
677
    }
678
679
///////////////////////////////////////////////////////////////////////////////////////////////////
680
// Fragment-based effects  
681
///////////////////////////////////////////////////////////////////////////////////////////////////
682
// MACROBLOCK
683
/**
684
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
685
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
686
 * 
687 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
688
 * @param region Region this Effect is limited to.
689
 *               Null here means 'apply the effect to the whole Bitmap'.
690
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
691
 *               current center of the effect.
692
 * @return       ID of the effect added, or -1 if we failed to add one. 
693 6a06a912 Leszek Koltunski
 */
694
  public long macroblock(Interpolator1D a, Float4D region, Interpolator2D i)
695
    {
696
    return mF.add(EffectNames.MACROBLOCK, a, region, i);
697
    }
698
699
///////////////////////////////////////////////////////////////////////////////////////////////////
700
/**
701
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
702
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
703
 * <p>
704
 * The difference between this and the previous method is that here the center of the Effect stays constant.
705
 *    
706 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
707
 * @param region Region this Effect is limited to. 
708
 *               Null here means 'apply the effect to the whole Bitmap'.
709
 * @param point  Center of the Effect.
710
 * @return       ID of the effect added, or -1 if we failed to add one. 
711 6a06a912 Leszek Koltunski
 */
712
  public long macroblock(Interpolator1D a, Float4D region, Float2D point)
713
    {
714
    return mF.add(EffectNames.MACROBLOCK, a, region, point.x, point.y);
715
    }
716
  
717
///////////////////////////////////////////////////////////////////////////////////////////////////
718
/**
719
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
720
 * <p>
721
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
722
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
723
 * size is 1X1, i.e. 1 pixel).   
724
 * 
725 d7bbef2f Leszek Koltunski
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
726
 * @param region   Region this Effect is limited to. 
727
 *                 Null here means 'apply the effect to the whole Bitmap'.
728
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D representing the
729
 *                 current center of the effect.
730 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
731 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
732
 * @return         ID of the effect added, or -1 if we failed to add one. 
733 6a06a912 Leszek Koltunski
 */
734
  public long macroblock(int pixels, Float4D region, Interpolator2D i, int duration, float count)
735
    {
736
    Interpolator1D di = new Interpolator1D();
737
    di.setCount(count);
738
    di.setDuration(duration);
739
    di.add(new Float1D(1));                             
740
    di.add(new Float1D(pixels));                        
741
742
    return mF.add(EffectNames.MACROBLOCK, di, region, i);
743
    }
744
745
///////////////////////////////////////////////////////////////////////////////////////////////////
746
/**
747
 * Creates macroblocks at and around point defined by the Point2D and the Region. 
748
 * <p>
749
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
750
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
751
 * size is 1X1, i.e. 1 pixel).   
752
 * <p>
753
 * The difference between this and the previous method is that here the center of the Effect stays constant.
754
 *    
755 d7bbef2f Leszek Koltunski
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
756
 * @param region   Region this Effect is limited to. 
757
 *                 Null here means 'apply the effect to the whole Bitmap'.
758
 * @param point    Center of the Effect.
759 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
760 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
761
 * @return         ID of the effect added, or -1 if we failed to add one. 
762 6a06a912 Leszek Koltunski
 */
763
  public long macroblock(int pixels, Float4D region, Float2D point, int duration, float count)
764
    {
765
    Interpolator1D di = new Interpolator1D();
766
    di.setCount(count);
767
    di.setDuration(duration);
768
    di.add(new Float1D(1));                             
769
    di.add(new Float1D(pixels));                        
770
771
    return mF.add(EffectNames.MACROBLOCK, di, region, point.x, point.y);
772
    }
773
774
///////////////////////////////////////////////////////////////////////////////////////////////////
775
/**
776
 * Creates macroblocks on the whole Bitmap. 
777
 * <p>
778
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
779
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
780
 * size is 1X1, i.e. 1 pixel).   
781
 * <p>
782
 * The difference between this and the previous method is that here there is no masking Region; thus
783
 * there is also no center of the Effect. 
784
 *    
785 d7bbef2f Leszek Koltunski
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
786 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
787 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
788
 * @return         ID of the effect added, or -1 if we failed to add one. 
789 6a06a912 Leszek Koltunski
 */
790
  public long macroblock(int pixels, int duration, float count) 
791
    {
792
    Interpolator1D di = new Interpolator1D(); 
793
    di.setCount(count);
794
    di.setDuration(duration);
795
    di.add(new Float1D(1));                            
796
    di.add(new Float1D(pixels));                        
797
   
798
    return mF.add(EffectNames.MACROBLOCK, di, null, 0.0f, 0.0f);
799
    }
800
801
///////////////////////////////////////////////////////////////////////////////////////////////////
802
///////////////////////////////////////////////////////////////////////////////////////////////////
803
// CHROMA
804
/**
805
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
806
 *        
807 d7bbef2f Leszek Koltunski
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be
808
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
809
 * @param color  Color to mix.         
810
 * @param region Region this Effect is limited to. 
811
 *               Null here means 'apply the Effect to the whole Bitmap'.
812
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing 
813
 *               the current center of the effect.
814
 * @return       ID of the effect added, or -1 if we failed to add one. 
815 6a06a912 Leszek Koltunski
 */
816
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
817
    {
818
    return mF.add(EffectNames.CHROMA, t, color, region, i);
819
    }
820
821
///////////////////////////////////////////////////////////////////////////////////////////////////
822
/**
823
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
824
 * <p>
825
 * Here the center of the Effect stays constant.
826
 *         
827 d7bbef2f Leszek Koltunski
 * @param t      1-dimensional Interpolator that returns the level of blend a given pixel will be 
828
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
829
 * @param color  Color to mix.         
830
 * @param region Region this Effect is limited to. 
831
 *               Null here means 'apply the Effect to the whole Bitmap'.
832
 * @param point  Center of the Effect.
833
 * @return       ID of the effect added, or -1 if we failed to add one. 
834 6a06a912 Leszek Koltunski
 */
835
  public long chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
836
    {
837
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
838
    }
839
840
///////////////////////////////////////////////////////////////////////////////////////////////////  
841
/**
842
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
843
 *        
844 d7bbef2f Leszek Koltunski
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
845
 *               pixel = (1-t)*pixel + t*color
846
 * @param color  Color to mix.       
847
 * @param region Region this Effect is limited to.
848
 *               Null here means 'apply the Effect to the whole Bitmap'.
849
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
850
 *               current center of the effect.
851
 * @return       ID of the effect added, or -1 if we failed to add one. 
852 6a06a912 Leszek Koltunski
 */
853
  public long chroma(float t, Float3D color, Float4D region, Interpolator2D i)
854
    {
855
    return mF.add(EffectNames.CHROMA, t, color, region, i);
856
    }
857
858 d7bbef2f Leszek Koltunski
///// //////////////////////////////////////////////////////////////////////////////////////////////
859 6a06a912 Leszek Koltunski
/**
860
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
861
 * <p>
862
 * Here the center of the Effect stays constant.
863
 *         
864 d7bbef2f Leszek Koltunski
 * @param t      Level of blend a given pixel will be mixed with the next parameter 'color': 
865
 *               pixel = (1-t)*pixel + t*color
866
 * @param color  Color to mix.       
867
 * @param region The Region this Effect is limited to. 
868
 *               Null here means 'apply the Effect to the whole Bitmap'.
869
 * @param point  Center of the Effect.
870
 * @return       ID of the effect added, or -1 if we failed to add one. 
871 6a06a912 Leszek Koltunski
 */
872
  public long chroma(float t, Float3D color, Float4D region, Float2D point)
873
    {
874
    return mF.add(EffectNames.CHROMA, t, color, region, point.x, point.y);
875
    }
876
877
///////////////////////////////////////////////////////////////////////////////////////////////////
878
/**
879
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
880
 * <p>
881
 * Here the Effect applies to the whole bitmap.
882
 *         
883 d7bbef2f Leszek Koltunski
 * @param t     Level of blend a given pixel will be mixed with the next parameter 'color': 
884
 *              pixel = (1-t)*pixel + t*color
885
 * @param color Color to mix.       
886
 * @return      ID of the effect added, or -1 if we failed to add one. 
887 6a06a912 Leszek Koltunski
 */
888
  public long chroma(float t, Float3D color)
889
    {
890
    return mF.add(EffectNames.CHROMA, t, color, null, 0, 0);
891
    }
892
893
///////////////////////////////////////////////////////////////////////////////////////////////////  
894
/**
895
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
896
 * 
897
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
898
 */
899
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Interpolator2D i)
900
    {
901
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
902
    }
903
904
///////////////////////////////////////////////////////////////////////////////////////////////////
905
/**
906
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
907
 * 
908
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
909
 */
910
  public long smooth_chroma(Interpolator1D t, Float3D color, Float4D region, Float2D point)
911
    {
912
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
913
    }
914
  
915
///////////////////////////////////////////////////////////////////////////////////////////////////  
916
/**
917
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
918
 * 
919
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
920
 */
921
  public long smooth_chroma(float t, Float3D color, Float4D region, Interpolator2D i)
922
    {
923
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, i);
924
    }
925
926
///////////////////////////////////////////////////////////////////////////////////////////////////
927
/**
928
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
929
 * 
930
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
931
 */
932
  public long smooth_chroma(float t, Float3D color, Float4D region, Float2D point)
933
    {
934
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, region, point.x, point.y);
935
    }
936
  
937
///////////////////////////////////////////////////////////////////////////////////////////////////
938
/**
939
 * Makes a certain sub-region of the Bitmap smoothly change all three of its RGB components.
940
 * 
941
 * See {@link #chroma(float, Float3D)}
942
 */
943
  public long smooth_chroma(float t, Float3D color)
944
    {
945
    return mF.add(EffectNames.SMOOTH_CHROMA, t, color, null, 0, 0);
946
    }
947
  
948
///////////////////////////////////////////////////////////////////////////////////////////////////
949
///////////////////////////////////////////////////////////////////////////////////////////////////
950
// ALPHA
951
/**
952
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
953
 *        
954 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
955
 *               moment.
956
 * @param region Region this Effect is limited to. 
957
 *               Null here means 'apply the Effect to the whole Bitmap'.
958
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
959
 *               current center of the effect.
960
 * @return       ID of the effect added, or -1 if we failed to add one. 
961 6a06a912 Leszek Koltunski
 */
962
  public long alpha(Interpolator1D a, Float4D region, Interpolator2D i)
963
    {
964
    return mF.add(EffectNames.ALPHA, a, region, i);
965
    }
966
967
///////////////////////////////////////////////////////////////////////////////////////////////////
968
/**
969
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
970
 * <p>
971
 * Here the center of the Effect stays constant.
972
 *         
973 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of transparency we want to have at any given 
974
 *               moment.
975
 * @param region Region this Effect is limited to. 
976
 *               Null here means 'apply the Effect to the whole Bitmap'.
977
 * @param point  Center of the Effect.
978
 * @return       ID of the effect added, or -1 if we failed to add one. 
979 6a06a912 Leszek Koltunski
 */
980
  public long alpha(Interpolator1D a, Float4D region, Float2D point)
981
    {
982
    return mF.add(EffectNames.ALPHA, a, region, point.x, point.y);
983
    }
984
985
///////////////////////////////////////////////////////////////////////////////////////////////////  
986
/**
987
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
988
 *        
989 d7bbef2f Leszek Koltunski
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
990
 * @param region Region this Effect is limited to. 
991
 *               Null here means 'apply the Effect to the whole Bitmap'.
992
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
993
 *               current center of the effect.
994 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
995 d7bbef2f Leszek Koltunski
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
996
 * @return       ID of the effect added, or -1 if we failed to add one. 
997 6a06a912 Leszek Koltunski
 */
998
  public long alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
999
    {
1000
    Interpolator1D di = new Interpolator1D(); 
1001
    di.setCount(count);
1002
    di.setDuration(duration);
1003
    di.add(new Float1D(1));                          
1004
    di.add(new Float1D(alpha));                         
1005
   
1006
    return mF.add(EffectNames.ALPHA, di, region, i);
1007
    }
1008
1009
///////////////////////////////////////////////////////////////////////////////////////////////////
1010
/**
1011
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1012
 * <p>
1013
 * Here the center of the Effect stays constant.
1014
 *         
1015 d7bbef2f Leszek Koltunski
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1016
 * @param region Region this Effect is limited to. 
1017
 *               Null here means 'apply the Effect to the whole Bitmap'.
1018
 * @param point  Center of the Effect.
1019 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1020 d7bbef2f Leszek Koltunski
 * @param count  Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1021
 * @return       ID of the effect added, or -1 if we failed to add one. 
1022 6a06a912 Leszek Koltunski
 */
1023
  public long alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1024
    {
1025
    Interpolator1D di = new Interpolator1D(); 
1026
    di.setCount(count);
1027
    di.setDuration(duration);
1028
    di.add(new Float1D(1));                          
1029
    di.add(new Float1D(alpha));                         
1030
   
1031
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1032
    }
1033
1034
///////////////////////////////////////////////////////////////////////////////////////////////////
1035
/**
1036
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1037
 * <p>
1038
 * Here the center of the Effect stays constant and the effect for now change in time.
1039
 *         
1040 d7bbef2f Leszek Koltunski
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1041
 * @param region Region this Effect is limited to.
1042
 *               Null here means 'apply the Effect to the whole Bitmap'.
1043
 * @param point  Center of the Effect.
1044
 * @return       ID of the effect added, or -1 if we failed to add one. 
1045 6a06a912 Leszek Koltunski
 */
1046
  public long alpha(float alpha, Float4D region, Float2D point)
1047
    {
1048
    Interpolator1D di = new Interpolator1D(); 
1049
    di.setCount(0.5f);
1050
    di.setDuration(0);
1051
    di.add(new Float1D(1));                          
1052
    di.add(new Float1D(alpha));                         
1053
   
1054
    return mF.add(EffectNames.ALPHA, di, region, point.x, point.y);
1055
    }
1056
  
1057
///////////////////////////////////////////////////////////////////////////////////////////////////
1058
/**
1059
 * Makes the whole Bitmap change its transparency level.
1060
 * 
1061 d7bbef2f Leszek Koltunski
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1062 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1063 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1064
 * @return         ID of the effect added, or -1 if we failed to add one. 
1065 6a06a912 Leszek Koltunski
 */
1066
  public long alpha(float alpha, int duration, float count) 
1067
    {
1068
    Interpolator1D di = new Interpolator1D(); 
1069
    di.setCount(count);
1070
    di.setDuration(duration);
1071
    di.add(new Float1D(1));                            
1072
    di.add(new Float1D(alpha));                        
1073
         
1074
    return mF.add(EffectNames.ALPHA, di,null, 0.0f, 0.0f);
1075
    }
1076
1077
///////////////////////////////////////////////////////////////////////////////////////////////////  
1078
/**
1079
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1080
 * 
1081
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1082
 */
1083
  public long smooth_alpha(Interpolator1D a, Float4D region, Interpolator2D i)
1084
    {
1085
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, i);
1086
    }
1087
1088
///////////////////////////////////////////////////////////////////////////////////////////////////
1089
/**
1090
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1091
 * 
1092 da7ce0d8 LeszekKoltunski
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1093 6a06a912 Leszek Koltunski
 */
1094
  public long smooth_alpha(Interpolator1D a, Float4D region, Float2D point)
1095
    {
1096
    return mF.add(EffectNames.SMOOTH_ALPHA, a, region, point.x, point.y);
1097
    }
1098
  
1099
///////////////////////////////////////////////////////////////////////////////////////////////////  
1100
/**
1101
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1102
 * 
1103 da7ce0d8 LeszekKoltunski
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1104 6a06a912 Leszek Koltunski
 */
1105
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D i, int duration, float count)
1106
    {
1107
    Interpolator1D di = new Interpolator1D(); 
1108
    di.setCount(count);
1109
    di.setDuration(duration);
1110
    di.add(new Float1D(1));                          
1111
    di.add(new Float1D(alpha));                         
1112
   
1113
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, i);
1114
    }
1115
1116
///////////////////////////////////////////////////////////////////////////////////////////////////
1117
/**
1118
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1119
 * 
1120 da7ce0d8 LeszekKoltunski
 * See {@link #alpha(float, Float4D, Float2D, int, float)}
1121 6a06a912 Leszek Koltunski
 */
1122
  public long smooth_alpha(float alpha, Float4D region, Float2D point, int duration, float count)
1123
    {
1124
    Interpolator1D di = new Interpolator1D(); 
1125
    di.setCount(count);
1126
    di.setDuration(duration);
1127
    di.add(new Float1D(1));                          
1128
    di.add(new Float1D(alpha));                         
1129
   
1130
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1131
    }
1132
  
1133
///////////////////////////////////////////////////////////////////////////////////////////////////
1134
/**
1135
 * Makes a certain sub-region of the Bitmap smoothly change its transparency level.
1136
 * 
1137 da7ce0d8 LeszekKoltunski
 * See {@link #alpha(float, Float4D, Float2D)}
1138 6a06a912 Leszek Koltunski
 */
1139
  public long smooth_alpha(float alpha, Float4D region, Float2D point)
1140
    {
1141
    Interpolator1D di = new Interpolator1D(); 
1142
    di.setCount(0.5f);
1143
    di.setDuration(0);
1144
    di.add(new Float1D(1));                          
1145
    di.add(new Float1D(alpha));                         
1146
   
1147
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, point.x, point.y);
1148
    }
1149
  
1150
///////////////////////////////////////////////////////////////////////////////////////////////////
1151
///////////////////////////////////////////////////////////////////////////////////////////////////
1152
// BRIGHTNESS
1153
/**
1154
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1155
 *        
1156 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1157
 *               moment.
1158
 * @param region Region this Effect is limited to. 
1159
 *               Null here means 'apply the Effect to the whole Bitmap'.
1160
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1161
 *               current center of the effect.
1162
 * @return       ID of the effect added, or -1 if we failed to add one. 
1163 6a06a912 Leszek Koltunski
 */
1164
  public long brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1165
    {
1166
    return mF.add(EffectNames.BRIGHTNESS, a, region, i);
1167
    }
1168
1169
///////////////////////////////////////////////////////////////////////////////////////////////////
1170
/**
1171
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1172
 * <p>
1173
 * Here the center of the Effect stays constant.
1174
 *         
1175 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at any given 
1176
 *               moment.
1177
 * @param region Region this Effect is limited to.
1178
 *               Null here means 'apply the Effect to the whole Bitmap'.
1179
 * @param point  Center of the Effect.
1180
 * @return       ID of the effect added, or -1 if we failed to add one. 
1181 6a06a912 Leszek Koltunski
 */
1182
  public long brightness(Interpolator1D a, Float4D region, Float2D point)
1183
    {
1184
    return mF.add(EffectNames.BRIGHTNESS, a, region, point.x, point.y);
1185
    }
1186
1187
///////////////////////////////////////////////////////////////////////////////////////////////////  
1188
/**
1189
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1190
 *        
1191 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1192
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1193
 *                   anything more than 1- lighten it up. 
1194
 * @param region     Region this Effect is limited to.
1195
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1196
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1197
 *                   representing the current center of the effect.
1198
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1199
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1200
 * @return           ID of the effect added, or -1 if we failed to add one. 
1201 6a06a912 Leszek Koltunski
 */
1202
  public long brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1203
    {
1204
    Interpolator1D di = new Interpolator1D(); 
1205
    di.setCount(count);
1206
    di.setDuration(duration);
1207
    di.add(new Float1D(1));                          
1208
    di.add(new Float1D(brightness));                         
1209
   
1210
    return mF.add(EffectNames.BRIGHTNESS, di, region, i);
1211
    }
1212
1213
///////////////////////////////////////////////////////////////////////////////////////////////////
1214
/**
1215
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1216
 * <p>
1217
 * Here the center of the Effect stays constant.
1218
 *         
1219 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1220
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1221
 *                   anything more than 1 - lighten it up.
1222
 * @param region     Region this Effect is limited to. 
1223
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1224
 * @param point      Center of the Effect.
1225
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1226
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1227
 * @return           ID of the effect added, or -1 if we failed to add one. 
1228 6a06a912 Leszek Koltunski
 */
1229
  public long brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1230
    {
1231
    Interpolator1D di = new Interpolator1D(); 
1232
    di.setCount(count);
1233
    di.setDuration(duration);
1234
    di.add(new Float1D(1));                          
1235
    di.add(new Float1D(brightness));                         
1236
   
1237
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1238
    }
1239
1240
///////////////////////////////////////////////////////////////////////////////////////////////////
1241
/**
1242
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1243
 * <p>
1244
 * Here the center of the Effect stays constant and the effect for now change in time.
1245
 *         
1246 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1247
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1248
 *                   anything more than 1 - lighten it up.
1249
 * @param region     Region this Effect is limited to.
1250
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1251
 * @param point      Center of the Effect.
1252
 * @return           ID of the effect added, or -1 if we failed to add one. 
1253 6a06a912 Leszek Koltunski
 */
1254
  public long brightness(float brightness, Float4D region, Float2D point)
1255
    {
1256
    Interpolator1D di = new Interpolator1D(); 
1257
    di.setCount(0.5f);
1258
    di.setDuration(0);
1259
    di.add(new Float1D(1));                          
1260
    di.add(new Float1D(brightness));                         
1261
   
1262
    return mF.add(EffectNames.BRIGHTNESS, di, region, point.x, point.y);
1263
    }
1264
 
1265
///////////////////////////////////////////////////////////////////////////////////////////////////
1266
///////////////////////////////////////////////////////////////////////////////////////////////////
1267
// SMOOTH BRIGHTNESS
1268
/**
1269
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1270
 *        
1271 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1272
 *               any given moment.
1273
 * @param region Region this Effect is limited to. 
1274
 *               Null here means 'apply the Effect to the whole Bitmap'.
1275
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1276
 *               representing the current center of the effect.
1277
 * @return       ID of the effect added, or -1 if we failed to add one. 
1278 6a06a912 Leszek Koltunski
 */
1279
  public long smooth_brightness(Interpolator1D a, Float4D region, Interpolator2D i)
1280
    {
1281
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, i);
1282
    }
1283
1284
///////////////////////////////////////////////////////////////////////////////////////////////////
1285
/**
1286
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1287
 * <p>
1288
 * Here the center of the Effect stays constant.
1289
 *         
1290 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of brightness we want to have at
1291
 *               any given moment.
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
 * @return       ID of the effect added, or -1 if we failed to add one. 
1296 6a06a912 Leszek Koltunski
 */
1297
  public long smooth_brightness(Interpolator1D a, Float4D region, Float2D point)
1298
    {
1299
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, a, region, point.x, point.y);
1300
    }
1301
1302
///////////////////////////////////////////////////////////////////////////////////////////////////  
1303
/**
1304
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1305
 *        
1306 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1307
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1308
 *                   anything more than 1 - lighten it up. 
1309
 * @param region     Region this Effect is limited to. 
1310
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1311
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1312
 *                   represention the current center of the effect.
1313
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1314
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1315
 * @return           ID of the effect added, or -1 if we failed to add one. 
1316 6a06a912 Leszek Koltunski
 */
1317
  public long smooth_brightness(float brightness, Float4D region, Interpolator2D i, int duration, float count)
1318
    {
1319
    Interpolator1D di = new Interpolator1D(); 
1320
    di.setCount(count);
1321
    di.setDuration(duration);
1322
    di.add(new Float1D(1));                          
1323
    di.add(new Float1D(brightness));                         
1324
   
1325
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, i);
1326
    }
1327
1328
///////////////////////////////////////////////////////////////////////////////////////////////////
1329
/**
1330
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1331
 * <p>
1332
 * Here the center of the Effect stays constant.
1333
 *         
1334 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1335
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1336
 *                   anything more than 1 - lighten it up.
1337
 * @param region     Region this Effect is limited to. 
1338
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1339
 * @param point      Center of the Effect.
1340
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1341
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1342
 * @return           ID of the effect added, or -1 if we failed to add one. 
1343 6a06a912 Leszek Koltunski
 */
1344
  public long smooth_brightness(float brightness, Float4D region, Float2D point, int duration, float count)
1345
    {
1346
    Interpolator1D di = new Interpolator1D(); 
1347
    di.setCount(count);
1348
    di.setDuration(duration);
1349
    di.add(new Float1D(1));                          
1350
    di.add(new Float1D(brightness));                         
1351
   
1352
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1353
    }
1354
1355
///////////////////////////////////////////////////////////////////////////////////////////////////
1356
/**
1357
 * Makes a certain sub-region of the Bitmap smoothly change its brightness level.
1358
 * <p>
1359
 * Here the center of the Effect stays constant and the effect for now change in time.
1360
 *         
1361 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1362
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1363
 *                   anything more than 1 - lighten it up.
1364
 * @param region     Region this Effect is limited to. 
1365
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1366
 * @param point      Center of the Effect.
1367
 * @return           ID of the effect added, or -1 if we failed to add one. 
1368 6a06a912 Leszek Koltunski
 */
1369
  public long smooth_brightness(float brightness, Float4D region, Float2D point)
1370
    {
1371
    Interpolator1D di = new Interpolator1D(); 
1372
    di.setCount(0.5f);
1373
    di.setDuration(0);
1374
    di.add(new Float1D(1));                          
1375
    di.add(new Float1D(brightness));                         
1376
   
1377
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, point.x, point.y);
1378
    }
1379
    
1380
///////////////////////////////////////////////////////////////////////////////////////////////////
1381
/**
1382
 * Makes the whole Bitmap change its brightness level.
1383
 * 
1384 d7bbef2f Leszek Koltunski
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1385
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1386
 *                   anything more than 1- lighten it up.
1387
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1388
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1389
 * @return           ID of the effect added, or -1 if we failed to add one. 
1390 6a06a912 Leszek Koltunski
 */
1391
  public long smooth_brightness(float brightness, int duration, float count) 
1392
    {
1393
    Interpolator1D di = new Interpolator1D(); 
1394
    di.setCount(count);
1395
    di.setDuration(duration);
1396
    di.add(new Float1D(1));                            
1397
    di.add(new Float1D(brightness));                        
1398
         
1399
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, 0.0f, 0.0f);
1400
    }
1401
1402
///////////////////////////////////////////////////////////////////////////////////////////////////
1403
///////////////////////////////////////////////////////////////////////////////////////////////////
1404
// CONTRAST
1405
/**
1406
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1407
 *        
1408 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1409
 *               at any given moment.
1410
 * @param region Region this Effect is limited to. 
1411
 *               Null here means 'apply the Effect to the whole Bitmap'.
1412
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1413
 *               representing the current center of the effect.
1414
 * @return       ID of the effect added, or -1 if we failed to add one. 
1415 6a06a912 Leszek Koltunski
 */
1416
  public long contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1417
    {
1418
    return mF.add(EffectNames.CONTRAST, a, region, i);
1419
    }
1420
1421
///////////////////////////////////////////////////////////////////////////////////////////////////
1422
/**
1423
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1424
 * <p>
1425
 * Here the center of the Effect stays constant.
1426
 *         
1427 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1428
 *               at any given moment.
1429
 * @param region Region this Effect is limited to.
1430
 *               Null here means 'apply the Effect to the whole Bitmap'.
1431
 * @param point  Center of the Effect.
1432
 * @return       ID of the effect added, or -1 if we failed to add one. 
1433 6a06a912 Leszek Koltunski
 */
1434
  public long contrast(Interpolator1D a, Float4D region, Float2D point)
1435
    {
1436
    return mF.add(EffectNames.CONTRAST, a, region, point.x, point.y);
1437
    }
1438
1439
///////////////////////////////////////////////////////////////////////////////////////////////////  
1440
/**
1441
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1442
 *        
1443 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1444
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1445
 *                 anything more than 1 - increase the contrast. 
1446
 * @param region   Region this Effect is limited to.
1447
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1448
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1449
 *                 represention the current center of the effect.
1450 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1451 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1452
 * @return         ID of the effect added, or -1 if we failed to add one. 
1453 6a06a912 Leszek Koltunski
 */
1454
  public long contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1455
    {
1456
    Interpolator1D di = new Interpolator1D(); 
1457
    di.setCount(count);
1458
    di.setDuration(duration);
1459
    di.add(new Float1D(1));                          
1460
    di.add(new Float1D(contrast));                         
1461
   
1462
    return mF.add(EffectNames.CONTRAST, di, region, i);
1463
    }
1464
1465
///////////////////////////////////////////////////////////////////////////////////////////////////
1466
/**
1467
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1468
 * <p>
1469
 * Here the center of the Effect stays constant.
1470
 *         
1471 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1472
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1473
 *                 anything more than 1 -increase the contrast. 
1474
 * @param region   Region this Effect is limited to. 
1475
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1476
 * @param point    Center of the Effect.
1477 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1478 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1479
 * @return         ID of the effect added, or -1 if we failed to add one. 
1480 6a06a912 Leszek Koltunski
 */
1481
  public long contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1482
    {
1483
    Interpolator1D di = new Interpolator1D(); 
1484
    di.setCount(count);
1485
    di.setDuration(duration);
1486
    di.add(new Float1D(1));                          
1487
    di.add(new Float1D(contrast));                         
1488
   
1489
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1490
    }
1491
1492
///////////////////////////////////////////////////////////////////////////////////////////////////
1493
/**
1494
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1495
 * <p>
1496
 * Here the center of the Effect stays constant and the effect for now change in time.
1497
 *         
1498 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1499
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1500
 *                 anything more than 1 - increase the contrast. 
1501
 * @param region   Region this Effect is limited to. 
1502
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1503
 * @param point    Center of the Effect.
1504
 * @return         ID of the effect added, or -1 if we failed to add one. 
1505 6a06a912 Leszek Koltunski
 */
1506
  public long contrast(float contrast, Float4D region, Float2D point)
1507
    {
1508
    Interpolator1D di = new Interpolator1D(); 
1509
    di.setCount(0.5f);
1510
    di.setDuration(0);
1511
    di.add(new Float1D(1));                          
1512
    di.add(new Float1D(contrast));                         
1513
   
1514
    return mF.add(EffectNames.CONTRAST, di, region, point.x, point.y);
1515
    }
1516
 
1517
///////////////////////////////////////////////////////////////////////////////////////////////////
1518
///////////////////////////////////////////////////////////////////////////////////////////////////
1519
// SMOOTH CONTRAST
1520
/**
1521
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1522
 *        
1523 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1524
 *               at any given moment.
1525
 * @param region Region this Effect is limited to. 
1526
 *               Null here means 'apply the Effect to the whole Bitmap'.
1527
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1528
 *               representing the current center of the effect.
1529
 * @return       ID of the effect added, or -1 if we failed to add one. 
1530 6a06a912 Leszek Koltunski
 */
1531
  public long smooth_contrast(Interpolator1D a, Float4D region, Interpolator2D i)
1532
    {
1533
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, i);
1534
    }
1535
1536
///////////////////////////////////////////////////////////////////////////////////////////////////
1537
/**
1538
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1539
 * <p>
1540
 * Here the center of the Effect stays constant.
1541
 *         
1542 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of contrast we want to have
1543
 *               at any given moment.
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
 * @return       ID of the effect added, or -1 if we failed to add one. 
1548 6a06a912 Leszek Koltunski
 */
1549
  public long smooth_contrast(Interpolator1D a, Float4D region, Float2D point)
1550
    {
1551
    return mF.add(EffectNames.SMOOTH_CONTRAST, a, region, point.x, point.y);
1552
    }
1553
1554
///////////////////////////////////////////////////////////////////////////////////////////////////  
1555
/**
1556
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1557
 *        
1558 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1559
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1560
 *                 anything more than 1 - increase the contrast. 
1561
 * @param region   Region this Effect is limited to. 
1562
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1563
 * @param i        2-dimensional Interpolator which, at any given time, returns a Float2D
1564
 *                 representing the current center of the effect.
1565 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1566 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1567
 * @return         ID of the effect added, or -1 if we failed to add one. 
1568 6a06a912 Leszek Koltunski
 */
1569
  public long smooth_contrast(float contrast, Float4D region, Interpolator2D i, int duration, float count)
1570
    {
1571
    Interpolator1D di = new Interpolator1D(); 
1572
    di.setCount(count);
1573
    di.setDuration(duration);
1574
    di.add(new Float1D(1));                          
1575
    di.add(new Float1D(contrast));                         
1576
   
1577
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, i);
1578
    }
1579
1580
///////////////////////////////////////////////////////////////////////////////////////////////////
1581
/**
1582
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1583
 * <p>
1584
 * Here the center of the Effect stays constant.
1585
 *         
1586 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1587
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1588
 *                 anything more than 1 - increase the contrast. 
1589
 * @param region   Region this Effect is limited to. 
1590
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1591
 * @param point    Center of the Effect.
1592 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1593 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1594
 * @return         ID of the effect added, or -1 if we failed to add one. 
1595 6a06a912 Leszek Koltunski
 */
1596
  public long smooth_contrast(float contrast, Float4D region, Float2D point, int duration, float count)
1597
    {
1598
    Interpolator1D di = new Interpolator1D(); 
1599
    di.setCount(count);
1600
    di.setDuration(duration);
1601
    di.add(new Float1D(1));                          
1602
    di.add(new Float1D(contrast));                         
1603
   
1604
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1605
    }
1606
1607
///////////////////////////////////////////////////////////////////////////////////////////////////
1608
/**
1609
 * Makes a certain sub-region of the Bitmap smoothly change its contrast level.
1610
 * <p>
1611
 * Here the center of the Effect stays constant and the effect for now change in time.
1612
 *         
1613 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1614
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1615
 *                 anything more than 1 - increase the contrast. 
1616
 * @param region   Region this Effect is limited to. 
1617
 *                 Null here means 'apply the Effect to the whole Bitmap'.
1618
 * @param point    Center of the Effect.
1619
 * @return         ID of the effect added, or -1 if we failed to add one. 
1620 6a06a912 Leszek Koltunski
 */
1621
  public long smooth_contrast(float contrast, Float4D region, Float2D point)
1622
    {
1623
    Interpolator1D di = new Interpolator1D(); 
1624
    di.setCount(0.5f);
1625
    di.setDuration(0);
1626
    di.add(new Float1D(1));                          
1627
    di.add(new Float1D(contrast));                         
1628
   
1629
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, point.x, point.y);
1630
    }
1631
    
1632
///////////////////////////////////////////////////////////////////////////////////////////////////
1633
/**
1634
 * Makes the whole Bitmap change its contrast level.
1635
 * 
1636 d7bbef2f Leszek Koltunski
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1637
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1638
 *                 anything omre than 1 - increase the contrast. 
1639 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1640 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1641
 * @return         ID of the effect added, or -1 if we failed to add one. 
1642 6a06a912 Leszek Koltunski
 */
1643
  public long smooth_contrast(float contrast, int duration, float count) 
1644
    {
1645
    Interpolator1D di = new Interpolator1D(); 
1646
    di.setCount(count);
1647
    di.setDuration(duration);
1648
    di.add(new Float1D(1));                            
1649
    di.add(new Float1D(contrast));                        
1650
         
1651
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, 0.0f, 0.0f);
1652
    }
1653
1654
1655
///////////////////////////////////////////////////////////////////////////////////////////////////
1656
///////////////////////////////////////////////////////////////////////////////////////////////////
1657
// SATURATION
1658
/**
1659
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1660
 *        
1661 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1662
 *               at any given moment.
1663
 * @param region Region this Effect is limited to. 
1664
 *               Null here means 'apply the Effect to the whole Bitmap'.
1665
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D
1666
 *               representing the current center of the effect.
1667
 * @return       ID of the effect added, or -1 if we failed to add one. 
1668 6a06a912 Leszek Koltunski
 */
1669
  public long saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1670
    {
1671
    return mF.add(EffectNames.SATURATION, a, region, i);
1672
    }
1673
1674
///////////////////////////////////////////////////////////////////////////////////////////////////
1675
/**
1676
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1677
 * <p>
1678
 * Here the center of the Effect stays constant.
1679
 *         
1680 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1681
 *               at any given moment.
1682
 * @param region Region this Effect is limited to. 
1683
 *               Null here means 'apply the Effect to the whole Bitmap'.
1684
 * @param point  Center of the Effect.
1685
 * @return       ID of the effect added, or -1 if we failed to add one. 
1686 6a06a912 Leszek Koltunski
 */
1687
  public long saturation(Interpolator1D a, Float4D region, Float2D point)
1688
    {
1689
    return mF.add(EffectNames.SATURATION, a, region, point.x, point.y);
1690
    }
1691
1692
///////////////////////////////////////////////////////////////////////////////////////////////////  
1693
/**
1694
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1695
 *        
1696 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1697
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1698
 *                   anything more than 1 - increase the saturation. 
1699
 * @param region     Region this Effect is limited to.
1700
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1701
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1702
 *                   representing the current center of the effect.
1703
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1704
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1705
 * @return           ID of the effect added, or -1 if we failed to add one. 
1706 6a06a912 Leszek Koltunski
 */
1707
  public long saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1708
    {
1709
    Interpolator1D di = new Interpolator1D(); 
1710
    di.setCount(count);
1711
    di.setDuration(duration);
1712
    di.add(new Float1D(1));                          
1713
    di.add(new Float1D(saturation));                         
1714
   
1715
    return mF.add(EffectNames.SATURATION, di, region, i);
1716
    }
1717
1718
///////////////////////////////////////////////////////////////////////////////////////////////////
1719
/**
1720
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1721
 * <p>
1722
 * Here the center of the Effect stays constant.
1723
 *         
1724 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1725
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1726
 *                   anything more than 1 - increase the saturation. 
1727
 * @param region     Region this Effect is limited to. 
1728
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1729
 * @param point      Center of the Effect.
1730
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1731
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1732
 * @return           ID of the effect added, or -1 if we failed to add one. 
1733 6a06a912 Leszek Koltunski
 */
1734
  public long saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1735
    {
1736
    Interpolator1D di = new Interpolator1D(); 
1737
    di.setCount(count);
1738
    di.setDuration(duration);
1739
    di.add(new Float1D(1));                          
1740
    di.add(new Float1D(saturation));                         
1741
   
1742
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1743
    }
1744
1745
///////////////////////////////////////////////////////////////////////////////////////////////////
1746
/**
1747
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1748
 * <p>
1749
 * Here the center of the Effect stays constant and the effect for now change in time.
1750
 *         
1751 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1752
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1753
 *                   anything more than 1- increase the saturation. 
1754
 * @param region     Region this Effect is limited to. 
1755
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1756
 * @param point      Center of the Effect.
1757
 * @return           ID of the effect added, or -1 if we failed to add one. 
1758 6a06a912 Leszek Koltunski
 */
1759
  public long saturation(float saturation, Float4D region, Float2D point)
1760
    {
1761
    Interpolator1D di = new Interpolator1D(); 
1762
    di.setCount(0.5f);
1763
    di.setDuration(0);
1764
    di.add(new Float1D(1));                          
1765
    di.add(new Float1D(saturation));                         
1766
   
1767
    return mF.add(EffectNames.SATURATION, di, region, point.x, point.y);
1768
    }
1769
 
1770
///////////////////////////////////////////////////////////////////////////////////////////////////
1771
///////////////////////////////////////////////////////////////////////////////////////////////////
1772
// SMOOTH_SATURATION
1773
/**
1774
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1775
 *        
1776 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1777
 *               at any given moment.
1778
 * @param region Region this Effect is limited to. 
1779
 *               Null here means 'apply the Effect to the whole Bitmap'.
1780
 * @param i      2-dimensional Interpolator which, at any given time, returns a Float2D 
1781
 *               representing the current center of the effect.
1782
 * @return       ID of the effect added, or -1 if we failed to add one. 
1783 6a06a912 Leszek Koltunski
 */
1784
  public long smooth_saturation(Interpolator1D a, Float4D region, Interpolator2D i)
1785
    {
1786
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, i);
1787
    }
1788
1789
///////////////////////////////////////////////////////////////////////////////////////////////////
1790
/**
1791
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1792
 * <p>
1793
 * Here the center of the Effect stays constant.
1794
 *         
1795 d7bbef2f Leszek Koltunski
 * @param a      1-dimensional Interpolator that returns the level of saturation we want to have
1796
 *               at any given moment.
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
 * @return       ID of the effect added, or -1 if we failed to add one. 
1801 6a06a912 Leszek Koltunski
 */
1802
  public long smooth_saturation(Interpolator1D a, Float4D region, Float2D point)
1803
    {
1804
    return mF.add(EffectNames.SMOOTH_SATURATION, a, region, point.x, point.y);
1805
    }
1806
1807
///////////////////////////////////////////////////////////////////////////////////////////////////  
1808
/**
1809
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1810
 *        
1811 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1812
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1813
 *                   anything more than 1 -increase the saturation. 
1814
 * @param region     Region this Effect is limited to. 
1815
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1816
 * @param i          2-dimensional Interpolator which, at any given time, returns a Float2D
1817
 *                   representing the current center of the effect.
1818
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1819
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1820
 * @return           ID of the effect added, or -1 if we failed to add one. 
1821 6a06a912 Leszek Koltunski
 */
1822
  public long smooth_saturation(float saturation, Float4D region, Interpolator2D i, int duration, float count)
1823
    {
1824
    Interpolator1D di = new Interpolator1D(); 
1825
    di.setCount(count);
1826
    di.setDuration(duration);
1827
    di.add(new Float1D(1));                          
1828
    di.add(new Float1D(saturation));                         
1829
   
1830
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, i);
1831
    }
1832
1833
///////////////////////////////////////////////////////////////////////////////////////////////////
1834
/**
1835
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1836
 * <p>
1837
 * Here the center of the Effect stays constant.
1838
 *         
1839 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1840
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1841
 *                   anything more than 1 - increase the saturation. 
1842
 * @param region     Region this Effect is limited to. 
1843
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1844
 * @param point      Center of the Effect.
1845
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1846
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1847
 * @return           ID of the effect added, or -1 if we failed to add one. 
1848 6a06a912 Leszek Koltunski
 */
1849
  public long smooth_saturation(float saturation, Float4D region, Float2D point, int duration, float count)
1850
    {
1851
    Interpolator1D di = new Interpolator1D(); 
1852
    di.setCount(count);
1853
    di.setDuration(duration);
1854
    di.add(new Float1D(1));                          
1855
    di.add(new Float1D(saturation));                         
1856
   
1857
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1858
    }
1859
1860
///////////////////////////////////////////////////////////////////////////////////////////////////
1861
/**
1862
 * Makes a certain sub-region of the Bitmap smoothly change its saturation level.
1863
 * <p>
1864
 * Here the center of the Effect stays constant and the effect for now change in time.
1865
 *         
1866 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1867
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1868
 *                   anything more than 1 - increase the saturation. 
1869
 * @param region     Region this Effect is limited to. 
1870
 *                   Null here means 'apply the Effect to the whole Bitmap'.
1871
 * @param point      Center of the Effect.
1872
 * @return           ID of the effect added, or -1 if we failed to add one. 
1873 6a06a912 Leszek Koltunski
 */
1874
  public long smooth_saturation(float saturation, Float4D region, Float2D point)
1875
    {
1876
    Interpolator1D di = new Interpolator1D(); 
1877
    di.setCount(0.5f);
1878
    di.setDuration(0);
1879
    di.add(new Float1D(1));                          
1880
    di.add(new Float1D(saturation));                         
1881
   
1882
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, point.x, point.y);
1883
    }
1884
    
1885
///////////////////////////////////////////////////////////////////////////////////////////////////
1886
/**
1887
 * Makes the whole Bitmap change its saturation level.
1888
 * 
1889 d7bbef2f Leszek Koltunski
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1890
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1891
 *                   anything more than 1 - increase the saturation. 
1892
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1893
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1894
 * @return           ID of the effect added, or -1 if we failed to add one. 
1895 6a06a912 Leszek Koltunski
 */
1896
  public long smooth_saturation(float saturation, int duration, float count) 
1897
    {
1898
    Interpolator1D di = new Interpolator1D(); 
1899
    di.setCount(count);
1900
    di.setDuration(duration);
1901
    di.add(new Float1D(1));                            
1902
    di.add(new Float1D(saturation));                        
1903
         
1904
    return mF.add(EffectNames.SMOOTH_SATURATION, di,null, 0.0f, 0.0f);
1905
    }
1906
            
1907
///////////////////////////////////////////////////////////////////////////////////////////////////
1908
// Vertex-based effects  
1909
///////////////////////////////////////////////////////////////////////////////////////////////////
1910
// DISTORT
1911
/**
1912
 * Distort a (possibly changing in time) part of the Bitmap by a (possibly changing in time) vector of force.
1913
 * 
1914 d7bbef2f Leszek Koltunski
 * @param i      2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
1915
 *               represents the vector the Center of the Effect is currently being dragged with.
1916
 * @param region Region that masks the effect of the Distortion.
1917
 * @param p      2-dimensional Interpolator that, at any given time, returns a Point2D representing 
1918
 *               the Center of the Effect.
1919
 * @return       ID of the effect added, or -1 if we failed to add one. 
1920 6a06a912 Leszek Koltunski
 */
1921
  public long distort(Interpolator i, Float4D region, Interpolator2D p)
1922
    {  
1923
    return mV.add(EffectNames.DISTORT, i, region, p);  
1924
    }
1925
1926
///////////////////////////////////////////////////////////////////////////////////////////////////
1927
/**
1928
 * Distort part of the Bitmap by a (possibly changing in time) vector of force.
1929
 * <p>
1930
 * Difference between this and the previous method is that here the center of the Effect stays constant.
1931
 *   
1932 d7bbef2f Leszek Koltunski
 * @param i      2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
1933
 *               represents the vector the Center of the Effect is currently being dragged with.
1934
 * @param region Region that masks the effect of the Distortion.
1935
 * @param point  Center of the Effect.
1936
 * @return       ID of the effect added, or -1 if we failed to add one. 
1937 6a06a912 Leszek Koltunski
 */
1938
  public long distort(Interpolator i, Float4D region, Float2D point)
1939
    {  
1940
    return mV.add(EffectNames.DISTORT, i, region, point.x, point.y);  
1941
    }
1942
1943
///////////////////////////////////////////////////////////////////////////////////////////////////
1944
/**
1945
 * Distort the whole Bitmap by a (possibly changing in time) vector of force.
1946
 * 
1947 d7bbef2f Leszek Koltunski
 * @param i     2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
1948
 *              represents the vector the Center of the Effect is currently being dragged with.
1949
 * @param point Center of the Effect.
1950
 * @return      ID of the effect added, or -1 if we failed to add one. 
1951 6a06a912 Leszek Koltunski
 */
1952
  public long distort(Interpolator i, Float2D point)
1953
    {
1954
    return mV.add(EffectNames.DISTORT, i, null, point.x, point.y);  
1955
    }
1956
1957
///////////////////////////////////////////////////////////////////////////////////////////////////
1958
/**
1959
 * Distort part of the Bitmap by a vector of force that changes from (0,0,0) to v.
1960
 * 
1961 d7bbef2f Leszek Koltunski
 * @param vector   Maximum vector of force. 
1962
 * @param region   Region that masks the effect of the Distortion.
1963
 * @param point    Center of the Effect.
1964 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1965 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1966
 * @return         ID of the effect added, or -1 if we failed to add one. 
1967 6a06a912 Leszek Koltunski
 */
1968
  public long distort(Float3D vector, Float4D region, Float2D point, int duration, float count)
1969
    {  
1970
    Interpolator3D di = new Interpolator3D(); 
1971
    di.setCount(count);
1972
    di.setDuration(duration);
1973
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1974
    di.add(vector);                                                  
1975
           
1976
    return mV.add(EffectNames.DISTORT, di, region, point.x, point.y);  
1977
    }
1978
1979
///////////////////////////////////////////////////////////////////////////////////////////////////
1980
/**
1981
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
1982
 * 
1983 d7bbef2f Leszek Koltunski
 * @param vector   Maximum vector of force.
1984
 * @param point    Center of the Effect.
1985 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1986 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1987
 * @return         ID of the effect added, or -1 if we failed to add one. 
1988 6a06a912 Leszek Koltunski
 */
1989
  public long distort(Float3D vector, Float2D point, int duration, float count)
1990
    {
1991
    Interpolator3D di = new Interpolator3D(); 
1992
    di.setCount(count);
1993
    di.setDuration(duration);
1994
    di.add(new Float3D(0.0f,0.0f,0.0f));               
1995
    di.add(vector);                                                 
1996
           
1997
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
1998
    }
1999
2000
///////////////////////////////////////////////////////////////////////////////////////////////////
2001
/**
2002
 * Distort the whole Bitmap by a vector of force that changes from (0,0,0) to v.
2003
 * <p>
2004
 * Difference between this and the previous method is that here the vector of force will get interpolated
2005
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2006
 * 
2007 d7bbef2f Leszek Koltunski
 * @param vector   Maximum, final vector of force.
2008
 * @param point    Center of the Effect.
2009 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2010 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
2011 6a06a912 Leszek Koltunski
 */
2012
  public long distort(Float3D vector, Float2D point, int duration)
2013
    {
2014
    Interpolator3D di = new Interpolator3D();  
2015
    di.setCount(0.5f);
2016
    di.setDuration(duration);
2017
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2018
    di.add(vector);                 
2019
           
2020
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2021
    }
2022
2023
///////////////////////////////////////////////////////////////////////////////////////////////////
2024
/**
2025
 * Distort the whole Bitmap by a vector of force v.
2026
 * <p>
2027
 * Here we apply a constant vector of force.
2028
 * 
2029 d7bbef2f Leszek Koltunski
 * @param vector Vector of force.
2030
 * @param point  Center of the Effect.
2031
 * @return       ID of the effect added, or -1 if we failed to add one. 
2032 6a06a912 Leszek Koltunski
 */
2033
  public long distort(Float3D vector, Float2D point )
2034
    {
2035
    Interpolator3D di = new Interpolator3D(); 
2036
    di.setCount(0.5f);
2037
    di.setDuration(0);
2038
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2039
    di.add(vector);           
2040
           
2041
    return mV.add(EffectNames.DISTORT, di, null, point.x, point.y);  
2042
    }
2043
2044
///////////////////////////////////////////////////////////////////////////////////////////////////
2045
///////////////////////////////////////////////////////////////////////////////////////////////////
2046
// DEFORM
2047
/**
2048
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2049
 * a (possibly changing in time) point on the Bitmap.
2050
 *     
2051 d7bbef2f Leszek Koltunski
 * @param i     Interpolator that, at any given time, returns a Point2D representing vector of 
2052
 *              force that deforms the shapre of the whole Bitmap.
2053
 * @param point 2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2054
 *              the Center of the Effect.
2055
 * @return      ID of the effect added, or -1 if we failed to add one. 
2056 6a06a912 Leszek Koltunski
 */
2057
  public long deform(Interpolator i, Interpolator2D point)
2058
    {  
2059
    return mV.add(EffectNames.DEFORM, i, null, point);  
2060
    }
2061
2062
///////////////////////////////////////////////////////////////////////////////////////////////////
2063
/**
2064
 * Deform the shape of the whole Bitmap with a (possibly changing in time) vector of force applied to 
2065
 * a constant point on the Bitmap.
2066
 * 
2067 d7bbef2f Leszek Koltunski
 * @param i     Interpolator that, at any given time, returns a Point2D representing 
2068
 *              vector of force that deforms the shapre of the whole Bitmap.
2069
 * @param point Center of the Effect.
2070
 * @return      ID of the effect added, or -1 if we failed to add one. 
2071 6a06a912 Leszek Koltunski
 */
2072
  public long deform(Interpolator i, Float2D point)
2073
    {
2074
    return mV.add(EffectNames.DEFORM, i, null, point.x, point.y);  
2075
    }
2076
2077
///////////////////////////////////////////////////////////////////////////////////////////////////
2078
/**
2079
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2080
 * applied to a constant point on the Bitmap. 
2081
 * 
2082 d7bbef2f Leszek Koltunski
 * @param vector   Vector of force.
2083
 * @param point    Center of the Effect.
2084 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2085 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2086
 * @return         ID of the effect added, or -1 if we failed to add one. 
2087 6a06a912 Leszek Koltunski
 */
2088
  public long deform(Float3D vector, Float2D point, int duration, float count)
2089
    {
2090
    Interpolator3D di = new Interpolator3D(); 
2091
    di.setCount(count);
2092
    di.setDuration(duration);
2093
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2094
    di.add(vector);                
2095
           
2096
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2097
    }
2098
2099
///////////////////////////////////////////////////////////////////////////////////////////////////
2100
/**
2101
 * Deform the shape of the whole Bitmap with a vector of force smoothly changing from (0,0,0) to v 
2102
 * applied to a constant point on the Bitmap. 
2103
 * <p>
2104
 * Identical to calling the previous method with count=0.5.
2105
 * 
2106 d7bbef2f Leszek Koltunski
 * @param vector   Final vector of force.
2107
 * @param point    Center of the Effect.
2108 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2109 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
2110 6a06a912 Leszek Koltunski
 */
2111
  public long deform(Float3D vector, Float2D point, int duration)
2112
    {
2113
    Interpolator3D di = new Interpolator3D();  
2114
    di.setCount(0.5f);
2115
    di.setDuration(duration);
2116
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2117
    di.add(vector);             
2118
           
2119
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2120
    }
2121
2122
///////////////////////////////////////////////////////////////////////////////////////////////////
2123
/**
2124
 * Deform the shape of the whole Bitmap with a constant vector of force applied to a constant 
2125
 * point on the Bitmap. 
2126
 * 
2127 d7bbef2f Leszek Koltunski
 * @param vector Vector of force.
2128
 * @param point  Center of the Effect.
2129
 * @return       ID of the effect added, or -1 if we failed to add one. 
2130 6a06a912 Leszek Koltunski
 */
2131
  public long deform(Float3D vector, Float2D point )
2132
    {
2133
    Interpolator3D di = new Interpolator3D(); 
2134
    di.setCount(0.5f);
2135
    di.setDuration(0);
2136
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2137
    di.add(vector);            
2138
           
2139
    return mV.add(EffectNames.DEFORM, di, null, point.x, point.y);  
2140
    }
2141
   
2142
///////////////////////////////////////////////////////////////////////////////////////////////////  
2143
///////////////////////////////////////////////////////////////////////////////////////////////////
2144
// SINK
2145
/**
2146
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2147
 * away from the center (degree<=1)
2148
 *    
2149 d7bbef2f Leszek Koltunski
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing
2150
 *               the current degree of the effect.
2151
 * @param region Region that masks the effect of the Sink.
2152
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2153
 *               the Center of the Effect.
2154
 * @return       ID of the effect added, or -1 if we failed to add one. 
2155 6a06a912 Leszek Koltunski
 */
2156
  public long sink(Interpolator1D di, Float4D region, Interpolator2D point)
2157
    {
2158
    return mV.add(EffectNames.SINK, di, region, point);  
2159
    }
2160
2161
///////////////////////////////////////////////////////////////////////////////////////////////////
2162
/**
2163
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2164
 * away from the center (degree<=1).
2165
 * <p>
2166
 * Here the Center stays constant.
2167
 *      
2168 d7bbef2f Leszek Koltunski
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D
2169
 *               representing the current degree of the effect.
2170
 * @param region Region that masks the effect of the Sink.
2171
 * @param point  Center of the Effect.
2172
 * @return       ID of the effect added, or -1 if we failed to add one. 
2173 6a06a912 Leszek Koltunski
 */
2174
  public long sink(Interpolator1D di, Float4D region, Float2D point)
2175
    {
2176
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2177
    }
2178
  
2179
///////////////////////////////////////////////////////////////////////////////////////////////////
2180
/**
2181
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2182
 * away from the center (degree<=1).
2183
 * <p>
2184
 * Here we can only interpolate between 1 and degree.
2185
 * 
2186 d7bbef2f Leszek Koltunski
 * @param degree   How much to push or pull. Between 0 and infinity.
2187
 * @param region   Region that masks the effect of the Sink.
2188
 * @param p        2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2189
 *                 the Center of the Effect.
2190 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2191 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2192
 * @return         ID of the effect added, or -1 if we failed to add one. 
2193 6a06a912 Leszek Koltunski
 */
2194
  public long sink(float degree, Float4D region, Interpolator2D p, int duration, float count)
2195
    {
2196
    Interpolator1D di = new Interpolator1D(); 
2197
    di.setCount(count);
2198
    di.setDuration(duration);
2199
    di.add(new Float1D(1));                                
2200
    di.add(new Float1D(degree));                          
2201
    
2202
    return mV.add(EffectNames.SINK, di, region, p);  
2203
    }
2204
2205
///////////////////////////////////////////////////////////////////////////////////////////////////
2206
/**
2207
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2208
 * away from the center (degree<=1).
2209
 *   
2210 d7bbef2f Leszek Koltunski
 * @param degree   How much to push or pull. Between 0 and infinity.
2211
 * @param region   Region that masks the effect of the Sink.
2212
 * @param point    Center of the Effect.
2213 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2214 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2215
 * @return         ID of the effect added, or -1 if we failed to add one. 
2216 6a06a912 Leszek Koltunski
 */
2217
  public long sink(float degree, Float4D region, Float2D point, int duration, float count)
2218
    {
2219
    Interpolator1D di = new Interpolator1D(); 
2220
    di.setCount(count);
2221
    di.setDuration(duration);
2222
    di.add(new Float1D(1));                                
2223
    di.add(new Float1D(degree));                          
2224
    
2225
    return mV.add(EffectNames.SINK, di, region, point.x, point.y);  
2226
    }
2227
2228
///////////////////////////////////////////////////////////////////////////////////////////////////
2229
/**
2230
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2231
 * away from the center (degree<=1).
2232
 * 
2233 d7bbef2f Leszek Koltunski
 * @param degree   How much to push or pull. Between 0 and infinity.
2234
 * @param point    Center of the Effect.
2235 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2236 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2237
 * @return         ID of the effect added, or -1 if we failed to add one. 
2238 6a06a912 Leszek Koltunski
 */
2239
  public long sink(float degree, Float2D point, int duration, float count) 
2240
    {
2241
    Interpolator1D di = new Interpolator1D();  
2242
    di.setCount(count);
2243
    di.setDuration(duration);
2244
    di.add(new Float1D(1));                                
2245
    di.add(new Float1D(degree));                          
2246
         
2247
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2248
    }
2249
2250
///////////////////////////////////////////////////////////////////////////////////////////////////
2251
/**
2252
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2253
 * away from the center (degree<=1).
2254
 * <p>
2255
 * Equivalent to calling the previous method with count=0.5.
2256
 * 
2257 d7bbef2f Leszek Koltunski
 * @param degree   How much to push or pull. Between 0 and infinity.
2258
 * @param point    Center of the Effect.
2259 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2260 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
2261 6a06a912 Leszek Koltunski
 */
2262
  public long sink(float degree, Float2D point, int duration) 
2263
    {
2264
    Interpolator1D di = new Interpolator1D(); 
2265
    di.setCount(0.5f);
2266
    di.setDuration(duration);
2267
    di.add(new Float1D(1));                               
2268
    di.add(new Float1D(degree));                      
2269
        
2270
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2271
    }
2272
2273
///////////////////////////////////////////////////////////////////////////////////////////////////
2274
/**
2275
 * Pull all points of the Bitmap towards the center of the Effect (if degree>=1) or push them 
2276
 * away from the center (degree<=1).
2277
 * <p>
2278
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2279
 * 
2280 d7bbef2f Leszek Koltunski
 * @param degree How much to push or pull. Between 0 and infinity.
2281
 * @param point  Center of the Effect.
2282
 * @return       ID of the effect added, or -1 if we failed to add one. 
2283 6a06a912 Leszek Koltunski
 */
2284
  public long sink(float degree, Float2D point) 
2285
    {
2286
    Interpolator1D di = new Interpolator1D(); 
2287
    di.setCount(0.5f);
2288
    di.setDuration(0);
2289
    di.add(new Float1D(1));                               
2290
    di.add(new Float1D(degree));                      
2291
        
2292
    return mV.add(EffectNames.SINK, di, null, point.x, point.y);  
2293
    }
2294
  
2295
///////////////////////////////////////////////////////////////////////////////////////////////////  
2296
///////////////////////////////////////////////////////////////////////////////////////////////////
2297
// SWIRL
2298
/**
2299
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2300
 * Interpolator). 
2301
 *   
2302 d7bbef2f Leszek Koltunski
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2303
 *               the degree of Swirl.
2304
 * @param region Region that masks the effect of the Swirl.
2305
 * @param point  2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2306
 *               the Center of the Effect.
2307
 * @return       ID of the effect added, or -1 if we failed to add one. 
2308 6a06a912 Leszek Koltunski
 */
2309
  public long swirl(Interpolator1D di, Float4D region, Interpolator2D point)
2310
    {    
2311
    return mV.add(EffectNames.SWIRL, di, region, point);  
2312
    }
2313
2314
///////////////////////////////////////////////////////////////////////////////////////////////////
2315
/**
2316
 * Rotate part of the Bitmap around the Center of the Effect by a certain angle (as returned by the
2317
 * Interpolator).
2318
 * <p>
2319
 * Here the Center stays constant.
2320
 *      
2321 d7bbef2f Leszek Koltunski
 * @param di     1-dimensional Interpolator which, at any given time, returns a Point1D representing 
2322
 *               the degree of Swirl.
2323
 * @param region Region that masks the effect of the Swirl.
2324
 * @param point  Center of the Effect.
2325
 * @return       ID of the effect added, or -1 if we failed to add one. 
2326 6a06a912 Leszek Koltunski
 */
2327
  public long swirl(Interpolator1D di, Float4D region, Float2D point)
2328
    {    
2329
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2330
    }
2331
 
2332
///////////////////////////////////////////////////////////////////////////////////////////////////
2333
/**
2334
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2335
 *   
2336 d7bbef2f Leszek Koltunski
 * @param degree   Angle of rotation. Unit: degrees.
2337
 * @param region   Region that masks the effect of the Swirl.
2338
 * @param point    2-dimensional Interpolator that, at any given time, returns a Point2D representing 
2339
 *                 the Center of the Effect.
2340 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2341 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2342
 * @return         ID of the effect added, or -1 if we failed to add one. 
2343 6a06a912 Leszek Koltunski
 */
2344
  public long swirl(int degree, Float4D region, Interpolator2D point, int duration, float count)
2345
    {
2346
    Interpolator1D di = new Interpolator1D(); 
2347
    di.setCount(count);
2348
    di.setDuration(duration);
2349
    di.add(new Float1D(0));                                
2350
    di.add(new Float1D(degree));                          
2351
    
2352
    return mV.add(EffectNames.SWIRL, di, region, point);  
2353
    }
2354
2355
///////////////////////////////////////////////////////////////////////////////////////////////////
2356
/**
2357
 * Rotate part of the Bitmap around the Center of the Effect by 'degree' angle.
2358
 * <p>
2359
 * Here the Center stays constant.
2360
 *    
2361 d7bbef2f Leszek Koltunski
 * @param degree   Angle of rotation. Unit: degrees.
2362
 * @param region   Region that masks the effect of the Swirl.
2363
 * @param point    Center of the Effect.
2364 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2365 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2366
 * @return         ID of the effect added, or -1 if we failed to add one. 
2367 6a06a912 Leszek Koltunski
 */
2368
  public long swirl(int degree, Float4D region, Float2D point, int duration, float count)
2369
    {
2370
    Interpolator1D di = new Interpolator1D(); 
2371
    di.setCount(count);
2372
    di.setDuration(duration);
2373
    di.add(new Float1D(0));                                
2374
    di.add(new Float1D(degree));                          
2375
    
2376
    return mV.add(EffectNames.SWIRL, di, region, point.x, point.y);  
2377
    }
2378
2379
///////////////////////////////////////////////////////////////////////////////////////////////////
2380
/**
2381
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2382
 * 
2383 d7bbef2f Leszek Koltunski
 * @param degree   Angle of rotation. Unit: degrees.
2384
 * @param point    Center of the Effect.
2385 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2386 d7bbef2f Leszek Koltunski
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2387
 * @return         ID of the effect added, or -1 if we failed to add one. 
2388 6a06a912 Leszek Koltunski
 */
2389
  public long swirl(int degree, Float2D point, int duration, float count) 
2390
    {
2391
    Interpolator1D di = new Interpolator1D();  
2392
    di.setCount(count);
2393
    di.setDuration(duration);
2394
    di.add(new Float1D(0));                                
2395
    di.add(new Float1D(degree));                          
2396
         
2397
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2398
    }
2399
2400
///////////////////////////////////////////////////////////////////////////////////////////////////
2401
/**
2402
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2403
 * <p>
2404
 * Equivalent to calling the previous method with count=0.5.
2405
 * 
2406 d7bbef2f Leszek Koltunski
 * @param degree   Angle of rotation. Unit: degrees.
2407
 * @param point    Center of the Effect.
2408 6a06a912 Leszek Koltunski
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2409 d7bbef2f Leszek Koltunski
 * @return         ID of the effect added, or -1 if we failed to add one. 
2410 6a06a912 Leszek Koltunski
 */
2411
  public long swirl(int degree, Float2D point, int duration) 
2412
    {
2413
    Interpolator1D di = new Interpolator1D(); 
2414
    di.setCount(0.5f);
2415
    di.setDuration(duration);
2416
    di.add(new Float1D(0));                               
2417
    di.add(new Float1D(degree));                      
2418
        
2419
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2420
    }
2421
2422
///////////////////////////////////////////////////////////////////////////////////////////////////
2423
/**
2424
 * Rotate the whole Bitmap around the Center of the Effect by 'degree' angle.
2425
 * <p>
2426
 * Equivalent to calling the previous method with duration=0.
2427
 * 
2428 d7bbef2f Leszek Koltunski
 * @param degree Angle of rotation. Unit: degrees.
2429
 * @param point  Center of the Effect.
2430
 * @return       ID of the effect added, or -1 if we failed to add one. 
2431 6a06a912 Leszek Koltunski
 */
2432
  public long swirl(int degree, Float2D point) 
2433
    {
2434
    Interpolator1D di = new Interpolator1D(); 
2435
    di.setCount(0.5f);
2436
    di.setDuration(0);
2437
    di.add(new Float1D(0));                               
2438
    di.add(new Float1D(degree));                      
2439
        
2440
    return mV.add(EffectNames.SWIRL, di, null, point.x, point.y);  
2441
    }
2442
2443
///////////////////////////////////////////////////////////////////////////////////////////////////
2444
///////////////////////////////////////////////////////////////////////////////////////////////////
2445
// WAVE
2446
2447
///////////////////////////////////////////////////////////////////////////////////////////////////   
2448
}