User Tools

Site Tools


sample_code:image_rotate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sample_code:image_rotate [2016/08/16 13:42]
gamecreator created image rotate sample
sample_code:image_rotate [2016/08/16 22:05]
Line 1: Line 1:
-**Battery Level** 
- 
-This is a simple app that displays battery level and also notifies it on the notification bar. 
- 
-<code JavaScript> 
-//globals 
-xm=4; ym=4; //images x×y 
-i=0; //rotation counter 
- 
-//Called when application is started. 
- 
-function OnStart() { 
- lay=app.CreateLayout("Linear","FillXY"); 
- 
- canv=app.CreateImage(null,1,1,"fix",480,800); 
- canv.SetAutoUpdate(false); 
- lay.AddChild(canv); 
- 
- app.AddLayout(lay); 
-  
- img=app.CreateImage("/Sys/Img/Hello.png"); 
- setInterval(rotate) 
-} 
- 
-function rotate() { 
- i+=0.0005; //rotation value 
- 
- canv.Clear(); //clear canvas 
- 
- for (a=0; a<xm; a++) { 
- for (b=0; b<ym; b++) { 
- //draw images 
- Vs=Math.sin(180*(i+b/ym+a/xm)); 
- Vc=Math.cos(180*(i+b/ym+a/xm)); 
- canv.DrawImageMtx(img,[Vs,0,-Vs/3+a/xm+1/xm/2,Vc/3,1,-Vc/16+b/ym+1/ym/2-0.2,0,0,1]); 
- }} 
-canv.Update(); //update canvas 
-} 
-</code> 
  
sample_code/image_rotate.txt · Last modified: 2016/08/16 22:05 (external edit)