This shows you the differences between two versions of the page.
sample_code:torch [2016/04/12 09:11] 196.102.170.202 created |
sample_code:torch [2016/08/29 14:14] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **Simple Torch** | ||
- | <code JavaScript Torch.js> | ||
- | // | ||
- | function OnStart() | ||
- | { | ||
- | // | ||
- | lay = app.CreateLayout( " | ||
- | lay.SetBackColor("# | ||
- | // | ||
- | cam = app.CreateCameraView( .003, | ||
- | cam.SetOnReady( capture ) | ||
- | lay.AddChild( cam ) | ||
- | // | ||
- | txt = app.CreateText( " | ||
- | txt.SetTextColor("# | ||
- | txt.SetTextSize( 32 ); | ||
- | lay.AddChild( txt ); | ||
- | |||
- | // | ||
- | chkFlash = app.CreateCheckBox( " | ||
- | chkFlash.SetMargins( 0, | ||
- | chkFlash.SetOnTouch( chkFlash_OnTouch ); | ||
- | lay.AddChild( chkFlash ); | ||
- | // | ||
- | app.AddLayout( lay ); | ||
- | } | ||
- | // | ||
- | function capture() | ||
- | { | ||
- | cam.StartPreview(); | ||
- | } | ||
- | |||
- | // | ||
- | function chkFlash_OnTouch(value) | ||
- | { | ||
- | cam.SetFlash(value); | ||
- | if(value==true){chkFlash.SetText(" | ||
- | else{ chkFlash.SetText(" | ||
- | } | ||
- | </ |