User Tools

Site Tools


sample_code:torch

Differences

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

Link to this comparison view

sample_code:torch [2016/07/06 16:45]
sandudhate
sample_code:torch [2016/08/29 14:14]
Line 1: Line 1:
-**Simple Torch** 
  
-<code JavaScript Torch.js> 
-//Called when application is started. 
-function OnStart() 
-{ 
-    //Create a layout 
-    lay = app.CreateLayout( "linear", "VCenter,FillXY" );     
-     lay.SetBackColor("#ff999999") 
-     //Create Camera view 
-     cam = app.CreateCameraView( .003,.003 ); 
-     cam.SetOnReady( capture )   
-     lay.AddChild( cam ) 
-    //Create a text label and add it to layout. 
-    txt = app.CreateText( "Torch" ); 
-    txt.SetTextColor("#ff000000") 
-    txt.SetTextSize( 32 ); 
-    lay.AddChild( txt ); 
-     
-     //Create 'Use Flash' check box.  
-    chkFlash = app.CreateCheckBox( "Off" );  
-    chkFlash.SetMargins( 0,0.1,0,0 );  
-    chkFlash.SetOnTouch( chkFlash_OnTouch );  
-    lay.AddChild( chkFlash );  
-    //Add layout to app.     
-    app.AddLayout( lay ); 
-} 
-   //Start Preview 
-   function capture()   
-   { 
-    cam.StartPreview(); 
-   } 
- 
-//Handle 'Use Flash' checkbox touch  
-    function chkFlash_OnTouch(value)  
-   {  
-    cam.SetFlash(value);  
-    if(value==true) chkFlash.SetText("On"); 
-     else chkFlash.SetText("Off"); 
-   }  
-</code> 
sample_code/torch.txt · Last modified: 2016/08/29 14:14 (external edit)