This shows you the differences between two versions of the page.
sample_code:cameraview_color_effect [2015/11/28 08:11] stevegarman created |
sample_code:cameraview_color_effect [2016/07/22 17:19] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Colour effects ====== | ||
- | The CameraView allows you to add colour effects to the picture. | ||
- | This demo shows which effects are available on your device. | ||
- | ===== The code ===== | ||
- | <code JavaScript colorEffects.js> | ||
- | var lay, | ||
- | function OnStart() | ||
- | { | ||
- | lay = app.CreateLayout( " | ||
- | layMnu = app.CreateLayout( " | ||
- | |||
- | cam=app.CreateCameraView(1, | ||
- | cam.SetOnReady(ready); | ||
- | lay.AddChild(cam); | ||
- | |||
- | var btn=app.CreateButton(" | ||
- | btn.SetStyle( "# | ||
- | btn.SetTextColor("# | ||
- | btn.SetOnTouch(toggleMenu); | ||
- | btn.SetPosition(0.8, | ||
- | lay.AddChild(btn); | ||
- | |||
- | lst=app.CreateList("", | ||
- | lst.SetBackColor("# | ||
- | lst.SetTextColor("# | ||
- | // | ||
- | lst.SetHiTextColor1("# | ||
- | lst.SetOnTouch(effects); | ||
- | layMnu.SetPosition(0.5, | ||
- | layMnu.SetVisibility(" | ||
- | layMnu.AddChild(lst); | ||
- | lay.AddChild(layMnu); | ||
- | |||
- | app.AddLayout( lay ); | ||
- | } | ||
- | |||
- | function toggleMenu() | ||
- | { | ||
- | if(layMnu.GetVisibility()==" | ||
- | { | ||
- | layMnu.Animate(" | ||
- | lay.ChildToFront(layMnu); | ||
- | } | ||
- | else | ||
- | layMnu.Animate(" | ||
- | } | ||
- | |||
- | function effects(item) | ||
- | { | ||
- | cam.SetColorEffect(item); | ||
- | lst.SelectItem(item); | ||
- | layMnu.Animate(" | ||
- | } | ||
- | |||
- | function ready() | ||
- | { | ||
- | var s = cam.GetColorEffects(); | ||
- | lst.SetList(s); | ||
- | lst.SelectItem(" | ||
- | layMnu.Animate(" | ||
- | cam.StartPreview(); | ||
- | } | ||
- | </ |