DALi Version 1.4.26
[platform/core/uifw/dali-toolkit.git] / plugins / dali-script-v8 / docs / content / image-view.js
1 /**
2  *
3 ## ImageView API
4
5    DALi ImageView can be used to display an image.
6
7    It is preferable to set a valid size to the image for efficiency. However, do not set size
8    that is bigger than the actual image size, as the up-scaling is not available, the content
9    of the area not covered by actual image is undefined and it will not be cleared.
10
11   
12 ### Simple example of creating an ImageView
13
14 ```
15 var imageView = new dali.Control("ImageView");
16   
17 imageView.image = "myImage.jpg";
18 imageView.parentOrigin = dali.CENTER;
19 imageView.anchorPoint = dali.CENTER;
20   
21 dali.stage.add( imageView );
22 ```
23
24 ### Advanced example of creating an ImageView and applying a GL-ES shader to it
25
26 ```
27 // vertexShader = "";  // vertex shader   ( optional)
28 // fragmentShader = "";  // fragment shader   ( optional)
29 // hints =   // shader hints   ( optional)
30 //       [ "OUTPUT_IS_TRANSPARENT",   // Might generate transparent alpha from opaque inputs
31 //         "MODIFIES_GEOMETRY" ];     // Might change position of vertices, this option disables any culling optimizations
32   
33 var shader = {
34     "vertexShader": myVertexShader,
35     "fragmentShader": myFragmentShader,
36     "hints" : myHints
37 };
38   
39 var imageView = new dali.Control("ImageView");
40 imageView.parentOrigin = dali.CENTER;
41 imageView.anchorPoint = dali.CENTER;
42 imageView.size = imageViewSize; // If not set, it will use either the natural image size or the desired image size if any
43 dali.stage.add( imageView );
44   
45 var image = {
46     "visualType" : "IMAGE",
47     "url" : "myImage.jpg",
48     "desiredWidth" : desiredWidth,   // The desired image width while loading (optional but preferable to set for efficiency)
49     "desiredHeight" : desiredHeight,   // The desired image height while loading (optional but preferable to set for efficiency)
50     "shader" : shader  // Optional
51 };
52   
53 imageView.image = image; // assign the image and shader to imageView
54
55 ```
56
57
58  @class ImageView
59  @extends Actor
60
61 */