Revision f209a803
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/examples/TableOfContents.java | ||
---|---|---|
137 | 137 |
|
138 | 138 |
@Override |
139 | 139 |
public void onCreate(Bundle savedInstanceState) |
140 |
{ |
|
141 |
super.onCreate(savedInstanceState); |
|
142 |
setContentView(R.layout.table_of_contents); |
|
140 |
{
|
|
141 |
super.onCreate(savedInstanceState);
|
|
142 |
setContentView(R.layout.table_of_contents);
|
|
143 | 143 |
|
144 |
final List<Map<String, Object>> data = new ArrayList<>(); |
|
145 |
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>(); |
|
144 |
final List<Map<String, Object>> data = new ArrayList<>();
|
|
145 |
final SparseArray<Class<? extends Activity>> activityMapping = new SparseArray<>();
|
|
146 | 146 |
|
147 |
int index=0; |
|
147 |
int index=0;
|
|
148 | 148 |
|
149 |
for( Application app : Application.values() ) |
|
150 |
{ |
|
151 |
final Map<String, Object> item = new HashMap<>(); |
|
152 |
item.put(ITEM_IMAGE, app.icon); |
|
153 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title)); |
|
154 |
item.put(ITEM_SUBTITLE, getText(app.subtitle)); |
|
155 |
data.add(item); |
|
156 |
activityMapping.put(index++, app.activity); |
|
157 |
} |
|
149 |
for( Application app : Application.values() )
|
|
150 |
{
|
|
151 |
final Map<String, Object> item = new HashMap<>();
|
|
152 |
item.put(ITEM_IMAGE, app.icon);
|
|
153 |
item.put(ITEM_TITLE, (index+1)+". "+getText(app.title));
|
|
154 |
item.put(ITEM_SUBTITLE, getText(app.subtitle));
|
|
155 |
data.add(item);
|
|
156 |
activityMapping.put(index++, app.activity);
|
|
157 |
}
|
|
158 | 158 |
|
159 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this, |
|
160 |
data, |
|
161 |
R.layout.toc_item, |
|
162 |
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE}, |
|
163 |
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} ); |
|
164 |
setListAdapter(dataAdapter);
|
|
159 |
final SimpleAdapter dataAdapter = new SimpleAdapter( this,
|
|
160 |
data,
|
|
161 |
R.layout.toc_item,
|
|
162 |
new String[] {ITEM_IMAGE, ITEM_TITLE, ITEM_SUBTITLE},
|
|
163 |
new int[] {R.id.Image, R.id.Title, R.id.SubTitle} );
|
|
164 |
setListAdapter(dataAdapter);
|
|
165 | 165 |
|
166 |
getListView().setOnItemClickListener(new OnItemClickListener() |
|
167 |
{ |
|
168 |
@Override |
|
169 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
166 |
getListView().setOnItemClickListener(new OnItemClickListener() |
|
170 | 167 |
{ |
171 |
final Class<? extends Activity> activityToLaunch = activityMapping.get(position); |
|
172 |
|
|
173 |
if (activityToLaunch != null) |
|
168 |
@Override |
|
169 |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) |
|
174 | 170 |
{ |
175 |
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch); |
|
176 |
startActivity(launchIntent); |
|
177 |
} |
|
178 |
} |
|
179 |
}); |
|
180 |
} |
|
171 |
final Class<? extends Activity> activityToLaunch = activityMapping.get(position); |
|
172 |
|
|
173 |
if (activityToLaunch != null) |
|
174 |
{ |
|
175 |
final Intent launchIntent = new Intent(TableOfContents.this, activityToLaunch); |
|
176 |
startActivity(launchIntent); |
|
177 |
} |
|
178 |
} |
|
179 |
}); |
|
180 |
} |
|
181 | 181 |
} |
182 |
|
|
183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/examples/monalisa/MonaLisaRenderer.java | ||
---|---|---|
69 | 69 |
Static4D rRight = new Static4D( 10/320.0f, 5/366.0f, 0, 25/320.0f); |
70 | 70 |
|
71 | 71 |
// two dynamics for interpolating through vectors of distortion. Interpolate |
72 |
// every 1000 miliseconds, indefinately ('0.0f').
|
|
72 |
// every 1000 milliseconds, indefinitely ('0.0f').
|
|
73 | 73 |
Dynamic3D dLeft = new Dynamic3D(1000,0.0f); |
74 | 74 |
Dynamic3D dRight= new Dynamic3D(1000,0.0f); |
75 | 75 |
|
src/main/java/org/distorted/examples/sink/SinkRenderer.java | ||
---|---|---|
52 | 52 |
private DistortedTexture mTexture; |
53 | 53 |
private MeshRectangles mMesh; |
54 | 54 |
private Static3D mScale; |
55 |
private float mBmpRatio; |
|
55 | 56 |
|
56 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
57 | 58 |
|
... | ... | |
59 | 60 |
{ |
60 | 61 |
mView = v; |
61 | 62 |
|
62 |
Dynamic1D sink = new Dynamic1D(2000,0.0f); |
|
63 |
sink.add(new Static1D(1.0f)); |
|
64 |
sink.add(new Static1D(0.2f)); |
|
63 |
Dynamic1D sinkStrength = new Dynamic1D(2000,0.0f);
|
|
64 |
sinkStrength.add(new Static1D(1.0f));
|
|
65 |
sinkStrength.add(new Static1D(0.2f));
|
|
65 | 66 |
|
66 | 67 |
mEffects = new DistortedEffects(); |
67 |
VertexEffectSink sinkEffect = new VertexEffectSink(sink, new Static3D(0,0,0), null); |
|
68 |
|
|
69 |
// strength [changing in time from 1.0 to 0.2 and back], |
|
70 |
// center [(0,0,0), i.e. center of the bitmap], |
|
71 |
// region [null - apply to the whole bitmap |
|
72 |
VertexEffectSink sinkEffect = new VertexEffectSink(sinkStrength, new Static3D(0,0,0), null); |
|
68 | 73 |
mEffects.apply(sinkEffect); |
69 | 74 |
|
70 | 75 |
mScale = new Static3D(1,1,1); |
... | ... | |
84 | 89 |
|
85 | 90 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
86 | 91 |
{ |
87 |
float horiRatio = (float)width / mMesh.getStretchX(); |
|
88 |
float vertRatio = (float)height/ mMesh.getStretchY(); |
|
89 |
float factor = horiRatio > vertRatio ? vertRatio : horiRatio; |
|
92 |
float min= width>height ? height : width; |
|
90 | 93 |
|
91 |
mScale.set( factor,factor,factor );
|
|
94 |
mScale.set( min, min*mBmpRatio, 1 );
|
|
92 | 95 |
mScreen.resize(width, height); |
93 | 96 |
} |
94 | 97 |
|
... | ... | |
112 | 115 |
catch(IOException e) { } |
113 | 116 |
} |
114 | 117 |
|
115 |
int bmpHeight = bitmap.getHeight(); |
|
116 |
int bmpWidth = bitmap.getWidth(); |
|
118 |
mBmpRatio = (float)bitmap.getHeight()/bitmap.getWidth(); |
|
117 | 119 |
|
118 | 120 |
if( mTexture==null ) mTexture = new DistortedTexture(); |
119 | 121 |
mTexture.setTexture(bitmap); |
120 | 122 |
|
121 |
if( mMesh==null ) |
|
122 |
{ |
|
123 |
mMesh = new MeshRectangles(30,30*bmpHeight/bmpWidth); |
|
124 |
mMesh.setStretch(bmpWidth,bmpHeight,0); |
|
125 |
} |
|
123 |
if( mMesh==null ) mMesh = new MeshRectangles(30,(int)(30*mBmpRatio)); |
|
126 | 124 |
|
127 | 125 |
mScreen.detachAll(); |
128 | 126 |
mScreen.attach(mTexture,mEffects,mMesh); |
Also available in: Unified diff
Convert Sink to not use the depreciated MeshBase.setStretch() API.