Project

General

Profile

« Previous | Next » 

Revision 02a4ac20

Added by Leszek Koltunski over 7 years ago

Progress with support for Effect classes. Almost compiles now!

View differences:

src/main/java/org/distorted/library/effect/PostprocessEffectBlur.java
34 34
  private static final boolean SUPPORTS_REGION = false;
35 35

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

  
37
/**
38
 * Blur the object.
39
 *
40
 * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
41
 *               take into account 10 pixels in each direction.
42
 */
38 43
  public PostprocessEffectBlur(Data1D radius)
39 44
    {
40 45
    super(BLUR,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
src/main/java/org/distorted/library/effect/PostprocessEffectGlow.java
37 37
  private static final boolean SUPPORTS_REGION = false;
38 38

  
39 39
///////////////////////////////////////////////////////////////////////////////////////////////////
40

  
40
/**
41
 * Make the object glow with a specific color and a halo of specific radius.
42
 *
43
 * @param radius The 'strength' if the effect, in pixels. 0 = no halo, 10 = halo of roughly 10 pixels
44
 *               around the whole object.
45
 * @param color  RGBA of the color with which to draw the glow.
46
 */
41 47
  public PostprocessEffectGlow(Data1D radius, Data4D color)
42 48
    {
43 49
    super(GLOW,UNITIES,DIMENSION,SUPPORTS_CENTER,SUPPORTS_REGION,NAME);
src/main/java/org/distorted/library/main/DistortedEffectsPostprocess.java
21 21

  
22 22
import org.distorted.library.effect.Effect;
23 23
import org.distorted.library.message.EffectListener;
24
import org.distorted.library.type.Data1D;
25
import org.distorted.library.type.Data4D;
26 24

  
27 25
import java.util.ArrayList;
28 26

  
......
227 225
    mP.deregisterForMessages(el);
228 226
    }
229 227

  
228

  
230 229
///////////////////////////////////////////////////////////////////////////////////////////////////
231 230
/**
232 231
 * Aborts all Effects.
233 232
 * @return Number of effects aborted.
234 233
 */
235
  @SuppressWarnings("unused")
236 234
  public int abortAllEffects()
237
      {
238
      return mP.abortAll(true);
239
      }
235
    {
236
    return mP.abortAll(true);
237
    }
240 238

  
241 239
///////////////////////////////////////////////////////////////////////////////////////////////////
242 240
/**
243
 * Aborts all Effects of a given type (currently only POSTPROCESSING Effects).
244
 * 
245
 * @param type one of the constants defined in {@link org.distorted.library.effect.Effect}
241
 * Aborts all Effects of a given type, for example all POSTPROCESS Effects.
242
 *
243
 * @param type one of the constants defined in {@link Effect}
246 244
 * @return Number of effects aborted.
247 245
 */
248
  @SuppressWarnings("unused")
249
  public int abortEffects(int type)
246
  public int abortByType(int type)
250 247
    {
251 248
    switch(type)
252 249
      {
......
254 251
      default                : return 0;
255 252
      }
256 253
    }
257
    
254

  
258 255
///////////////////////////////////////////////////////////////////////////////////////////////////
259 256
/**
260 257
 * Aborts a single Effect.
261
 * 
262
 * @param id ID of the Effect we want to abort.
258
 *
259
 * @param effect the Effect we want to abort.
263 260
 * @return number of Effects aborted. Always either 0 or 1.
264 261
 */
265
  @SuppressWarnings("unused")
266
  public int abortEffect(long id)
267
    {
268
    int type = (int)(id&Effect.MASK);
269

  
270
    if( type==Effect.POSTPROCESS ) return mP.removeByID(id>>Effect.LENGTH);
271

  
272
    return 0;
273
    }
274

  
275
///////////////////////////////////////////////////////////////////////////////////////////////////
276
/**
277
 * Abort all Effects of a given name, for example all blurs.
278
 * 
279
 * @param name one of the constants defined in {@link org.distorted.library.effect.PostprocessEffect}
280
 * @return number of Effects aborted.
281
 */
282
  @SuppressWarnings("unused")
283
  public int abortEffects(int name)
262
  public int abortEffect(Effect effect)
284 263
    {
285
    switch(name.getType())
264
    switch(effect.getType())
286 265
      {
287
      case POSTPROCESS: return mP.removeByType(name);
288
      default         : return 0;
266
      case Effect.POSTPROCESS: return mP.removeEffect(effect);
267
      default                : return 0;
289 268
      }
290 269
    }
291
    
292
///////////////////////////////////////////////////////////////////////////////////////////////////
293
/**
294
 * Print some info about a given Effect to Android's standard out. Used for debugging only.
295
 * 
296
 * @param id Effect ID we want to print info about
297
 * @return <code>true</code> if a single Effect of type effectType has been found.
298
 */
299
  @SuppressWarnings("unused")
300
  public boolean printEffect(long id)
301
    {
302
    int type = (int)(id&EffectTypes.MASK);
303

  
304
    if( type==EffectTypes.POSTPROCESS.type )  return mP.printByID(id>>EffectTypes.LENGTH);
305

  
306
    return false;
307
    }
308 270

  
309 271
///////////////////////////////////////////////////////////////////////////////////////////////////
310 272
/**
......
315 277
  @SuppressWarnings("unused")
316 278
  public static int getMaxPostprocess()
317 279
    {
318
    return EffectQueue.getMax(EffectTypes.POSTPROCESS.ordinal());
280
    return EffectQueue.getMax(Effect.POSTPROCESS);
319 281
    }
320 282

  
321 283
///////////////////////////////////////////////////////////////////////////////////////////////////
......
337 299
  @SuppressWarnings("unused")
338 300
  public static boolean setMaxPostprocess(int max)
339 301
    {
340
    return EffectQueue.setMax(EffectTypes.POSTPROCESS.ordinal(),max);
302
    return EffectQueue.setMax(Effect.POSTPROCESS,max);
341 303
    }
342 304

  
343 305
///////////////////////////////////////////////////////////////////////////////////////////////////
......
356 318
    DistortedMaster.newSlave(this);
357 319
    }
358 320

  
359
///////////////////////////////////////////////////////////////////////////////////////////////////   
360
///////////////////////////////////////////////////////////////////////////////////////////////////
361
// Individual effect functions.
362
///////////////////////////////////////////////////////////////////////////////////////////////////
363
// Postprocess-based effects
364 321
///////////////////////////////////////////////////////////////////////////////////////////////////
365 322
/**
366
 * Blur the object.
323
 * Add a new Effect to our queue.
367 324
 *
368
 * @param radius The 'strength' if the effect, in pixels. 0 = no blur, 10 = when blurring a given pixel,
369
 *               take into account 10 pixels in each direction.
370
 * @return ID of the effect added, or -1 if we failed to add one.
325
 * @param effect The Effect to add.
371 326
 */
372
  public long blur(Data1D radius)
327
  public void apply(Effect effect)
373 328
    {
374
    return mP.add(EffectNames.BLUR, radius);
375
    }
376

  
377
///////////////////////////////////////////////////////////////////////////////////////////////////
378
/**
379
 * Make the object glow with a specific color and a halo of specific radius.
380
 *
381
 * @param radius The 'strength' if the effect, in pixels. 0 = no halo, 10 = halo of roughly 10 pixels
382
 *               around the whole object.
383
 * @param color  RGBA of the color with which to draw the glow.
384
 * @return ID of the effect added, or -1 if we failed to add one.
385
 */
386
  public long glow(Data1D radius, Data4D color)
387
    {
388
    return mP.add(EffectNames.GLOW, radius, color);
329
    switch(effect.getType())
330
      {
331
      case Effect.POSTPROCESS : mP.add(effect); break;
332
      }
389 333
    }
390 334
  }

Also available in: Unified diff