Project

General

Profile

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

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

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2016 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Distorted.                                                               //
5
//                                                                                               //
6
// Distorted is free software: you can redistribute it and/or modify                             //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Distorted is distributed in the hope that it will be useful,                                  //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Distorted.  If not, see <http://www.gnu.org/licenses/>.                            //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.library;
21

    
22
import android.graphics.Bitmap;
23
import android.opengl.GLES20;
24
import android.opengl.GLUtils;
25

    
26
///////////////////////////////////////////////////////////////////////////////////////////////////
27
/**
28
 * All Objects to which Distorted Graphics effects can be applied need to be extended from here.
29
 */
30
public abstract class DistortedObject 
31
{
32
    private static final Float2D mZero2D = new Float2D(0,0);
33
    private static final Float3D mZero3D = new Float3D(0,0,0);
34

    
35
    private static float[] mViewMatrix   = new float[16];
36
   
37
    protected EffectQueueMatrix    mM;
38
    protected EffectQueueFragment  mF;
39
    protected EffectQueueVertex    mV;
40
    protected EffectQueueOther mO;
41

    
42
    protected boolean matrixCloned, vertexCloned, fragmentCloned;
43
 
44
    protected GridObject mGrid = null;
45
    protected long mID;
46
    protected int mSizeX, mSizeY, mSizeZ, mSize; // in screen space
47

    
48
    protected Bitmap[] mBmp= null; // 
49
    int[] mTextureDataH;           // have to be shared among all the cloned Objects
50
    boolean[] mBitmapSet;          // 
51

    
52
///////////////////////////////////////////////////////////////////////////////////////////////////
53

    
54
    protected abstract DistortedObject deepCopy(int flags);
55

    
56
///////////////////////////////////////////////////////////////////////////////////////////////////
57

    
58
    protected void initializeData(int size)
59
      {
60
      mID             = DistortedObjectList.add(this);
61
      mSize           = size;
62
      mTextureDataH   = new int[1];
63
      mTextureDataH[0]= 0;
64
      mBmp            = new Bitmap[1];
65
      mBmp[0]         = null;
66
      mBitmapSet      = new boolean[1];
67
      mBitmapSet[0]   = false;
68
      
69
      initializeEffectLists(this,0);
70
      
71
      if( Distorted.isInitialized() ) resetTexture();    
72
      }
73
    
74
///////////////////////////////////////////////////////////////////////////////////////////////////
75
    
76
    protected void initializeEffectLists(DistortedObject d, int flags)
77
      {
78
      if( (flags & Distorted.CLONE_PRESHADER) != 0 )
79
        {
80
        mM = d.mM;
81
        matrixCloned = true;
82
        } 
83
      else
84
        {
85
        mM = new EffectQueueMatrix(d);
86
        matrixCloned = false;  
87
        }
88
    
89
      if( (flags & Distorted.CLONE_VERTEX) != 0 )
90
        {
91
        mV = d.mV;
92
        vertexCloned = true;
93
        } 
94
      else
95
        {
96
        mV = new EffectQueueVertex(d);
97
        vertexCloned = false;  
98
        }
99
    
100
      if( (flags & Distorted.CLONE_FRAGMENT) != 0 )
101
        {
102
        mF = d.mF;
103
        fragmentCloned = true;
104
        } 
105
      else
106
        {
107
        mF = new EffectQueueFragment(d);
108
        fragmentCloned = false;   
109
        }
110

    
111
      mO= new EffectQueueOther(d); // Other effects are never cloned.
112
      }
113
    
114
///////////////////////////////////////////////////////////////////////////////////////////////////
115
// this will be called on startup and every time OpenGL context has been lost
116
// also call this from the constructor if the OpenGL context has been created already.
117
    
118
    void resetTexture()
119
      {
120
      if( mTextureDataH!=null ) 
121
        {
122
        if( mTextureDataH[0]==0 ) GLES20.glGenTextures(1, mTextureDataH, 0);
123

    
124
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);       
125
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR );
126
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR );
127
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE );
128
        GLES20.glTexParameteri ( GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE );
129
       
130
        if( mBmp!=null && mBmp[0]!=null)
131
          {
132
          GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBmp[0], 0);
133
          mBmp[0] = null;
134
          }
135
        }
136
      }
137
  
138
///////////////////////////////////////////////////////////////////////////////////////////////////
139
   
140
    void drawPriv(long currTime, DistortedProjection dp)
141
      {
142
      GLES20.glViewport(0, 0, dp.width, dp.height); 
143
      
144
      mM.compute(currTime);
145
      mM.send(mViewMatrix, dp);
146
      
147
      mV.compute(currTime);
148
      mV.postprocess();
149
      mV.send();
150
        
151
      mF.compute(currTime);
152
      mF.postprocess(mViewMatrix);
153
      mF.send();
154
       
155
      mGrid.draw();
156

    
157
      mO.send();
158
      }
159

    
160
///////////////////////////////////////////////////////////////////////////////////////////////////
161
   
162
    void drawNoEffectsPriv(DistortedProjection dp)
163
      {
164
      GLES20.glViewport(0, 0, dp.width, dp.height);
165
      mM.sendNoEffects(dp);
166
      mV.sendZero();
167
      mF.sendZero();
168
      mGrid.draw();
169
      }
170
    
171
///////////////////////////////////////////////////////////////////////////////////////////////////
172
   
173
    void releasePriv()
174
      {
175
      if( matrixCloned  ==false) mM.abortAll();
176
      if( vertexCloned  ==false) mV.abortAll();
177
      if( fragmentCloned==false) mF.abortAll();
178

    
179
      mO.abortAll();
180

    
181
      mBmp          = null;
182
      mGrid         = null;
183
      mM            = null;
184
      mV            = null;
185
      mF            = null;
186
      mO            = null;
187
      mTextureDataH = null;
188
      }
189
 
190
///////////////////////////////////////////////////////////////////////////////////////////////////
191

    
192
    long getBitmapID()
193
      {
194
      return mBmp==null ? 0 : mBmp.hashCode();
195
      }
196

    
197
///////////////////////////////////////////////////////////////////////////////////////////////////
198

    
199
  /**
200
   * Default empty constructor so that derived classes can call it
201
   */
202
    public DistortedObject()
203
      {
204

    
205
      }
206

    
207
///////////////////////////////////////////////////////////////////////////////////////////////////
208
  /**
209
   * Copy constructor used to create a DistortedObject based on various parts of another object.
210
   * <p>
211
   * Whatever we do not clone gets created just like in the default constructor.
212
   * We only call this from the descendant's classes' constructors where we have to pay attention
213
   * to give it the appropriate type of a DistortedObject!
214
   *
215
   * @param dc    Source object to create our object from
216
   * @param flags A bitmask of values specifying what to copy.
217
   *              For example, CLONE_BITMAP | CLONE_MATRIX.
218
   */
219
    public DistortedObject(DistortedObject dc, int flags)
220
      {
221
      initializeEffectLists(dc,flags);
222

    
223
      mID = DistortedObjectList.add(this);
224

    
225
      mSizeX = dc.mSizeX;
226
      mSizeY = dc.mSizeY;
227
      mSizeZ = dc.mSizeZ;
228
      mSize  = dc.mSize;
229
      mGrid  = dc.mGrid;
230

    
231
      if( (flags & Distorted.CLONE_BITMAP) != 0 )
232
        {
233
        mTextureDataH = dc.mTextureDataH;
234
        mBmp          = dc.mBmp;
235
        mBitmapSet    = dc.mBitmapSet;
236
        }
237
      else
238
        {
239
        mTextureDataH   = new int[1];
240
        mTextureDataH[0]= 0;
241
        mBitmapSet      = new boolean[1];
242
        mBitmapSet[0]   = false;
243
        mBmp            = new Bitmap[1];
244
        mBmp[0]         = null;
245

    
246
        if( Distorted.isInitialized() ) resetTexture();
247
        }
248
      }
249

    
250
///////////////////////////////////////////////////////////////////////////////////////////////////
251
/**
252
 * Draw the DistortedObject to the location specified by current Matrix effects.    
253
 *     
254
 * @param currTime current time, in milliseconds, as returned by System.currentTimeMillis().
255
 *        This gets passed on to Interpolators inside the Effects that are currently applied to the 
256
 *        Object.
257
 */
258
   public void draw(long currTime)
259
     {
260
     GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
261
     GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
262
     GLES20.glUniform1i(Distorted.mTextureUniformH, 0);  
263
     GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]); 
264
      
265
     drawPriv(currTime, Distorted.mProjection);
266
     }
267
 
268
///////////////////////////////////////////////////////////////////////////////////////////////////
269
/**
270
 * Releases all resources.
271
 */
272
   public synchronized void release()
273
     {
274
     releasePriv();  
275
     DistortedObjectList.remove(this);
276
     }
277

    
278
///////////////////////////////////////////////////////////////////////////////////////////////////
279
/**
280
 * Sets the underlying android.graphics.Bitmap object and uploads it to the GPU. 
281
 * <p>
282
 * You can only recycle() the passed Bitmap once the OpenGL context gets created (i.e. after call 
283
 * to onSurfaceCreated) because only after this point can the Library upload it to the GPU!
284
 * 
285
 * @param bmp The android.graphics.Bitmap object to apply effects to and display.
286
 */
287
   
288
   public void setBitmap(Bitmap bmp)
289
     {
290
     mBitmapSet[0] = true; 
291
      
292
     if( Distorted.isInitialized() )
293
       {
294
       GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
295
       GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureDataH[0]);        
296
       GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bmp, 0);
297
       }
298
     else
299
       {
300
       mBmp[0] = bmp;  
301
       }
302
     }
303
    
304
///////////////////////////////////////////////////////////////////////////////////////////////////
305
/**
306
 * Adds the calling class to the list of Listeners that get notified each time some event happens 
307
 * to one of the Effects that are currently applied to the DistortedBitmap.
308
 * 
309
 * @param el A class implementing the EffectListener interface that wants to get notifications.
310
 */
311
   public void addEventListener(EffectListener el)
312
     {
313
     mV.addListener(el);
314
     mF.addListener(el);
315
     mM.addListener(el);
316
     mO.addListener(el);
317
     }
318

    
319
///////////////////////////////////////////////////////////////////////////////////////////////////
320
/**
321
 * Removes the calling class from the list of Listeners.
322
 * 
323
 * @param el A class implementing the EffectListener interface that no longer wants to get notifications.
324
 */
325
   public void removeEventListener(EffectListener el)
326
     {
327
     mV.removeListener(el);
328
     mF.removeListener(el);
329
     mM.removeListener(el);
330
     mO.removeListener(el);
331
     }
332
   
333
///////////////////////////////////////////////////////////////////////////////////////////////////
334
/**
335
 * Returns the height of the DistortedObject.
336
 *    
337
 * @return height of the object, in pixels.
338
 */
339
   public int getWidth()
340
     {
341
     return mSizeX;   
342
     }
343

    
344
///////////////////////////////////////////////////////////////////////////////////////////////////
345
/**
346
 * Returns the width of the DistortedObject.
347
 * 
348
 * @return width of the Object, in pixels.
349
 */
350
    public int getHeight()
351
      {
352
      return mSizeY;  
353
      }
354
    
355
///////////////////////////////////////////////////////////////////////////////////////////////////
356
/**
357
 * Returns the depth of the DistortedObject.
358
 * 
359
 * @return depth of the Object, in pixels.
360
 */
361
    public int getDepth()
362
      {
363
      return mSizeZ;  
364
      }
365
        
366
///////////////////////////////////////////////////////////////////////////////////////////////////
367
/**
368
 * Returns unique ID of this instance.
369
 * 
370
 * @return ID of the object.
371
 */
372
    public long getID()
373
      {
374
      return mID;  
375
      }
376
    
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
/**
379
 * Aborts all Effects.
380
 * @return Number of effects aborted.
381
 */
382
    public int abortAllEffects()
383
      {
384
      return mM.abortAll() + mV.abortAll() + mF.abortAll() + mO.abortAll();
385
      }
386

    
387
///////////////////////////////////////////////////////////////////////////////////////////////////
388
/**
389
 * Aborts all Effects of a given type, for example all MATRIX Effects.
390
 * 
391
 * @param type one of the constants defined in {@link EffectTypes}
392
 * @return Number of effects aborted.
393
 */
394
    public int abortEffects(EffectTypes type)
395
      {
396
      switch(type)
397
        {
398
        case MATRIX  : return mM.abortAll();
399
        case VERTEX  : return mV.abortAll();
400
        case FRAGMENT: return mF.abortAll();
401
        case OTHER   : return mO.abortAll();
402
        default      : return 0;
403
        }
404
      }
405
    
406
///////////////////////////////////////////////////////////////////////////////////////////////////
407
/**
408
 * Aborts a single Effect.
409
 * 
410
 * @param id ID of the Effect we want to abort.
411
 * @return number of Effects aborted. Always either 0 or 1.
412
 */
413
    public int abortEffect(long id)
414
      {
415
      int type = (int)(id&EffectTypes.MASK);
416

    
417
      if( type==EffectTypes.MATRIX.type   ) return mM.removeByID(id>>EffectTypes.LENGTH);
418
      if( type==EffectTypes.VERTEX.type   ) return mV.removeByID(id>>EffectTypes.LENGTH);
419
      if( type==EffectTypes.FRAGMENT.type ) return mF.removeByID(id>>EffectTypes.LENGTH);
420
      if( type==EffectTypes.OTHER.type    ) return mO.removeByID(id>>EffectTypes.LENGTH);
421

    
422
      return 0;
423
      }
424

    
425
///////////////////////////////////////////////////////////////////////////////////////////////////
426
/**
427
 * Abort all Effects of a given type, for example all rotations.
428
 * 
429
 * @param name one of the constants defined in {@link EffectNames}
430
 * @return number of Effects aborted.
431
 */
432
    public int abortEffects(EffectNames name)
433
      {
434
      switch(name.getType())
435
        {
436
        case MATRIX  : return mM.removeByType(name);
437
        case VERTEX  : return mV.removeByType(name);
438
        case FRAGMENT: return mF.removeByType(name);
439
        case OTHER   : return mO.removeByType(name);
440
        default      : return 0;
441
        }
442
      }
443
    
444
///////////////////////////////////////////////////////////////////////////////////////////////////
445
/**
446
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
447
 * 
448
 * @param id Effect ID we want to print info about
449
 * @return <code>true</code> if a single Effect of type effectType has been found.
450
 */
451
    
452
    public boolean printEffect(long id)
453
      {
454
      int type = (int)(id&EffectTypes.MASK);
455

    
456
      if( type==EffectTypes.MATRIX.type   )  return mM.printByID(id>>EffectTypes.LENGTH);
457
      if( type==EffectTypes.VERTEX.type   )  return mV.printByID(id>>EffectTypes.LENGTH);
458
      if( type==EffectTypes.FRAGMENT.type )  return mF.printByID(id>>EffectTypes.LENGTH);
459
      if( type==EffectTypes.OTHER.type    )  return mO.printByID(id>>EffectTypes.LENGTH);
460

    
461
      return false;
462
      }
463
   
464
///////////////////////////////////////////////////////////////////////////////////////////////////   
465
///////////////////////////////////////////////////////////////////////////////////////////////////
466
// Individual effect functions.
467
///////////////////////////////////////////////////////////////////////////////////////////////////
468
// Matrix-based effects
469
///////////////////////////////////////////////////////////////////////////////////////////////////
470
// MOVE
471
/**
472
 * Moves the Object by a vector that changes in time as interpolated by the Interpolator.
473
 * 
474
 * @param vector 3-dimensional Interpolator which at any given time will return a Float3D
475
 *               representing the current coordinates of the vector we want to move the Object with.
476
 * @return       ID of the effect added, or -1 if we failed to add one.
477
 */
478
  public long move(Interpolator3D vector)
479
    {   
480
    return mM.add(EffectNames.MOVE,vector);
481
    }
482

    
483
///////////////////////////////////////////////////////////////////////////////////////////////////
484
/**
485
 * Moves the Object by a vector that smoothly changes from (0,0,0) to (x,y,z).
486
 *  
487
 * @param x        The x-coordinate of the vector we want to move the Object with. 
488
 * @param y        The y-coordinate of the vector we want to move the Object with.
489
 * @param z        The z-coordinate of the vector we want to move the Object with.
490
 * @param duration The time, in milliseconds, it takes to complete the movement.
491
 * @return         ID of the effect added, or -1 if we failed to add one. 
492
 */
493
  public long move(float x,float y,float z, int duration)
494
    {   
495
    Interpolator3D di = new Interpolator3D();  
496
    di.setCount(0.5f);
497
    di.setDuration(duration);
498
    di.add(new Float3D(0.0f,0.0f,0.0f));                             
499
    di.add(new Float3D(x,y,z));                        
500

    
501
    return mM.add(EffectNames.MOVE,di);
502
    }
503

    
504
///////////////////////////////////////////////////////////////////////////////////////////////////
505
/**
506
 * Moves the Object by vector (x,y,z) immediately.
507
 *   
508
 * @param x The x-coordinate of the vector we want to move the Object with. 
509
 * @param y The y-coordinate of the vector we want to move the Object with.
510
 * @param z The z-coordinate of the vector we want to move the Object with.
511
 * @return  ID of the effect added, or -1 if we failed to add one. 
512
 */
513
  public long move(float x,float y,float z)
514
    {   
515
    return mM.add(EffectNames.MOVE,mZero3D,x,y,z,0.0f);
516
    }
517

    
518
///////////////////////////////////////////////////////////////////////////////////////////////////
519
// SCALE
520
/**
521
 * Scales the Object by factors that change in time as returned by the Interpolator.
522
 * 
523
 * @param scale 3-dimensional Interpolator which at any given time returns a Float3D
524
 *              representing the current x- , y- and z- scale factors.
525
 * @return      ID of the effect added, or -1 if we failed to add one.
526
 */
527
  public long scale(Interpolator3D scale)
528
    {   
529
    return mM.add(EffectNames.SCALE,scale);
530
    }
531

    
532
///////////////////////////////////////////////////////////////////////////////////////////////////
533
/**
534
 * Scales the Object by a factor that smoothly changes from (1,1,1) at time 0 to (xscale,yscale,zscale)
535
 * after 'duration' milliseconds. 
536
 *    
537
 * @param xscale   After time 'duration' passes, Bitmap's width will get multiplied by xscale; e.g. if 
538
 *                 xscale=2, after 'duration' milliseconds the Object will become twice broader.
539
 * @param yscale   Factor to scale Object's height with.
540
 * @param zscale   Factor to scale Object's depth with.
541
 * @param duration Time, in milliseconds, it takes to interpolate to the full (xscale,yscale,zscale) scaling factors.
542
 * @return         ID of the effect added, or -1 if we failed to add one. 
543
 */
544
  public long scale(float xscale,float yscale,float zscale, int duration)
545
    {   
546
    Interpolator3D di = new Interpolator3D();  
547
    di.setCount(0.5f);
548
    di.setDuration(duration);
549
    di.add(new Float3D(1.0f,1.0f,1.0f));                             
550
    di.add(new Float3D(xscale,yscale,zscale));                        
551

    
552
    return mM.add(EffectNames.SCALE,di);
553
    }
554

    
555
///////////////////////////////////////////////////////////////////////////////////////////////////
556
/**
557
 * Immediately scales the Object's width by (xscale,yscale,zscale).   
558
 *   
559
 * @param xscale Object's width gets multiplied by this factor; e.g. if 
560
 *               xscale=2, the Object immediately becomes twice broader.
561
 * @param yscale factor to scale Object's height with.
562
 * @param zscale factor to scale Object's depth with. 
563
 * @return       ID of the effect added, or -1 if we failed to add one. 
564
 */
565
  public long scale(float xscale,float yscale,float zscale)
566
    {   
567
    return mM.add(EffectNames.SCALE,mZero3D,xscale,yscale,zscale,0.0f);
568
    }
569

    
570
///////////////////////////////////////////////////////////////////////////////////////////////////
571
/**
572
 * Convenience function - scale the Object by the same factor in all 3 dimensions.   
573
 *   
574
 * @param scale all 3 Object's dimensions get multiplied by this factor; e.g. if 
575
 *              scale=2, the Object immediately becomes twice larger.
576
 * @return      ID of the effect added, or -1 if we failed to add one. 
577
 */
578
  public long scale(float scale)
579
    {   
580
    return mM.add(EffectNames.SCALE,mZero3D,scale,scale,scale,0.0f);
581
    }
582
    
583
///////////////////////////////////////////////////////////////////////////////////////////////////
584
// ROTATE
585
/**
586
 * Rotates the Object around a (possibly moving) point, with angle and axis that change in time.
587
 * 
588
 * @param center    3-dimensional Interpolator which at any given time will return the current center
589
 *                  of the rotation
590
 * @param angleAxis 4-dimensional Interpolator which at any given time will return a Float4D
591
 *                  representing the current rotation in the (angle,axisX,axisY,axisY) form.
592
 * @return          ID of the effect added, or -1 if we failed to add one.
593
 */
594
  public long rotate(Interpolator3D center, Interpolator4D angleAxis)
595
    {   
596
    return mM.add(EffectNames.ROTATE, center, angleAxis);
597
    }
598

    
599
///////////////////////////////////////////////////////////////////////////////////////////////////  
600
/**
601
 * Rotates the Object around a static point, with angle and axis that change in time.
602
 * 
603
 * @param center    Center of the rotation
604
 * @param angleAxis 4-dimensional Interpolator which at any given time will return a Float4D
605
 *                  representing the current rotation in the (angle,axisX,axisY,axisY) form.
606
 * @return          ID of the effect added, or -1 if we failed to add one.
607
 */
608
  public long rotate(Float3D center, Interpolator4D angleAxis)
609
    {   
610
    return mM.add(EffectNames.ROTATE, center , angleAxis);
611
    }
612
  
613
///////////////////////////////////////////////////////////////////////////////////////////////////  
614
/**
615
 * Rotates the Object around a static point, with angle that changes in time, around axis 
616
 * (axisX, axisY, axisZ). 
617
 * 
618
 * @param center Center of the rotation
619
 * @param angle  1-dimensional Interpolator which at any given time will return the current rotation
620
 *               angle.
621
 * @param axisX  Rotation vector: x-coordinate
622
 * @param axisY  Rotation vector: y-coordinate
623
 * @param axisZ  Rotation vector: z-coordinate
624
 * @return       ID of the effect added, or -1 if we failed to add one.
625
 */
626
  public long rotate(Float3D center, Interpolator1D angle, float axisX, float axisY, float axisZ)
627
    {   
628
    return mM.add(EffectNames.ROTATE, center , angle, axisX, axisY, axisZ);
629
    }
630
  
631
///////////////////////////////////////////////////////////////////////////////////////////////////
632
/**
633
 * Rotates the Object around a (possibly moving) point, with angle that changes in time.
634
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
635
 * 
636
 * @param center 3-dimensional Interpolator which at any given time will return the current center
637
 *               of the rotation.
638
 * @param angle  1-dimensional Interpolator which returns the current rotation angle.
639
 * @return       ID of the effect added, or -1 if we failed to add one.
640
 */
641
  public long rotate(Interpolator3D center, Interpolator1D angle)
642
    {   
643
    return mM.add(EffectNames.ROTATE, center, angle, 0.0f,0.0f,1.0f);
644
    }
645

    
646
///////////////////////////////////////////////////////////////////////////////////////////////////
647
/**
648
 * Rotates the Object around a constant point, with angle that changes in time.  
649
 * Axis of rotation is the vector (0,0,1), i.e. a vector normal to the screen surface.
650
 *   
651
 * @param center   Coordinates of the Point we are rotating around.
652
 * @param angle    Angle that we want to rotate the Bitmap to. Unit: degrees
653
 * @param duration Time, in milliseconds, it takes to complete one rotation from 0 to 'angle' degrees.
654
 * @return         ID of the effect added, or -1 if we failed to add one. 
655
 */
656
  public long rotate(Float3D center, int angle, int duration)
657
    {   
658
    Interpolator1D di = new Interpolator1D();  
659
    di.setCount(0.5f);
660
    di.setDuration(duration);
661
    di.add(new Float1D(    0));                             
662
    di.add(new Float1D(angle));                        
663

    
664
    return mM.add(EffectNames.ROTATE, center, di, 0.0f,0.0f,1.0f);
665
    }
666

    
667
///////////////////////////////////////////////////////////////////////////////////////////////////
668
/**
669
 * Rotates the Object immediately by 'angle' degrees around point p.   
670
 * Axis of rotation is given by the last 3 floats.
671
 *   
672
 * @param center Coordinates of the Point we are rotating around.
673
 * @param angle  Angle that we want to rotate the Bitmap to. Unit: degrees
674
 * @param axisX  Axis of rotation: x-coordinate
675
 * @param axisY  Axis of rotation: y-coordinate
676
 * @param axisZ  Axis of rotation: z-coordinate
677
 * @return       ID of the effect added, or -1 if we failed to add one.
678
 */
679
  public long rotate(Float3D center, float angle, float axisX, float axisY, float axisZ)
680
    {   
681
    return mM.add(EffectNames.ROTATE, center, angle, axisX, axisY, axisZ);
682
    }
683
  
684
///////////////////////////////////////////////////////////////////////////////////////////////////
685
/**
686
 * Rotates the Object immediately by 'angle' degrees around point p.   
687
 *   
688
 * @param center Coordinates of the Point we are rotating around.
689
 * @param angle  The angle that we want to rotate the Bitmap to. Unit: degrees
690
 * @return       ID of the effect added, or -1 if we failed to add one. 
691
 */
692
  public long rotate(Float3D center, int angle)
693
    {   
694
    return mM.add(EffectNames.ROTATE, center, angle,0.0f,0.0f,1.0f);
695
    }
696

    
697
///////////////////////////////////////////////////////////////////////////////////////////////////
698
// QUATERNION
699
/**
700
 * Rotates the Object immediately by quaternion (qX,qY,qZ,qW).
701
 *   
702
 * @param center Coordinates of the Point we are rotating around.
703
 * @param qX     Quaternion: x-coordinate
704
 * @param qY     Quaternion: y-coordinate
705
 * @param qZ     Quaternion: z-coordinate
706
 * @param qW     Quaternion: w-coordinate
707
 * @return       ID of the effect added, or -1 if we failed to add one.
708
 */
709
  public long quaternion(Float3D center, float qX, float qY, float qZ, float qW)
710
    {   
711
    return mM.add(EffectNames.QUATERNION,center,qX,qY,qZ,qW);
712
    }
713

    
714
///////////////////////////////////////////////////////////////////////////////////////////////////
715
/**
716
 * Rotates the Object by a quaternion that's at the moment returned by the InterpolatorQuat.
717
 *   
718
 * @param center Coordinates of the Point we are rotating around.
719
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion.
720
 * @return       ID of the effect added, or -1 if we failed to add one.
721
 */
722
  public long quaternion(Float3D center, InterpolatorQuat quat)
723
    {   
724
    return mM.add(EffectNames.QUATERNION, center, quat);
725
    }
726

    
727
///////////////////////////////////////////////////////////////////////////////////////////////////
728
/**
729
 * Rotates the Object around a moving point by a quaternion that's at the moment returned by the InterpolatorQuat.
730
 *   
731
 * @param center Interpolator that returns the current center of rotation.
732
 * @param quat   Interpolator that's going to, at any given moment, return a quaternion representing
733
 *               the current rotation.
734
 * @return       ID of the effect added, or -1 if we failed to add one.
735
 */
736
  public long quaternion(Interpolator3D center, InterpolatorQuat quat)
737
    {   
738
    return mM.add(EffectNames.QUATERNION,center,quat);
739
    }
740
  
741
///////////////////////////////////////////////////////////////////////////////////////////////////
742
// SHEAR
743
/**
744
 * Shears the Object. If the Interpolator is 1D, it will shear along the X-axis. 2D Interpolator adds
745
 * shearing along the Y-axis, 3D one along Z axis.
746
 *
747
 * @param center  Center of shearing, i.e. the point which stays unmoved.
748
 * @param shear   1- 2- or 3D Interpolator which, at any given point, returns the ordered 1-, 2-
749
 *                or 3-tuple of shear factors.
750
 * @return        ID of the effect added, or -1 if we failed to add one.
751
 */
752
  public long shear(Float3D center, Interpolator shear)
753
    {
754
    return mM.add(EffectNames.SHEAR, center, shear);
755
    }
756

    
757
///////////////////////////////////////////////////////////////////////////////////////////////////
758
/**
759
 * Shears the Object in 3D. Order: first X shearing, then Y, then Z.
760
 * 
761
 * @param center Center of shearing, i.e. the point which stays unmoved.
762
 * @param shear  ordered 3-tuple (x-degree, y-degree, z-degree) of shearing (tangent of the angle with
763
 *               which the X,Y and Z axis get slanted) 
764
 * @return       ID of the effect added, or -1 if we failed to add one. 
765
 */
766
  public long shear(Float3D center, Float3D shear)
767
    {
768
    Interpolator3D di = new Interpolator3D(); 
769
    di.setCount(0.5f);
770
    di.setDuration(0);
771
    di.add(new Float3D(0.0f,0.0f,0.0f));              
772
    di.add(shear);
773
        
774
    return mM.add(EffectNames.SHEAR, center, di );
775
    }
776

    
777
///////////////////////////////////////////////////////////////////////////////////////////////////
778
// Fragment-based effects  
779
///////////////////////////////////////////////////////////////////////////////////////////////////
780
// MACROBLOCK
781
/**
782
 * Creates macroblocks at and around point defined by the Interpolator2D and the Region. 
783
 * Size of the macroblocks at any given time is returned by the Interpolator1D.
784
 * 
785
 * @param size   1-dimensional Interpolator which, at any given time, returns the size of the macroblocks.
786
 * @param region Region this Effect is limited to.
787
 *               Null here means 'apply the effect to the whole Bitmap'.
788
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
789
 *               current center of the effect.
790
 * @return       ID of the effect added, or -1 if we failed to add one. 
791
 */
792
  public long macroblock(Interpolator1D size, Float4D region, Interpolator2D center)
793
    {
794
    return mF.add(EffectNames.MACROBLOCK, size, region, center);
795
    }
796

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

    
840
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
841
    }
842

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

    
869
    return mF.add(EffectNames.MACROBLOCK, di, region, center);
870
    }
871

    
872
///////////////////////////////////////////////////////////////////////////////////////////////////
873
/**
874
 * Creates macroblocks on the whole Object.
875
 * <p>
876
 * The macroblocks change in size; at time 0 there are none, and after 'duration/2' milliseconds 
877
 * they are of (pixels X pixels) size; after 'duration' milliseconds there are again none (i.e. their
878
 * size is 1X1, i.e. 1 pixel).   
879
 * <p>
880
 * The difference between this and the previous method is that here there is no masking Region; thus
881
 * there is also no center of the Effect. 
882
 *    
883
 * @param pixels   Maximum size, in pixels, of the Macroblocks we want to see.
884
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
885
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
886
 * @return         ID of the effect added, or -1 if we failed to add one. 
887
 */
888
  public long macroblock(int pixels, int duration, float count) 
889
    {
890
    Interpolator1D di = new Interpolator1D(); 
891
    di.setCount(count);
892
    di.setDuration(duration);
893
    di.add(new Float1D(1));                            
894
    di.add(new Float1D(pixels));                        
895
   
896
    return mF.add(EffectNames.MACROBLOCK, di, null, mZero2D);
897
    }
898

    
899
///////////////////////////////////////////////////////////////////////////////////////////////////
900
///////////////////////////////////////////////////////////////////////////////////////////////////
901
// CHROMA
902
/**
903
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
904
 *        
905
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
906
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
907
 * @param color  Color to mix. (1,0,0) is RED.
908
 * @param region Region this Effect is limited to. 
909
 *               Null here means 'apply the Effect to the whole Bitmap'.
910
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing
911
 *               the current center of the effect.
912
 * @return       ID of the effect added, or -1 if we failed to add one. 
913
 */
914
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
915
    {
916
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
917
    }
918

    
919
///////////////////////////////////////////////////////////////////////////////////////////////////
920
/**
921
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
922
 * <p>
923
 * Here the center of the Effect stays constant.
924
 *         
925
 * @param blend  1-dimensional Interpolator that returns the level of blend a given pixel will be
926
 *               mixed with the next parameter 'color': pixel = (1-level)*pixel + level*color
927
 * @param color  Color to mix. (1,0,0) is RED.
928
 * @param region Region this Effect is limited to. 
929
 *               Null here means 'apply the Effect to the whole Bitmap'.
930
 * @param center Center of the Effect.
931
 * @return       ID of the effect added, or -1 if we failed to add one. 
932
 */
933
  public long chroma(Interpolator1D blend, Float3D color, Float4D region, Float2D center)
934
    {
935
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
936
    }
937

    
938
///////////////////////////////////////////////////////////////////////////////////////////////////  
939
/**
940
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
941
 *        
942
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
943
 *               pixel = (1-t)*pixel + t*color
944
 * @param color  Color to mix. (1,0,0) is RED.
945
 * @param region Region this Effect is limited to.
946
 *               Null here means 'apply the Effect to the whole Bitmap'.
947
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
948
 *               current center of the effect.
949
 * @return       ID of the effect added, or -1 if we failed to add one. 
950
 */
951
  public long chroma(float blend, Float3D color, Float4D region, Interpolator2D center)
952
    {
953
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
954
    }
955

    
956
///// //////////////////////////////////////////////////////////////////////////////////////////////
957
/**
958
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
959
 * <p>
960
 * Here the center of the Effect stays constant.
961
 *         
962
 * @param blend  Level of blend a given pixel will be mixed with the next parameter 'color':
963
 *               pixel = (1-t)*pixel + t*color
964
 * @param color  Color to mix. (1,0,0) is RED.
965
 * @param region The Region this Effect is limited to. 
966
 *               Null here means 'apply the Effect to the whole Bitmap'.
967
 * @param center Center of the Effect.
968
 * @return       ID of the effect added, or -1 if we failed to add one. 
969
 */
970
  public long chroma(float blend, Float3D color, Float4D region, Float2D center)
971
    {
972
    return mF.add(EffectNames.CHROMA, blend, color, region, center);
973
    }
974

    
975
///////////////////////////////////////////////////////////////////////////////////////////////////
976
/**
977
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
978
 * <p>
979
 * Here the Effect applies to the whole bitmap.
980
 *         
981
 * @param blend Level of blend a given pixel will be mixed with the next parameter 'color':
982
 *              pixel = (1-t)*pixel + t*color
983
 * @param color Color to mix. (1,0,0) is RED.
984
 * @return      ID of the effect added, or -1 if we failed to add one. 
985
 */
986
  public long chroma(float blend, Float3D color)
987
    {
988
    return mF.add(EffectNames.CHROMA, blend, color, null, mZero2D);
989
    }
990

    
991
///////////////////////////////////////////////////////////////////////////////////////////////////  
992
/**
993
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
994
 * 
995
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Interpolator2D)}
996
 */
997
  public long smooth_chroma(Interpolator1D blend, Float3D color, Float4D region, Interpolator2D center)
998
    {
999
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1000
    }
1001

    
1002
///////////////////////////////////////////////////////////////////////////////////////////////////
1003
/**
1004
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1005
 * 
1006
 * See {@link #chroma(Interpolator1D, Float3D, Float4D, Float2D)}
1007
 */
1008
  public long smooth_chroma(Interpolator1D blend, Float3D color, Float4D region, Float2D center)
1009
    {
1010
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1011
    }
1012
  
1013
///////////////////////////////////////////////////////////////////////////////////////////////////  
1014
/**
1015
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1016
 * 
1017
 * See {@link #chroma(float, Float3D, Float4D, Interpolator2D)}
1018
 */
1019
  public long smooth_chroma(float blend, Float3D color, Float4D region, Interpolator2D center)
1020
    {
1021
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1022
    }
1023

    
1024
///////////////////////////////////////////////////////////////////////////////////////////////////
1025
/**
1026
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1027
 * 
1028
 * See {@link #chroma(float, Float3D, Float4D, Float2D)}
1029
 */
1030
  public long smooth_chroma(float blend, Float3D color, Float4D region, Float2D center)
1031
    {
1032
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, region, center);
1033
    }
1034
  
1035
///////////////////////////////////////////////////////////////////////////////////////////////////
1036
/**
1037
 * Makes a certain sub-region of the Object smoothly change all three of its RGB components.
1038
 * 
1039
 * See {@link #chroma(float, Float3D)}
1040
 */
1041
  public long smooth_chroma(float blend, Float3D color)
1042
    {
1043
    return mF.add(EffectNames.SMOOTH_CHROMA, blend, color, null, mZero2D);
1044
    }
1045
  
1046
///////////////////////////////////////////////////////////////////////////////////////////////////
1047
///////////////////////////////////////////////////////////////////////////////////////////////////
1048
// ALPHA
1049
/**
1050
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1051
 *        
1052
 * @param alpha  1-dimensional Interpolator that returns the level of transparency we want to have at any given
1053
 *               moment.
1054
 * @param region Region this Effect is limited to. 
1055
 *               Null here means 'apply the Effect to the whole Object'.
1056
 * @param center 2-dimensional Interpolator which, at any given time, returns a Float2D representing the
1057
 *               current center of the effect.
1058
 * @return       ID of the effect added, or -1 if we failed to add one. 
1059
 */
1060
  public long alpha(Interpolator1D alpha, Float4D region, Interpolator2D center)
1061
    {
1062
    return mF.add(EffectNames.ALPHA, alpha, region, center);
1063
    }
1064

    
1065
///////////////////////////////////////////////////////////////////////////////////////////////////
1066
/**
1067
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1068
 * <p>
1069
 * Here the center of the Effect stays constant.
1070
 *         
1071
 * @param alpha  1-dimensional Interpolator that returns the level of transparency we want to have at any given
1072
 *               moment.
1073
 * @param region Region this Effect is limited to. 
1074
 *               Null here means 'apply the Effect to the whole Object'.
1075
 * @param center Center of the Effect.
1076
 * @return       ID of the effect added, or -1 if we failed to add one. 
1077
 */
1078
  public long alpha(Interpolator1D alpha, Float4D region, Float2D center)
1079
    {
1080
    return mF.add(EffectNames.ALPHA, alpha, region, center);
1081
    }
1082

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

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

    
1132
///////////////////////////////////////////////////////////////////////////////////////////////////
1133
/**
1134
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1135
 * <p>
1136
 * Here the center of the Effect stays constant and the effect for now change in time.
1137
 *         
1138
 * @param alpha  Level of Alpha (between 0 and 1) we want to interpolate to.
1139
 * @param region Region this Effect is limited to.
1140
 *               Null here means 'apply the Effect to the whole Object'.
1141
 * @param center Center of the Effect.
1142
 * @return       ID of the effect added, or -1 if we failed to add one. 
1143
 */
1144
  public long alpha(float alpha, Float4D region, Float2D center)
1145
    {
1146
    Interpolator1D di = new Interpolator1D(); 
1147
    di.setCount(0.5f);
1148
    di.setDuration(0);
1149
    di.add(new Float1D(1));                          
1150
    di.add(new Float1D(alpha));                         
1151
   
1152
    return mF.add(EffectNames.ALPHA, di, region, center);
1153
    }
1154
  
1155
///////////////////////////////////////////////////////////////////////////////////////////////////
1156
/**
1157
 * Makes the whole Object change its transparency level.
1158
 * 
1159
 * @param alpha    Level of Alpha (between 0 and 1) we want to interpolate to.
1160
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1161
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1162
 * @return         ID of the effect added, or -1 if we failed to add one. 
1163
 */
1164
  public long alpha(float alpha, int duration, float count) 
1165
    {
1166
    Interpolator1D di = new Interpolator1D(); 
1167
    di.setCount(count);
1168
    di.setDuration(duration);
1169
    di.add(new Float1D(1));                            
1170
    di.add(new Float1D(alpha));                        
1171
         
1172
    return mF.add(EffectNames.ALPHA, di,null, mZero2D);
1173
    }
1174

    
1175
///////////////////////////////////////////////////////////////////////////////////////////////////  
1176
/**
1177
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1178
 * 
1179
 * See {@link #alpha(Interpolator1D, Float4D, Interpolator2D)}
1180
 */
1181
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Interpolator2D center)
1182
    {
1183
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1184
    }
1185

    
1186
///////////////////////////////////////////////////////////////////////////////////////////////////
1187
/**
1188
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1189
 * 
1190
 * See {@link #alpha(Interpolator1D, Float4D, Float2D)}
1191
 */
1192
  public long smooth_alpha(Interpolator1D alpha, Float4D region, Float2D center)
1193
    {
1194
    return mF.add(EffectNames.SMOOTH_ALPHA, alpha, region, center);
1195
    }
1196
  
1197
///////////////////////////////////////////////////////////////////////////////////////////////////  
1198
/**
1199
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1200
 * 
1201
 * See {@link #alpha(float, Float4D, Interpolator2D, int, float)}
1202
 */
1203
  public long smooth_alpha(float alpha, Float4D region, Interpolator2D center, int duration, float count)
1204
    {
1205
    Interpolator1D di = new Interpolator1D(); 
1206
    di.setCount(count);
1207
    di.setDuration(duration);
1208
    di.add(new Float1D(1));                          
1209
    di.add(new Float1D(alpha));                         
1210
   
1211
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1212
    }
1213

    
1214
///////////////////////////////////////////////////////////////////////////////////////////////////
1215
/**
1216
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1217
 * 
1218
 * See {@link #alpha(float, Float4D, Float2D, int, float)}
1219
 */
1220
  public long smooth_alpha(float alpha, Float4D region, Float2D center, int duration, float count)
1221
    {
1222
    Interpolator1D di = new Interpolator1D(); 
1223
    di.setCount(count);
1224
    di.setDuration(duration);
1225
    di.add(new Float1D(1));                          
1226
    di.add(new Float1D(alpha));                         
1227
   
1228
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1229
    }
1230
  
1231
///////////////////////////////////////////////////////////////////////////////////////////////////
1232
/**
1233
 * Makes a certain sub-region of the Object smoothly change its transparency level.
1234
 * 
1235
 * See {@link #alpha(float, Float4D, Float2D)}
1236
 */
1237
  public long smooth_alpha(float alpha, Float4D region, Float2D center)
1238
    {
1239
    Interpolator1D di = new Interpolator1D(); 
1240
    di.setCount(0.5f);
1241
    di.setDuration(0);
1242
    di.add(new Float1D(1));                          
1243
    di.add(new Float1D(alpha));                         
1244
   
1245
    return mF.add(EffectNames.SMOOTH_ALPHA, di, region, center);
1246
    }
1247
  
1248
///////////////////////////////////////////////////////////////////////////////////////////////////
1249
///////////////////////////////////////////////////////////////////////////////////////////////////
1250
// BRIGHTNESS
1251
/**
1252
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1253
 *        
1254
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1255
 *                   at any given moment.
1256
 * @param region     Region this Effect is limited to.
1257
 *                   Null here means 'apply the Effect to the whole Object'.
1258
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D representing
1259
 *                   the current center of the effect.
1260
 * @return           ID of the effect added, or -1 if we failed to add one.
1261
 */
1262
  public long brightness(Interpolator1D brightness, Float4D region, Interpolator2D center)
1263
    {
1264
    return mF.add(EffectNames.BRIGHTNESS, brightness, region, center);
1265
    }
1266

    
1267
///////////////////////////////////////////////////////////////////////////////////////////////////
1268
/**
1269
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1270
 * <p>
1271
 * Here the center of the Effect stays constant.
1272
 *         
1273
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1274
 *                   at any given moment.
1275
 * @param region     Region this Effect is limited to.
1276
 *                   Null here means 'apply the Effect to the whole Object'.
1277
 * @param center     Center of the Effect.
1278
 * @return           ID of the effect added, or -1 if we failed to add one.
1279
 */
1280
  public long brightness(Interpolator1D brightness, Float4D region, Float2D center)
1281
    {
1282
    return mF.add(EffectNames.BRIGHTNESS, brightness, region, center);
1283
    }
1284

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

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

    
1338
///////////////////////////////////////////////////////////////////////////////////////////////////
1339
/**
1340
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1341
 * <p>
1342
 * Here the center of the Effect stays constant and the effect for now change in time.
1343
 *         
1344
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1345
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1346
 *                   anything more than 1 - lighten it up.
1347
 * @param region     Region this Effect is limited to.
1348
 *                   Null here means 'apply the Effect to the whole Object'.
1349
 * @param center     Center of the Effect.
1350
 * @return           ID of the effect added, or -1 if we failed to add one. 
1351
 */
1352
  public long brightness(float brightness, Float4D region, Float2D center)
1353
    {
1354
    Interpolator1D di = new Interpolator1D(); 
1355
    di.setCount(0.5f);
1356
    di.setDuration(0);
1357
    di.add(new Float1D(1));                          
1358
    di.add(new Float1D(brightness));                         
1359
   
1360
    return mF.add(EffectNames.BRIGHTNESS, di, region, center);
1361
    }
1362
 
1363
///////////////////////////////////////////////////////////////////////////////////////////////////
1364
///////////////////////////////////////////////////////////////////////////////////////////////////
1365
// SMOOTH BRIGHTNESS
1366
/**
1367
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1368
 *        
1369
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1370
 *                   at any given moment.
1371
 * @param region     Region this Effect is limited to.
1372
 *                   Null here means 'apply the Effect to the whole Object'.
1373
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1374
 *                   representing the current center of the effect.
1375
 * @return           ID of the effect added, or -1 if we failed to add one.
1376
 */
1377
  public long smooth_brightness(Interpolator1D brightness, Float4D region, Interpolator2D center)
1378
    {
1379
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, brightness, region, center);
1380
    }
1381

    
1382
///////////////////////////////////////////////////////////////////////////////////////////////////
1383
/**
1384
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1385
 * <p>
1386
 * Here the center of the Effect stays constant.
1387
 *         
1388
 * @param brightness 1-dimensional Interpolator that returns the level of brightness we want to have
1389
 *                   at any given moment.
1390
 * @param region     Region this Effect is limited to.
1391
 *                   Null here means 'apply the Effect to the whole Object'.
1392
 * @param center     Center of the Effect.
1393
 * @return           ID of the effect added, or -1 if we failed to add one.
1394
 */
1395
  public long smooth_brightness(Interpolator1D brightness, Float4D region, Float2D center)
1396
    {
1397
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, brightness, region, center);
1398
    }
1399

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

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

    
1453
///////////////////////////////////////////////////////////////////////////////////////////////////
1454
/**
1455
 * Makes a certain sub-region of the Object smoothly change its brightness level.
1456
 * <p>
1457
 * Here the center of the Effect stays constant and the effect for now change in time.
1458
 *         
1459
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1460
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1461
 *                   anything more than 1 - lighten it up.
1462
 * @param region     Region this Effect is limited to. 
1463
 *                   Null here means 'apply the Effect to the whole Object'.
1464
 * @param center     Center of the Effect.
1465
 * @return           ID of the effect added, or -1 if we failed to add one. 
1466
 */
1467
  public long smooth_brightness(float brightness, Float4D region, Float2D center)
1468
    {
1469
    Interpolator1D di = new Interpolator1D(); 
1470
    di.setCount(0.5f);
1471
    di.setDuration(0);
1472
    di.add(new Float1D(1));                          
1473
    di.add(new Float1D(brightness));                         
1474
   
1475
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di, region, center);
1476
    }
1477
    
1478
///////////////////////////////////////////////////////////////////////////////////////////////////
1479
/**
1480
 * Makes the whole Object change its brightness level.
1481
 * 
1482
 * @param brightness Level of Brightness (between 0 and infinity) we want to interpolate to.
1483
 *                   1 - level of brightness unchanged, anything less than 1 - 'darken the image',
1484
 *                   anything more than 1- lighten it up.
1485
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1486
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1487
 * @return           ID of the effect added, or -1 if we failed to add one. 
1488
 */
1489
  public long smooth_brightness(float brightness, int duration, float count) 
1490
    {
1491
    Interpolator1D di = new Interpolator1D(); 
1492
    di.setCount(count);
1493
    di.setDuration(duration);
1494
    di.add(new Float1D(1));                            
1495
    di.add(new Float1D(brightness));                        
1496
         
1497
    return mF.add(EffectNames.SMOOTH_BRIGHTNESS, di,null, mZero2D);
1498
    }
1499

    
1500
///////////////////////////////////////////////////////////////////////////////////////////////////
1501
///////////////////////////////////////////////////////////////////////////////////////////////////
1502
// CONTRAST
1503
/**
1504
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1505
 *        
1506
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1507
 *                 at any given moment.
1508
 * @param region   Region this Effect is limited to.
1509
 *                 Null here means 'apply the Effect to the whole Object'.
1510
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1511
 *                 representing the current center of the effect.
1512
 * @return         ID of the effect added, or -1 if we failed to add one.
1513
 */
1514
  public long contrast(Interpolator1D contrast, Float4D region, Interpolator2D center)
1515
    {
1516
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1517
    }
1518

    
1519
///////////////////////////////////////////////////////////////////////////////////////////////////
1520
/**
1521
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1522
 * <p>
1523
 * Here the center of the Effect stays constant.
1524
 *         
1525
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1526
 *                 at any given moment.
1527
 * @param region   Region this Effect is limited to.
1528
 *                 Null here means 'apply the Effect to the whole Object'.
1529
 * @param center  Center of the Effect.
1530
 * @return        ID of the effect added, or -1 if we failed to add one.
1531
 */
1532
  public long contrast(Interpolator1D contrast, Float4D region, Float2D center)
1533
    {
1534
    return mF.add(EffectNames.CONTRAST, contrast, region, center);
1535
    }
1536

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

    
1563
///////////////////////////////////////////////////////////////////////////////////////////////////
1564
/**
1565
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1566
 * <p>
1567
 * Here the center of the Effect stays constant.
1568
 *         
1569
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1570
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1571
 *                 anything more than 1 -increase the contrast. 
1572
 * @param region   Region this Effect is limited to. 
1573
 *                 Null here means 'apply the Effect to the whole Object'.
1574
 * @param center   Center of the Effect.
1575
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1576
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1577
 * @return         ID of the effect added, or -1 if we failed to add one. 
1578
 */
1579
  public long contrast(float contrast, Float4D region, Float2D center, int duration, float count)
1580
    {
1581
    Interpolator1D di = new Interpolator1D(); 
1582
    di.setCount(count);
1583
    di.setDuration(duration);
1584
    di.add(new Float1D(1));                          
1585
    di.add(new Float1D(contrast));                         
1586
   
1587
    return mF.add(EffectNames.CONTRAST, di, region, center);
1588
    }
1589

    
1590
///////////////////////////////////////////////////////////////////////////////////////////////////
1591
/**
1592
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1593
 * <p>
1594
 * Here the center of the Effect stays constant and the effect for now change in time.
1595
 *         
1596
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1597
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1598
 *                 anything more than 1 - increase the contrast. 
1599
 * @param region   Region this Effect is limited to. 
1600
 *                 Null here means 'apply the Effect to the whole Object'.
1601
 * @param center   Center of the Effect.
1602
 * @return         ID of the effect added, or -1 if we failed to add one. 
1603
 */
1604
  public long contrast(float contrast, Float4D region, Float2D center)
1605
    {
1606
    Interpolator1D di = new Interpolator1D(); 
1607
    di.setCount(0.5f);
1608
    di.setDuration(0);
1609
    di.add(new Float1D(1));                          
1610
    di.add(new Float1D(contrast));                         
1611
   
1612
    return mF.add(EffectNames.CONTRAST, di, region, center);
1613
    }
1614
 
1615
///////////////////////////////////////////////////////////////////////////////////////////////////
1616
///////////////////////////////////////////////////////////////////////////////////////////////////
1617
// SMOOTH CONTRAST
1618
/**
1619
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1620
 *        
1621
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1622
 *                 at any given moment.
1623
 * @param region   Region this Effect is limited to.
1624
 *                 Null here means 'apply the Effect to the whole Object'.
1625
 * @param center   2-dimensional Interpolator which, at any given time, returns a Float2D
1626
 *                 representing the current center of the effect.
1627
 * @return         ID of the effect added, or -1 if we failed to add one.
1628
 */
1629
  public long smooth_contrast(Interpolator1D contrast, Float4D region, Interpolator2D center)
1630
    {
1631
    return mF.add(EffectNames.SMOOTH_CONTRAST, contrast, region, center);
1632
    }
1633

    
1634
///////////////////////////////////////////////////////////////////////////////////////////////////
1635
/**
1636
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1637
 * <p>
1638
 * Here the center of the Effect stays constant.
1639
 *         
1640
 * @param contrast 1-dimensional Interpolator that returns the level of contrast we want to have
1641
 *                 at any given moment.
1642
 * @param region   Region this Effect is limited to.
1643
 *                 Null here means 'apply the Effect to the whole Object'.
1644
 * @param center   Center of the Effect.
1645
 * @return         ID of the effect added, or -1 if we failed to add one.
1646
 */
1647
  public long smooth_contrast(Interpolator1D contrast, Float4D region, Float2D center)
1648
    {
1649
    return mF.add(EffectNames.SMOOTH_CONTRAST, contrast, region, center);
1650
    }
1651

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

    
1678
///////////////////////////////////////////////////////////////////////////////////////////////////
1679
/**
1680
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1681
 * <p>
1682
 * Here the center of the Effect stays constant.
1683
 *         
1684
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1685
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1686
 *                 anything more than 1 - increase the contrast. 
1687
 * @param region   Region this Effect is limited to. 
1688
 *                 Null here means 'apply the Effect to the whole Object'.
1689
 * @param center   Center of the Effect.
1690
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1691
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1692
 * @return         ID of the effect added, or -1 if we failed to add one. 
1693
 */
1694
  public long smooth_contrast(float contrast, Float4D region, Float2D center, int duration, float count)
1695
    {
1696
    Interpolator1D di = new Interpolator1D(); 
1697
    di.setCount(count);
1698
    di.setDuration(duration);
1699
    di.add(new Float1D(1));                          
1700
    di.add(new Float1D(contrast));                         
1701
   
1702
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, center);
1703
    }
1704

    
1705
///////////////////////////////////////////////////////////////////////////////////////////////////
1706
/**
1707
 * Makes a certain sub-region of the Object smoothly change its contrast level.
1708
 * <p>
1709
 * Here the center of the Effect stays constant and the effect for now change in time.
1710
 *         
1711
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1712
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1713
 *                 anything more than 1 - increase the contrast. 
1714
 * @param region   Region this Effect is limited to. 
1715
 *                 Null here means 'apply the Effect to the whole Object'.
1716
 * @param center   Center of the Effect.
1717
 * @return         ID of the effect added, or -1 if we failed to add one. 
1718
 */
1719
  public long smooth_contrast(float contrast, Float4D region, Float2D center)
1720
    {
1721
    Interpolator1D di = new Interpolator1D(); 
1722
    di.setCount(0.5f);
1723
    di.setDuration(0);
1724
    di.add(new Float1D(1));                          
1725
    di.add(new Float1D(contrast));                         
1726
   
1727
    return mF.add(EffectNames.SMOOTH_CONTRAST, di, region, center);
1728
    }
1729
    
1730
///////////////////////////////////////////////////////////////////////////////////////////////////
1731
/**
1732
 * Makes the whole Object change its contrast level.
1733
 * 
1734
 * @param contrast Level of contrast (between 0 and infinity) we want to interpolate to.
1735
 *                 1 - level of contrast unchanged, anything less than 1 - reduce contrast,
1736
 *                 anything more than 1 - increase the contrast.
1737
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
1738
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1739
 * @return         ID of the effect added, or -1 if we failed to add one. 
1740
 */
1741
  public long smooth_contrast(float contrast, int duration, float count) 
1742
    {
1743
    Interpolator1D di = new Interpolator1D(); 
1744
    di.setCount(count);
1745
    di.setDuration(duration);
1746
    di.add(new Float1D(1));                            
1747
    di.add(new Float1D(contrast));                        
1748
         
1749
    return mF.add(EffectNames.SMOOTH_CONTRAST, di,null, mZero2D);
1750
    }
1751

    
1752

    
1753
///////////////////////////////////////////////////////////////////////////////////////////////////
1754
///////////////////////////////////////////////////////////////////////////////////////////////////
1755
// SATURATION
1756
/**
1757
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1758
 *        
1759
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1760
 *                   at any given moment.
1761
 * @param region     Region this Effect is limited to.
1762
 *                   Null here means 'apply the Effect to the whole Object'.
1763
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1764
 *                   representing the current center of the effect.
1765
 * @return           ID of the effect added, or -1 if we failed to add one.
1766
 */
1767
  public long saturation(Interpolator1D saturation, Float4D region, Interpolator2D center)
1768
    {
1769
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1770
    }
1771

    
1772
///////////////////////////////////////////////////////////////////////////////////////////////////
1773
/**
1774
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1775
 * <p>
1776
 * Here the center of the Effect stays constant.
1777
 *         
1778
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1779
 *                   at any given moment.
1780
 * @param region     Region this Effect is limited to.
1781
 *                   Null here means 'apply the Effect to the whole Object'.
1782
 * @param center     Center of the Effect.
1783
 * @return           ID of the effect added, or -1 if we failed to add one.
1784
 */
1785
  public long saturation(Interpolator1D saturation, Float4D region, Float2D center)
1786
    {
1787
    return mF.add(EffectNames.SATURATION, saturation, region, center);
1788
    }
1789

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

    
1816
///////////////////////////////////////////////////////////////////////////////////////////////////
1817
/**
1818
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1819
 * <p>
1820
 * Here the center of the Effect stays constant.
1821
 *         
1822
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1823
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1824
 *                   anything more than 1 - increase the saturation. 
1825
 * @param region     Region this Effect is limited to. 
1826
 *                   Null here means 'apply the Effect to the whole Object'.
1827
 * @param center     Center of the Effect.
1828
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1829
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1830
 * @return           ID of the effect added, or -1 if we failed to add one. 
1831
 */
1832
  public long saturation(float saturation, Float4D region, Float2D center, int duration, float count)
1833
    {
1834
    Interpolator1D di = new Interpolator1D(); 
1835
    di.setCount(count);
1836
    di.setDuration(duration);
1837
    di.add(new Float1D(1));                          
1838
    di.add(new Float1D(saturation));                         
1839
   
1840
    return mF.add(EffectNames.SATURATION, di, region, center);
1841
    }
1842

    
1843
///////////////////////////////////////////////////////////////////////////////////////////////////
1844
/**
1845
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1846
 * <p>
1847
 * Here the center of the Effect stays constant and the effect for now change in time.
1848
 *         
1849
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1850
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1851
 *                   anything more than 1- increase the saturation. 
1852
 * @param region     Region this Effect is limited to. 
1853
 *                   Null here means 'apply the Effect to the whole Object'.
1854
 * @param center     Center of the Effect.
1855
 * @return           ID of the effect added, or -1 if we failed to add one. 
1856
 */
1857
  public long saturation(float saturation, Float4D region, Float2D center)
1858
    {
1859
    Interpolator1D di = new Interpolator1D(); 
1860
    di.setCount(0.5f);
1861
    di.setDuration(0);
1862
    di.add(new Float1D(1));                          
1863
    di.add(new Float1D(saturation));                         
1864
   
1865
    return mF.add(EffectNames.SATURATION, di, region, center);
1866
    }
1867
 
1868
///////////////////////////////////////////////////////////////////////////////////////////////////
1869
///////////////////////////////////////////////////////////////////////////////////////////////////
1870
// SMOOTH_SATURATION
1871
/**
1872
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1873
 *        
1874
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1875
 *                   at any given moment.
1876
 * @param region     Region this Effect is limited to.
1877
 *                   Null here means 'apply the Effect to the whole Object'.
1878
 * @param center     2-dimensional Interpolator which, at any given time, returns a Float2D
1879
 *                   representing the current center of the effect.
1880
 * @return           ID of the effect added, or -1 if we failed to add one.
1881
 */
1882
  public long smooth_saturation(Interpolator1D saturation, Float4D region, Interpolator2D center)
1883
    {
1884
    return mF.add(EffectNames.SMOOTH_SATURATION, saturation, region, center);
1885
    }
1886

    
1887
///////////////////////////////////////////////////////////////////////////////////////////////////
1888
/**
1889
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1890
 * <p>
1891
 * Here the center of the Effect stays constant.
1892
 *         
1893
 * @param saturation 1-dimensional Interpolator that returns the level of saturation we want to have
1894
 *                   at any given moment.
1895
 * @param region     Region this Effect is limited to.
1896
 *                   Null here means 'apply the Effect to the whole Object'.
1897
 * @param center     Center of the Effect.
1898
 * @return           ID of the effect added, or -1 if we failed to add one.
1899
 */
1900
  public long smooth_saturation(Interpolator1D saturation, Float4D region, Float2D center)
1901
    {
1902
    return mF.add(EffectNames.SMOOTH_SATURATION, saturation, region, center);
1903
    }
1904

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

    
1931
///////////////////////////////////////////////////////////////////////////////////////////////////
1932
/**
1933
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1934
 * <p>
1935
 * Here the center of the Effect stays constant.
1936
 *         
1937
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1938
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1939
 *                   anything more than 1 - increase the saturation. 
1940
 * @param region     Region this Effect is limited to. 
1941
 *                   Null here means 'apply the Effect to the whole Object'.
1942
 * @param center     Center of the Effect.
1943
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1944
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1945
 * @return           ID of the effect added, or -1 if we failed to add one. 
1946
 */
1947
  public long smooth_saturation(float saturation, Float4D region, Float2D center, int duration, float count)
1948
    {
1949
    Interpolator1D di = new Interpolator1D(); 
1950
    di.setCount(count);
1951
    di.setDuration(duration);
1952
    di.add(new Float1D(1));                          
1953
    di.add(new Float1D(saturation));                         
1954
   
1955
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, center);
1956
    }
1957

    
1958
///////////////////////////////////////////////////////////////////////////////////////////////////
1959
/**
1960
 * Makes a certain sub-region of the Object smoothly change its saturation level.
1961
 * <p>
1962
 * Here the center of the Effect stays constant and the effect for now change in time.
1963
 *         
1964
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1965
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1966
 *                   anything more than 1 - increase the saturation. 
1967
 * @param region     Region this Effect is limited to. 
1968
 *                   Null here means 'apply the Effect to the whole Object'.
1969
 * @param center     Center of the Effect.
1970
 * @return           ID of the effect added, or -1 if we failed to add one. 
1971
 */
1972
  public long smooth_saturation(float saturation, Float4D region, Float2D center)
1973
    {
1974
    Interpolator1D di = new Interpolator1D(); 
1975
    di.setCount(0.5f);
1976
    di.setDuration(0);
1977
    di.add(new Float1D(1));                          
1978
    di.add(new Float1D(saturation));                         
1979
   
1980
    return mF.add(EffectNames.SMOOTH_SATURATION, di, region, center);
1981
    }
1982
    
1983
///////////////////////////////////////////////////////////////////////////////////////////////////
1984
/**
1985
 * Makes the whole Object change its saturation level.
1986
 * 
1987
 * @param saturation Level of saturation (between 0 and infinity) we want to interpolate to.
1988
 *                   1 - level of saturation unchanged, anything less than 1 - reduce saturation,
1989
 *                   anything more than 1 - increase the saturation. 
1990
 * @param duration   Time, in milliseconds, it takes to do one full interpolation.
1991
 * @param count      Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
1992
 * @return           ID of the effect added, or -1 if we failed to add one. 
1993
 */
1994
  public long smooth_saturation(float saturation, int duration, float count) 
1995
    {
1996
    Interpolator1D di = new Interpolator1D(); 
1997
    di.setCount(count);
1998
    di.setDuration(duration);
1999
    di.add(new Float1D(1));                            
2000
    di.add(new Float1D(saturation));                        
2001
         
2002
    return mF.add(EffectNames.SMOOTH_SATURATION, di,null, mZero2D);
2003
    }
2004
            
2005
///////////////////////////////////////////////////////////////////////////////////////////////////
2006
// Vertex-based effects  
2007
///////////////////////////////////////////////////////////////////////////////////////////////////
2008
// DISTORT
2009
/**
2010
 * Distort a (possibly changing in time) part of the Object by a (possibly changing in time) vector of force.
2011
 * 
2012
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2013
 *               represents the vector the Center of the Effect is currently being dragged with.
2014
 * @param region Region that masks the effect of the Distortion.
2015
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2016
 *               the Center of the Effect.
2017
 * @return       ID of the effect added, or -1 if we failed to add one. 
2018
 */
2019
  public long distort(Interpolator vector, Float4D region, Interpolator2D center)
2020
    {  
2021
    return mV.add(EffectNames.DISTORT, vector, region, center);
2022
    }
2023

    
2024
///////////////////////////////////////////////////////////////////////////////////////////////////
2025
/**
2026
 * Distort part of the Object by a (possibly changing in time) vector of force.
2027
 * <p>
2028
 * Difference between this and the previous method is that here the center of the Effect stays constant.
2029
 *   
2030
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2031
 *               represents the vector the Center of the Effect is currently being dragged with.
2032
 * @param region Region that masks the effect of the Distortion.
2033
 * @param center Center of the Effect.
2034
 * @return       ID of the effect added, or -1 if we failed to add one. 
2035
 */
2036
  public long distort(Interpolator vector, Float4D region, Float2D center)
2037
    {  
2038
    return mV.add(EffectNames.DISTORT, vector, region, center);
2039
    }
2040

    
2041
///////////////////////////////////////////////////////////////////////////////////////////////////
2042
/**
2043
 * Distort the whole Object by a (possibly changing in time) vector of force.
2044
 * 
2045
 * @param vector 2- or 3-dimensional Interpolator that returns a 2- or 3-dimensional Point which
2046
 *               represents the vector the Center of the Effect is currently being dragged with.
2047
 * @param center Center of the Effect.
2048
 * @return       ID of the effect added, or -1 if we failed to add one.
2049
 */
2050
  public long distort(Interpolator vector, Float2D center)
2051
    {
2052
    return mV.add(EffectNames.DISTORT, vector, null, center);
2053
    }
2054

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

    
2077
///////////////////////////////////////////////////////////////////////////////////////////////////
2078
/**
2079
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
2080
 * 
2081
 * @param vector   Maximum vector of force.
2082
 * @param center   Center of the Effect.
2083
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2084
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2085
 * @return         ID of the effect added, or -1 if we failed to add one. 
2086
 */
2087
  public long distort(Float3D vector, Float2D center, int duration, float count)
2088
    {
2089
    Interpolator3D di = new Interpolator3D(); 
2090
    di.setCount(count);
2091
    di.setDuration(duration);
2092
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2093
    di.add(vector);                                                 
2094
           
2095
    return mV.add(EffectNames.DISTORT, di, null, center);
2096
    }
2097

    
2098
///////////////////////////////////////////////////////////////////////////////////////////////////
2099
/**
2100
 * Distort the whole Object by a vector of force that changes from (0,0,0) to v.
2101
 * <p>
2102
 * Difference between this and the previous method is that here the vector of force will get interpolated
2103
 * to the maximum v and the effect will end. We are thus limited to count=0.5.
2104
 * 
2105
 * @param vector   Maximum, final vector of force.
2106
 * @param center   Center of the Effect.
2107
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2108
 * @return         ID of the effect added, or -1 if we failed to add one. 
2109
 */
2110
  public long distort(Float3D vector, Float2D center, int duration)
2111
    {
2112
    Interpolator3D di = new Interpolator3D();  
2113
    di.setCount(0.5f);
2114
    di.setDuration(duration);
2115
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2116
    di.add(vector);                 
2117
           
2118
    return mV.add(EffectNames.DISTORT, di, null, center);
2119
    }
2120

    
2121
///////////////////////////////////////////////////////////////////////////////////////////////////
2122
/**
2123
 * Distort the whole Object by a vector of force v.
2124
 * <p>
2125
 * Here we apply a constant vector of force.
2126
 * 
2127
 * @param vector Vector of force.
2128
 * @param center Center of the Effect.
2129
 * @return       ID of the effect added, or -1 if we failed to add one. 
2130
 */
2131
  public long distort(Float3D vector, Float2D center )
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.DISTORT, di, null, center);
2140
    }
2141

    
2142
///////////////////////////////////////////////////////////////////////////////////////////////////
2143
///////////////////////////////////////////////////////////////////////////////////////////////////
2144
// DEFORM
2145
/**
2146
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
2147
 * a (possibly changing in time) point on the Bitmap.
2148
 *     
2149
 * @param vector Interpolator that, at any given time, returns a Float2D representing vector of
2150
 *               force that deforms the shape of the whole Bitmap.
2151
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2152
 *               the Center of the Effect.
2153
 * @return       ID of the effect added, or -1 if we failed to add one.
2154
 */
2155
  public long deform(Interpolator vector, Interpolator2D center)
2156
    {  
2157
    return mV.add(EffectNames.DEFORM, vector, null, center);
2158
    }
2159

    
2160
///////////////////////////////////////////////////////////////////////////////////////////////////
2161
/**
2162
 * Deform the shape of the whole Object with a (possibly changing in time) vector of force applied to
2163
 * a constant point on the Bitmap.
2164
 * 
2165
 * @param vector Interpolator that, at any given time, returns a Float2D representing
2166
 *               vector of force that deforms the shape of the whole Bitmap.
2167
 * @param center Center of the Effect.
2168
 * @return       ID of the effect added, or -1 if we failed to add one.
2169
 */
2170
  public long deform(Interpolator vector, Float2D center)
2171
    {
2172
    return mV.add(EffectNames.DEFORM, vector, null, center);
2173
    }
2174

    
2175
///////////////////////////////////////////////////////////////////////////////////////////////////
2176
/**
2177
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2178
 * applied to a constant point on the Object.
2179
 * 
2180
 * @param vector   Vector of force.
2181
 * @param center   Center of the Effect.
2182
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2183
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2184
 * @return         ID of the effect added, or -1 if we failed to add one. 
2185
 */
2186
  public long deform(Float3D vector, Float2D center, int duration, float count)
2187
    {
2188
    Interpolator3D di = new Interpolator3D(); 
2189
    di.setCount(count);
2190
    di.setDuration(duration);
2191
    di.add(new Float3D(0.0f,0.0f,0.0f));               
2192
    di.add(vector);                
2193
           
2194
    return mV.add(EffectNames.DEFORM, di, null, center);
2195
    }
2196

    
2197
///////////////////////////////////////////////////////////////////////////////////////////////////
2198
/**
2199
 * Deform the shape of the whole Object with a vector of force smoothly changing from (0,0,0) to v
2200
 * applied to a constant point on the Object.
2201
 * <p>
2202
 * Identical to calling the previous method with count=0.5.
2203
 * 
2204
 * @param vector   Final vector of force.
2205
 * @param center   Center of the Effect.
2206
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2207
 * @return         ID of the effect added, or -1 if we failed to add one. 
2208
 */
2209
  public long deform(Float3D vector, Float2D center, int duration)
2210
    {
2211
    Interpolator3D di = new Interpolator3D();  
2212
    di.setCount(0.5f);
2213
    di.setDuration(duration);
2214
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2215
    di.add(vector);             
2216
           
2217
    return mV.add(EffectNames.DEFORM, di, null, center);
2218
    }
2219

    
2220
///////////////////////////////////////////////////////////////////////////////////////////////////
2221
/**
2222
 * Deform the shape of the whole Object with a constant vector of force applied to a constant
2223
 * point on the Object.
2224
 * 
2225
 * @param vector Vector of force.
2226
 * @param center Center of the Effect.
2227
 * @return       ID of the effect added, or -1 if we failed to add one. 
2228
 */
2229
  public long deform(Float3D vector, Float2D center )
2230
    {
2231
    Interpolator3D di = new Interpolator3D(); 
2232
    di.setCount(0.5f);
2233
    di.setDuration(0);
2234
    di.add(new Float3D(0.0f,0.0f,0.0f));              
2235
    di.add(vector);            
2236
           
2237
    return mV.add(EffectNames.DEFORM, di, null, center);
2238
    }
2239
   
2240
///////////////////////////////////////////////////////////////////////////////////////////////////  
2241
///////////////////////////////////////////////////////////////////////////////////////////////////
2242
// SINK
2243
/**
2244
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2245
 * away from the center (degree<=1)
2246
 *    
2247
 * @param sink   1-dimensional Interpolator which, at any given time, returns a Point1D representing
2248
 *               the current degree of the effect.
2249
 * @param region Region that masks the effect of the Sink.
2250
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2251
 *               the Center of the Effect.
2252
 * @return       ID of the effect added, or -1 if we failed to add one. 
2253
 */
2254
  public long sink(Interpolator1D sink, Float4D region, Interpolator2D center)
2255
    {
2256
    return mV.add(EffectNames.SINK, sink, region, center);
2257
    }
2258

    
2259
///////////////////////////////////////////////////////////////////////////////////////////////////
2260
/**
2261
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2262
 * away from the center (degree<=1).
2263
 * <p>
2264
 * Here the Center stays constant.
2265
 *      
2266
 * @param sink   1-dimensional Interpolator which, at any given time, returns a Point1D
2267
 *               representing the current degree of the effect.
2268
 * @param region Region that masks the effect of the Sink.
2269
 * @param center Center of the Effect.
2270
 * @return       ID of the effect added, or -1 if we failed to add one. 
2271
 */
2272
  public long sink(Interpolator1D sink, Float4D region, Float2D center)
2273
    {
2274
    return mV.add(EffectNames.SINK, sink, region, center);
2275
    }
2276
  
2277
///////////////////////////////////////////////////////////////////////////////////////////////////
2278
/**
2279
 * Pull all points around the center of the effect towards the center (if degree>=1) or push them 
2280
 * away from the center (degree<=1).
2281
 * <p>
2282
 * Here we can only interpolate between 1 and degree.
2283
 * 
2284
 * @param sink     How much to push or pull. Between 0 and infinity.
2285
 * @param region   Region that masks the effect of the Sink.
2286
 * @param center   2-dimensional Interpolator that, at any given time, returns a Point2D representing
2287
 *                 the Center of the Effect.
2288
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2289
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2290
 * @return         ID of the effect added, or -1 if we failed to add one. 
2291
 */
2292
  public long sink(float sink, Float4D region, Interpolator2D center, int duration, float count)
2293
    {
2294
    Interpolator1D di = new Interpolator1D(); 
2295
    di.setCount(count);
2296
    di.setDuration(duration);
2297
    di.add(new Float1D(1));                                
2298
    di.add(new Float1D(sink));
2299
    
2300
    return mV.add(EffectNames.SINK, di, region, center);
2301
    }
2302

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

    
2326
///////////////////////////////////////////////////////////////////////////////////////////////////
2327
/**
2328
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2329
 * away from the center (degree<=1).
2330
 * 
2331
 * @param sink     How much to push or pull. Between 0 and infinity.
2332
 * @param center   Center of the Effect.
2333
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2334
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2335
 * @return         ID of the effect added, or -1 if we failed to add one. 
2336
 */
2337
  public long sink(float sink, Float2D center, int duration, float count)
2338
    {
2339
    Interpolator1D di = new Interpolator1D();  
2340
    di.setCount(count);
2341
    di.setDuration(duration);
2342
    di.add(new Float1D(1));                                
2343
    di.add(new Float1D(sink));
2344
         
2345
    return mV.add(EffectNames.SINK, di, null, center);
2346
    }
2347

    
2348
///////////////////////////////////////////////////////////////////////////////////////////////////
2349
/**
2350
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2351
 * away from the center (degree<=1).
2352
 * <p>
2353
 * Equivalent to calling the previous method with count=0.5.
2354
 * 
2355
 * @param sink     How much to push or pull. Between 0 and infinity.
2356
 * @param center   Center of the Effect.
2357
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2358
 * @return         ID of the effect added, or -1 if we failed to add one. 
2359
 */
2360
  public long sink(float sink, Float2D center, int duration)
2361
    {
2362
    Interpolator1D di = new Interpolator1D(); 
2363
    di.setCount(0.5f);
2364
    di.setDuration(duration);
2365
    di.add(new Float1D(1));                               
2366
    di.add(new Float1D(sink));
2367
        
2368
    return mV.add(EffectNames.SINK, di, null, center);
2369
    }
2370

    
2371
///////////////////////////////////////////////////////////////////////////////////////////////////
2372
/**
2373
 * Pull all points of the Object towards the center of the Effect (if degree>=1) or push them
2374
 * away from the center (degree<=1).
2375
 * <p>
2376
 * Equivalent of calling the previous method with duration=0; i.e. we pull immediately.
2377
 * 
2378
 * @param sink   How much to push or pull. Between 0 and infinity.
2379
 * @param center Center of the Effect.
2380
 * @return       ID of the effect added, or -1 if we failed to add one. 
2381
 */
2382
  public long sink(float sink, Float2D center)
2383
    {
2384
    Interpolator1D di = new Interpolator1D(); 
2385
    di.setCount(0.5f);
2386
    di.setDuration(0);
2387
    di.add(new Float1D(1));                               
2388
    di.add(new Float1D(sink));
2389
        
2390
    return mV.add(EffectNames.SINK, di, null, center);
2391
    }
2392
  
2393
///////////////////////////////////////////////////////////////////////////////////////////////////  
2394
///////////////////////////////////////////////////////////////////////////////////////////////////
2395
// SWIRL
2396
/**
2397
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
2398
 * Interpolator). 
2399
 *   
2400
 * @param swirl  1-dimensional Interpolator which, at any given time, returns a Point1D representing
2401
 *               the degree of Swirl.
2402
 * @param region Region that masks the effect of the Swirl.
2403
 * @param center 2-dimensional Interpolator that, at any given time, returns a Point2D representing
2404
 *               the Center of the Effect.
2405
 * @return       ID of the effect added, or -1 if we failed to add one. 
2406
 */
2407
  public long swirl(Interpolator1D swirl, Float4D region, Interpolator2D center)
2408
    {    
2409
    return mV.add(EffectNames.SWIRL, swirl, region, center);
2410
    }
2411

    
2412
///////////////////////////////////////////////////////////////////////////////////////////////////
2413
/**
2414
 * Rotate part of the Object around the Center of the Effect by a certain angle (as returned by the
2415
 * Interpolator).
2416
 * <p>
2417
 * Here the Center stays constant.
2418
 *      
2419
 * @param swirl  1-dimensional Interpolator which, at any given time, returns a Point1D representing
2420
 *               the degree of Swirl.
2421
 * @param region Region that masks the effect of the Swirl.
2422
 * @param center Center of the Effect.
2423
 * @return       ID of the effect added, or -1 if we failed to add one. 
2424
 */
2425
  public long swirl(Interpolator1D swirl, Float4D region, Float2D center)
2426
    {    
2427
    return mV.add(EffectNames.SWIRL, swirl, region, center);
2428
    }
2429
 
2430
///////////////////////////////////////////////////////////////////////////////////////////////////
2431
/**
2432
 * Rotate part of the Object around the Center of the Effect by 'degree' angle.
2433
 *   
2434
 * @param swirl    Angle of rotation. Unit: degrees.
2435
 * @param region   Region that masks the effect of the Swirl.
2436
 * @param center   2-dimensional Interpolator that, at any given time, returns a Point2D representing
2437
 *                 the Center of the Effect.
2438
 * @return         ID of the effect added, or -1 if we failed to add one.
2439
 */
2440
  public long swirl(int swirl, Float4D region, Interpolator2D center)
2441
    {
2442
    Interpolator1D di = new Interpolator1D();
2443
    di.setCount(0.5f);
2444
    di.setDuration(0);
2445
    di.add(new Float1D(0));                                
2446
    di.add(new Float1D(swirl));
2447
    
2448
    return mV.add(EffectNames.SWIRL, di, region, center);
2449
    }
2450

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

    
2475
///////////////////////////////////////////////////////////////////////////////////////////////////
2476
/**
2477
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2478
 * 
2479
 * @param swirl    Angle of rotation. Unit: degrees.
2480
 * @param center   Center of the Effect.
2481
 * @param duration Time, in milliseconds, it takes to do one full interpolation.
2482
 * @param count    Controls how many interpolations we want to do. See {@link Interpolator#setCount(float)}
2483
 * @return         ID of the effect added, or -1 if we failed to add one. 
2484
 */
2485
  public long swirl(int swirl, Float2D center, int duration, float count)
2486
    {
2487
    Interpolator1D di = new Interpolator1D();  
2488
    di.setCount(count);
2489
    di.setDuration(duration);
2490
    di.add(new Float1D(0));                                
2491
    di.add(new Float1D(swirl));
2492
         
2493
    return mV.add(EffectNames.SWIRL, di, null, center);
2494
    }
2495

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

    
2518
///////////////////////////////////////////////////////////////////////////////////////////////////
2519
/**
2520
 * Rotate the whole Object around the Center of the Effect by 'degree' angle.
2521
 * <p>
2522
 * Equivalent to calling the previous method with duration=0.
2523
 * 
2524
 * @param swirl  Angle of rotation. Unit: degrees.
2525
 * @param center Center of the Effect.
2526
 * @return       ID of the effect added, or -1 if we failed to add one. 
2527
 */
2528
  public long swirl(int swirl, Float2D center)
2529
    {
2530
    Interpolator1D di = new Interpolator1D(); 
2531
    di.setCount(0.5f);
2532
    di.setDuration(0);
2533
    di.add(new Float1D(0));                               
2534
    di.add(new Float1D(swirl));
2535
        
2536
    return mV.add(EffectNames.SWIRL, di, null, center);
2537
    }
2538

    
2539
///////////////////////////////////////////////////////////////////////////////////////////////////
2540
///////////////////////////////////////////////////////////////////////////////////////////////////
2541
// WAVE
2542

    
2543
///////////////////////////////////////////////////////////////////////////////////////////////////   
2544
///////////////////////////////////////////////////////////////////////////////////////////////////
2545
// Other-based effects
2546
///////////////////////////////////////////////////////////////////////////////////////////////////
2547
// SAVE_PNG
2548
/**
2549
 * Save the current state of the Object that's backing up our DistortedObject to a PNG file.
2550
 *
2551
 * @param filename Full path to the file.
2552
 * @return         ID of the effect added, or -1 if we failed to add one.
2553
 */
2554
 public long savePNG(String filename, int left, int top, int width, int height)
2555
   {
2556
   return mO.add(EffectNames.SAVE_PNG, filename, left, top, width, height);
2557
   }
2558
}
(5-5/30)