Revision a1d92a36
Added by Leszek Koltunski over 8 years ago
| src/main/java/org/distorted/library/effect/FragmentEffectSaturation.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
public class FragmentEffectSaturation extends FragmentEffect |
| 32 | 32 |
{
|
| 33 |
private Data1D mSaturation; |
|
| 34 |
private Data4D mRegion; |
|
| 35 |
|
|
| 33 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 34 | 37 |
/** |
| 35 | 38 |
* Makes a certain sub-region of the Object smoothly change its saturation level. |
| ... | ... | |
| 43 | 46 |
{
|
| 44 | 47 |
super(smooth?EffectName.SMOOTH_SATURATION:EffectName.SATURATION); |
| 45 | 48 |
|
| 46 |
if( saturation instanceof Dynamic1D ) |
|
| 47 |
{
|
|
| 48 |
mDynamic0 = (Dynamic1D)saturation; |
|
| 49 |
} |
|
| 50 |
else if ( saturation instanceof Static1D ) |
|
| 51 |
{
|
|
| 52 |
mStatic0 = (Static1D)saturation; |
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
if( region == null ) |
|
| 56 |
{
|
|
| 57 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 58 |
} |
|
| 59 |
else |
|
| 60 |
{
|
|
| 61 |
if (region instanceof Static4D) |
|
| 62 |
{
|
|
| 63 |
mStaticRegion = (Static4D) region; |
|
| 64 |
} |
|
| 65 |
else if (region instanceof Dynamic4D) |
|
| 66 |
{
|
|
| 67 |
mDynamicRegion = (Dynamic4D) region; |
|
| 68 |
} |
|
| 69 |
} |
|
| 49 |
mSaturation = saturation; |
|
| 50 |
mRegion = (region==null ? new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE) : region); |
|
| 70 | 51 |
} |
| 71 | 52 |
|
| 72 | 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| ... | ... | |
| 80 | 61 |
{
|
| 81 | 62 |
super(EffectName.SATURATION); |
| 82 | 63 |
|
| 83 |
if( saturation instanceof Dynamic1D ) |
|
| 84 |
{
|
|
| 85 |
mDynamic0 = (Dynamic1D)saturation; |
|
| 86 |
} |
|
| 87 |
else if ( saturation instanceof Static1D ) |
|
| 88 |
{
|
|
| 89 |
mStatic0 = (Static1D)saturation; |
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
mStaticRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 64 |
mSaturation = saturation; |
|
| 65 |
mRegion = new Static4D(0,0,Float.MAX_VALUE, Float.MAX_VALUE); |
|
| 93 | 66 |
} |
| 94 | 67 |
|
| 95 | 68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 96 | 69 |
|
| 97 | 70 |
public boolean compute(float[] uniforms, int index, long currentDuration, long step ) |
| 98 | 71 |
{
|
| 99 |
if( mDynamicRegion!=null ) |
|
| 100 |
{
|
|
| 101 |
mDynamicRegion.interpolateMain(uniforms,index+4,currentDuration,step); |
|
| 102 |
} |
|
| 103 |
else |
|
| 104 |
{
|
|
| 105 |
uniforms[index+4] = mStaticRegion.getX(); |
|
| 106 |
uniforms[index+5] = mStaticRegion.getY(); |
|
| 107 |
uniforms[index+6] = mStaticRegion.getZ(); |
|
| 108 |
uniforms[index+7] = mStaticRegion.getW(); |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
if( mDynamic0!=null ) |
|
| 112 |
{
|
|
| 113 |
return mDynamic0.interpolateMain(uniforms,index,currentDuration,step); |
|
| 114 |
} |
|
| 115 |
else |
|
| 116 |
{
|
|
| 117 |
uniforms[index] = ((Static1D)mStatic0).getX(); |
|
| 118 |
return false; |
|
| 119 |
} |
|
| 72 |
mRegion.get(uniforms,index+4,currentDuration,step); |
|
| 73 |
return mSaturation.get(uniforms,index,currentDuration,step); |
|
| 120 | 74 |
} |
| 121 | 75 |
} |
Also available in: Unified diff
Beginnings of support for the unified Data data type.