457d8e1312e12c981fe00fb9e3eff7e54ceb0223
[platform/core/uifw/dali-toolkit.git] / docs / content / shared-javascript-and-cpp-documentation / visuals.md
1 <!--
2 /**-->
3
4 # Visuals {#visuals}
5
6 Visuals provide reusable rendering logic which can be used by all controls.
7 This means that custom controls do not have to create actors, they can just reuse the existing visuals which increases performance.
8  
9 Visuals reuse geometry, shaders etc. across controls and manages the renderer and texture to exist only when the control is on-stage.
10 Additionally, they respond to actor size and color change, while also providing clipping at the renderer level.
11  
12 DALi provides the following visuals:
13  + [Color](@ref color-visual)
14  + [Gradient](@ref gradient-visual)
15  + [Image](@ref image-visuals)
16  + [Border](@ref border-visual)
17  + [Mesh](@ref mesh-visual)
18  + [Primitive](@ref primitive-visual)
19  + [Wireframe](@ref wireframe-visual)
20  
21 Controls can provide properties that allow users to specify the visual type ( visualType ).
22 Setting visual properties are done via a property map.
23 The **visualType** field in the property map specifies the visual to use/create.
24 This is required to avoid ambiguity as multiple visuals may be capable of rendering the same contents.
25
26 Visuals have a **transform** field in the property map to allow layouting within a control. If this field is not set, then the visual defaults to filling the control. The **transform** field has a property map with the following keys:
27
28 | Property                                        | String   | Type    | Required | Description               |
29 |-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
30 | Dali::Toolkit::Visual::Transform::Property::OFFSET | offset | VECTOR2 | No      | The offset of the visual. |
31 | Dali::Toolkit::Visual::Transform::Property::SIZE | size | VECTOR2 | No      | The size of the visual. |
32 | Dali::Toolkit::Visual::Transform::Property::OFFSET_SIZE_MODE | offsetSizeMode | VECTOR4 | No      | Whether the size or offset components are Relative or Absolute [More info](@ref offset-size-mode)|
33 | Dali::Toolkit::Visual::Transform::Property::ORIGIN | origin | INTEGER or STRING | No      | The origin of the visual within the control's area. [More info](@ref align-type)] |
34 | Dali::Toolkit::Visual::Transform::Property::ANCHOR_POINT | anchorPoint | INTEGER or STRING | No      | The anchor point of the visual. [More info](@ref align-type)|
35  
36
37 ## Offset & size modes  {#offset-size-mode}
38
39 The offset and size modes can be either Relative or Absolute. The offset modes are in the x and y components of the offsetSizeMode property, and map to the offset's x and y components respectively. The size modes are in the z and w components of the offsetSizeMode property, and map to the size's x and y components, respectively.
40
41 A mode value of 0 represents a Relative mode, in which case the size or offset value represents a ratio of the control's size. A mode value of 1 represents an Absolute mode, in which case the size or offset value represents world units (pixels).
42
43 For example, an offsetSizeMode of [0, 0, 1, 1], an offset of (0, 0.25) and a size of (20, 20) means the visual will be 20 pixels by 20 pixels in size, positioned 25% above the center of the control.
44
45
46 ## Alignment  {#align-type}
47 | Enumeration                                          | String  | Description                                                                                          |
48 |------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------|
49 | Dali::Toolkit::Align::TOP_BEGIN | TOP_BEGIN | Aligns to the top of the vertical axis and the beginning of the horizontal axis (The left or right edge in Left-To-Right or Right-to-Left layouts, respectively) |
50 | Dali::Toolkit::Align::TOP_CENTER | TOP_CENTER | Aligns to the top of the vertical axis and the center of the horizontal axis |
51 | Dali::Toolkit::Align::TOP_END | TOP_END | Aligns to the top of the vertical axis and end of the horizontal axis (The right or left edge in Left-To-Right or Right-to-Left layouts, respectively) |
52 | Dali::Toolkit::Align::CENTER_BEGIN | CENTER_BEGIN | Aligns to the center of the vertical axis and the beginning of the horizontal axis|
53 | Dali::Toolkit::Align::CENTER | CENTER | Aligns to the center of the control |
54 | Dali::Toolkit::Align::CENTER_END | CENTER_END | Aligns to the center of the vertical axis and end of the horizontal axis |
55 | Dali::Toolkit::Align::BOTTOM_BEGIN | BOTTOM_BEGIN | Aligns to the bottom of the vertical axis and the beginning of the horizontal axis|
56 | Dali::Toolkit::Align::BOTTOM_CENTER | BOTTOM_CENTER | Aligns to the bottom of the vertical axis and the center of the horizontal axis
57 | Dali::Toolkit::Align::BOTTOM_END | BOTTOM_END | Aligns to the bottom of the vertical axis and end of the horizontal axis |
58  
59 Visuals also have a custom **shader** property. Whilst it's possible to change the shader, please note that some visuals rely on the vertex shader to perform certain functions. For example, the NPatch visual uses the vertex shader to perform the stretching. The **shader** property is a Property::Map with the following keys:
60
61
62 | Property                                        | String   | Type    | Required | Description               |
63 |-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
64 | Dali::Toolkit::Visual::Shader::Property::VERTEX_SHADER | vertexShader | STRING | No      | The vertex shader code. |
65 | Dali::Toolkit::Visual::Shader::Property::FRAGMENT_SHADER | fragmentShader | STRING | No      | The fragment shader code. |
66 | Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X | subdivideGridX | INTEGER | No      | How to subdivide the grid along the X-Axis. Defaults to 1 |
67 | Dali::Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y | subdivideGridY | INTEGER | No      | How to subdivide the grid along the Y-Axis. Defaults to 1 |
68 | Dali::Toolkit::Visual::Shader::Property::HINTS | hints | INTEGER or ARRAY of STRING | No      | Shader hints bitmask [More info](@ref shader-hints) |
69
70 ## Shader hints {#shader-hints}
71
72 This is a bitmask giving hints to the renderer about what the shader does, in order to help the rendering system optimise it's rendering.
73
74 The bitmask can have the following values:
75
76 | Value | Description |
77 |-------------------------------------------|----------------------------------------|
78 | Dali::Shader::Hint::NONE | No hints |
79 | Dali::Shader::Hint::OUTPUT_IS_TRANSPARENT | Might generate transparent alpha from opaque inputs |
80 | Dali::Shader::Hint::MODIFIES_GEOMETRY | Might change the position of vertices - this disables culling optimizations |
81
82
83 See also Dali::Shader::Hint::Value enumeration.
84
85 ___________________________________________________________________________________________________
86
87 ## Color Visual {#color-visual}
88
89 Renders a color to the visual's quad geometry.
90  
91 ![ ](../assets/img/visuals/color-visual.png)
92 ![ ](visuals/color-visual.png)
93
94 ### Properties Supported
95
96 **VisualType:** Dali::Toolkit::Visual::COLOR, "COLOR"
97
98 | Property                                        | String   | Type    | Required | Description               |
99 |-------------------------------------------------|----------|:-------:|:--------:|---------------------------|
100 | Dali::Toolkit::ColorVisual::Property::MIX_COLOR | mixColor | VECTOR4 | Yes      | The color required. |
101
102 ### Usage
103
104 ~~~{.cpp}
105 // C++
106 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
107
108 Dali::Property::Map map;
109 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::COLOR;
110 map[ ColorVisual::Property::MIX_COLOR ] = Color::RED;
111
112 control.SetProperty( Control::Property::BACKGROUND, map );
113 ~~~
114
115 ~~~{.js}
116 // JavaScript
117 var control = new dali.Control( "Control" );
118
119 control.background =
120 {
121   visualType : "COLOR",
122   mixColor : dali.COLOR_RED
123 };
124 ~~~
125 ___________________________________________________________________________________________________
126
127 ## Gradient Visual {#gradient-visual}
128
129 Renders a smooth transition of colors to the visual's quad geometry.
130  
131 Both Linear and Radial gradients are supported.
132
133 | Linear | Radial |
134 |--------|--------|
135 | ![ ](../assets/img/visuals/linear-gradient-visual.png) ![ ](visuals/linear-gradient-visual.png) | ![ ](../assets/img/visuals/radial-gradient-visual.png) ![ ](visuals/radial-gradient-visual.png) |
136
137 ### Properties Supported
138
139 **VisualType:** Dali::Toolkit::Visual::GRADIENT, "GRADIENT"
140
141 | Property                                                | String        | Type              | Required   | Description                                                                                                      |
142 |---------------------------------------------------------|---------------|:-----------------:|:----------:|------------------------------------------------------------------------------------------------------------------|
143 | Dali::Toolkit::GradientVisual::Property::START_POSITION | startPosition | VECTOR2           | For Linear | The start position of the linear gradient.                                                                       |
144 | Dali::Toolkit::GradientVisual::Property::END_POSITION   | endPosition   | VECTOR2           | For Linear | The end position of the linear gradient.                                                                         |
145 | Dali::Toolkit::GradientVisual::Property::CENTER         | center        | VECTOR2           | For Radial | The center point of the gradient.                                                                                |
146 | Dali::Toolkit::GradientVisual::Property::RADIUS         | radius        | FLOAT             | For Radial | The size of the radius.                                                                                          |
147 | Dali::Toolkit::GradientVisual::Property::STOP_OFFSET    | stopOffset    | ARRAY of FLOAT    | No         | All the stop offsets. If not supplied default is 0.0 and 1.0.                                                    |
148 | Dali::Toolkit::GradientVisual::Property::STOP_COLOR     | stopColor     | ARRAY of VECTOR4  | Yes        | The color at those stop offsets. At least 2 required to show a gradient.                                         |
149 | Dali::Toolkit::GradientVisual::Property::UNITS          | units         | INTEGER or STRING | No         | Defines the coordinate system. [More info](@ref gradient-visual-units)                                           |
150 | Dali::Toolkit::GradientVisual::Property::SPREAD_METHOD  | spreadMethod  | INTEGER or STRING | No         | Indicates what happens if gradient starts or ends inside bounds. [More info](@ref gradient-visual-spread-method) |
151
152 If the *stopOffset* and *stopColor* arrays do not have the same number of elements, then the minimum of the two is used as the stop points.
153
154 ### Units {#gradient-visual-units}
155
156 Defines the coordinate system for the attributes:
157  + Start (x1, y1) and End (x2 and y2) points of a line if using a linear gradient.
158  + Center point (cx, cy) and radius (r) of a circle if using a radial gradient.
159  
160 | Enumeration                                               | String              | Description                                                                                                                                    |
161 |-----------------------------------------------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
162 | Dali::Toolkit::GradientVisual::Units::OBJECT_BOUNDING_BOX | OBJECT_BOUNDING_BOX | *Default*. Uses the normals for the start, end & center points, i.e. top-left is (-0.5, -0.5) and bottom-right is (0.5, 0.5).                  |
163 | Dali::Toolkit::GradientVisual::Units::USER_SPACE          | USER_SPACE          | Uses the user coordinates for the start, end & center points, i.e. in a 200 by 200 control, top-left is (0, 0) and bottom-right is (200, 200). |
164
165 ### Spread Method {#gradient-visual-spread-method}
166
167 Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle.
168
169 | Enumeration                                          | String  | Description                                                                                          |
170 |------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------|
171 | Dali::Toolkit::GradientVisual::SpreadMethod::PAD     | PAD     | *Default*. Uses the terminal colors of the gradient to fill the remainder of the quad geometry.               |
172 | Dali::Toolkit::GradientVisual::SpreadMethod::REFLECT | REFLECT | Reflect the gradient pattern start-to-end, end-to-start, start-to-end etc. until the quad geometry is filled. |
173 | Dali::Toolkit::GradientVisual::SpreadMethod::REPEAT  | REPEAT  | Repeat the gradient pattern start-to-end, start-to-end, start-to-end etc. until the quad geometry is filled.  |
174
175 ### Usage
176
177 **Linear:**
178 ~~~{.cpp}
179 // C++
180 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
181
182 Dali::Property::Map map;
183 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::GRADIENT;
184 map[ GradientVisual::Property::START_POSITION ] = Vector2( 0.5f, 0.5f );
185 map[ GradientVisual::Property::END_POSITION ] = Vector2( -0.5f, -0.5f );
186
187 Dali::Property::Array stopOffsets;
188 stopOffsets.PushBack( 0.0f );
189 stopOffsets.PushBack( 0.3f );
190 stopOffsets.PushBack( 0.6f );
191 stopOffsets.PushBack( 0.8f );
192 stopOffsets.PushBack( 1.f );
193 map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
194
195 Dali::Property::Array stopColors;
196 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
197 stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
198 stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
199 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
200 stopColors.PushBack( Color::YELLOW );
201 map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
202
203 control.SetProperty( Control::Property::BACKGROUND, map );
204 ~~~
205
206 ~~~{.js}
207 // JavaScript
208 var control = new dali.Control( "Control" );
209
210 control.background =
211 {
212   visualType : "GRADIENT",
213   startPosition : [ 0.5, 0.5 ],
214   endPosition : [ -0.5, -0.5 ],
215   stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
216   stopColor : [
217     [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
218     [ 196 / 255, 198 / 255,  71 / 255, 122 / 255 ],
219     [ 214 / 255,  37 / 255, 139 / 255, 191 / 255 ],
220     [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
221     dali.COLOR_YELLOW
222   ]
223 };
224 ~~~
225
226 **Radial:**
227 ~~~{.cpp}
228 // C++
229 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
230
231 Dali::Property::Map map;
232 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::GRADIENT;
233 map[ GradientVisual::Property::CENTER ] = Vector2( 0.5f, 0.5f );
234 map[ GradientVisual::Property::RADIUS ] = 1.414f;
235
236 Dali::Property::Array stopOffsets;
237 stopOffsets.PushBack( 0.0f );
238 stopOffsets.PushBack( 0.3f );
239 stopOffsets.PushBack( 0.6f );
240 stopOffsets.PushBack( 0.8f );
241 stopOffsets.PushBack( 1.f );
242 map[ GradientVisual::Property::STOP_OFFSET ] = stopOffsets;
243
244 Dali::Property::Array stopColors;
245 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 255.f )/255.f );
246 stopColors.PushBack( Vector4( 196.f, 198.f, 71.f, 122.f )/255.f );
247 stopColors.PushBack( Vector4( 214.f, 37.f, 139.f, 191.f )/255.f );
248 stopColors.PushBack( Vector4( 129.f, 198.f, 193.f, 150.f )/255.f );
249 stopColors.PushBack( Color::YELLOW );
250 map[ GradientVisual::Property::STOP_COLOR ] = stopColors;
251
252 control.SetProperty( Control::Property::BACKGROUND, map );
253 ~~~
254
255 ~~~{.js}
256 // JavaScript
257 var control = new dali.Control( "Control" );
258
259 control.background =
260 {
261   visualType : "GRADIENT",
262   center : [ 0.5, 0.5 ],
263   radius : 1.414,
264   stopOffset : [ 0.0, 0.3, 0.6, 0.8, 1.0 ],
265   stopColor : [
266     [ 129 / 255, 198 / 255, 193 / 255, 255 / 255 ],
267     [ 196 / 255, 198 / 255,  71 / 255, 122 / 255 ],
268     [ 214 / 255,  37 / 255, 139 / 255, 191 / 255 ],
269     [ 129 / 255, 198 / 255, 193 / 255, 150 / 255 ],
270     dali.COLOR_YELLOW
271   ]
272 };
273 ~~~
274 ___________________________________________________________________________________________________
275
276 ## Image Visual {#image-visuals}
277
278 Renders an image into the visual's geometry.
279  
280 Depending on the extension of the image, a different visual is provided to render the image onto the screen.
281  
282  + [Normal (Quad)](@ref image-visual)
283  + [N-Patch](@ref n-patch-visual)
284  + [SVG](@ref svg-visual)
285  
286 ___________________________
287  
288 ### Normal {#image-visual}
289  
290 Renders a raster image ( jpg, png etc.) into the visual's quad geometry.
291  
292 ![ ](../assets/img/visuals/image-visual.png)
293 ![ ](visuals/image-visual.png)
294
295 #### Properties Supported
296
297 **VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
298
299 | Property                                             | String        | Type              | Required | Description                                                                                                              |
300 |------------------------------------------------------|---------------|:-----------------:|:--------:|--------------------------------------------------------------------------------------------------------------------------|
301 | Dali::Toolkit::ImageVisual::Property::URL            | url           | STRING            | Yes      | The URL of the image.                                                                                                    |
302 | Dali::Toolkit::ImageVisual::Property::FITTING_MODE   | fittingMode   | INTEGER or STRING | No       | Fitting options, used when resizing images to fit desired dimensions. [More info](@ref resourceimagescaling-fittingmode) |
303 | Dali::Toolkit::ImageVisual::Property::SAMPLING_MODE  | samplingMode  | INTEGER or STRING | No       | Filtering options, used when resizing images to sample original pixels. [More info](@ref resourceimagescaling-scaling)   |
304 | Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH  | desiredWidth  | INT               | No       | The desired image width. Will use actual image width if not specified.                                                   |
305 | Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT | desiredHeight | INT               | No       | The desired image height. Will use actual image height if not specified.                                                 |
306
307 #### Usage
308
309 ~~~{.cpp}
310 // C++
311 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
312
313 Dali::Property::Map map;
314 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
315 map[ ImageVisual::Property::URL ] = "path-to-image.jpg";
316
317 control.SetProperty( Control::Property::BACKGROUND, map );
318 ~~~
319
320 ~~~{.js}
321 // JavaScript
322 var control = new dali.Control( "Control" );
323
324 control.background =
325 {
326   visualType : "IMAGE",
327   url : "path-to-image.jpg"
328 };
329 ~~~
330 ___________________________________________________________________________________________________
331
332 ### N-Patch {#n-patch-visual}
333
334 Renders an n-patch or a 9-patch image. Uses non-quad geometry. Both geometry and texture are cached to reduce memory consumption if the same n-patch image is used elsewhere.
335  
336 ![ ](../assets/img/visuals/n-patch-visual.png)
337 ![ ](visuals/n-patch-visual.png)
338
339 #### Properties Supported
340
341 **VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
342
343 | Property                                          | String        | Type    | Required | Description                      |
344 |---------------------------------------------------|---------------|:-------:|:--------:|----------------------------------|
345 | Dali::Toolkit::ImageVisual::Property::URL         | url           | STRING  | Yes      | The URL of the n-patch image.    |
346 | Dali::Toolkit::ImageVisual::Property::BORDER_ONLY | borderOnly    | BOOLEAN | No       | If true, only draws the borders. |
347
348 #### Usage
349
350 ~~~{.cpp}
351 // C++
352 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
353
354 Dali::Property::Map map;
355
356 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
357 map[ Dali::Toolkit::ImageVisual::Property::URL ] = "path-to-image.9.png";
358
359 control.SetProperty( Control::Property::BACKGROUND, map );
360 ~~~
361
362 ~~~{.js}
363 // JavaScript
364 var control = new dali.Control( "Control" );
365
366 control.background =
367 {
368   visualType : "IMAGE",
369   url : "path-to-image.9.png"
370 };
371 ~~~
372
373 ___________________________________________________________________________________________________
374
375 ### SVG {#svg-visual}
376
377 Renders a svg image into the visual's quad geometry.
378  
379 #### Features: SVG Tiny 1.2 specification
380
381 **supported:**
382  
383   * basic shapes
384   * paths
385   * solid color fill
386   * gradient color fill
387   * solid color stroke
388  
389 **not supported:**
390  
391   * gradient color stroke
392   * dash array stroke
393   * view box
394   * text
395   * clip path
396
397 <div style="width:300px">
398  
399 ![ ](../assets/img/visuals/svg-visual.svg)
400  
401 </div>
402  
403 <div style="width:300px">
404  
405 ![ ](visuals/svg-visual.svg)
406  
407 </div>
408
409  
410 #### Properties Supported
411
412 **VisualType:** Dali::Toolkit::Visual::IMAGE, "IMAGE"
413
414 | Property                                  | String | Type    | Required | Description                      |
415 |-------------------------------------------|--------|:-------:|:--------:|----------------------------------|
416 | Dali::Toolkit::ImageVisual::Property::URL | url    | STRING  | Yes      | The URL of the SVG image.    |
417
418 #### Usage
419
420 ~~~{.cpp}
421 // C++
422 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
423
424 Dali::Property::Map map;
425
426 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::IMAGE;
427 map[ Dali::Toolkit::ImageVisual::Property::URL ] = "path-to-image.svg";
428
429 control.SetSize( 200.f, 200.f );
430 control.SetProperty( Control::Property::BACKGROUND, map );
431 ~~~
432
433 ~~~{.js}
434 // JavaScript
435 var control = new dali.Control( "Control" );
436
437 control.background =
438 {
439   visualType : "IMAGE",
440   url : "path-to-image.svg"
441 };
442 ~~~
443 ___________________________________________________________________________________________________
444
445 ## Border Visual {#border-visual}
446
447 Renders a color as an internal border to the visual's geometry.
448  
449 ![ ](../assets/img/visuals/border-visual.png)
450 ![ ](visuals/border-visual.png)
451
452 ### Properties Supported
453
454 **VisualType:** Dali::Toolkit::Visual::BORDER, "BORDER"
455
456 | Property                                             | String        | Type    | Required | Description                                      |
457 |------------------------------------------------------|---------------|:-------:|:--------:|--------------------------------------------------|
458 | Dali::Toolkit::BorderVisual::Property::COLOR         | borderColor   | VECTOR4 | Yes      | The color of the border.                         |
459 | Dali::Toolkit::BorderVisual::Property::SIZE          | borderSize    | FLOAT   | Yes      | The width of the border (in pixels).             |
460 | Dali::Toolkit::BorderVisual::Property::ANTI_ALIASING | antiAliasing  | BOOLEAN | No       | Whether anti-aliasing of the border is required. |
461
462 ### Usage
463
464 ~~~{.cpp}
465 // C++
466 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
467
468 Dali::Property::Map map;
469
470 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::BORDER;
471 map[ BorderVisual::Property::COLOR ] = Color::BLUE;
472 map[ BorderVisual::Property::SIZE ] = 5.0f;
473
474 control.SetProperty( Control::Property::BACKGROUND, map );
475 ~~~
476
477 ~~~{.js}
478 // JavaScript
479 var control = new dali.Control( "Control" );
480
481 control.background =
482 {
483   visualType : "BORDER",
484   borderColor : dali.COLOR_BLUE,
485   borderSize = 5
486 };
487 ~~~
488
489 ___________________________________________________________________________________________________
490
491 ## Mesh Visual {#mesh-visual}
492
493 Renders a mesh using a .obj file, optionally with textures provided by a mtl file. Scaled to fit the control.
494  
495 ![ ](../assets/img/visuals/mesh-visual.png)
496 ![ ](visuals/mesh-visual.png)
497  
498 ### Properties Supported
499  
500 **VisualType:** Dali::Toolkit::Visual::MESH, "MESH"
501
502 | Property                                              | String         | Type               | Required          | Description                                                                                      |
503 |-------------------------------------------------------|----------------|:------------------:|:-----------------:|--------------------------------------------------------------------------------------------------|
504 | Dali::Toolkit::MeshVisual::Property::OBJECT_URL       | objectUrl      | STRING             | Yes               | The location of the ".obj" file.                                                                 |
505 | Dali::Toolkit::MeshVisual::Property::MATERIAL_URL     | materialUrl    | STRING             | No                | The location of the ".mtl" file. Leave blank for a textureless object.                           |
506 | Dali::Toolkit::MeshVisual::Property::TEXTURES_PATH    | texturesPath   | STRING             | If using material | Path to the directory the textures (including gloss and normal) are stored in.                   |
507 | Dali::Toolkit::MeshVisual::Property::SHADING_MODE     | shadingMode    | INTEGER or STRING  | No                | Sets the type of shading mode that the mesh will use. [More info](@ref mesh-visual-shading-mode) |
508 | Dali::Toolkit::MeshVisual::Property::USE_MIPMAPPING   | useMipmapping  | BOOLEAN            | No                | Flag for whether to use mipmaps for textures or not. Default true.                               |
509 | Dali::Toolkit::MeshVisual::Property::USE_SOFT_NORMALS | useSoftNormals | BOOLEAN            | No                | Flag for whether to average normals at each point to smooth textures or not. Default true.       |
510 | Dali::Toolkit::MeshVisual::Property::LIGHT_POSITION   | lightPosition  | VECTOR3            | No                | The position, in stage space, of the point light that applies lighting to the model.             |
511  
512 ### Shading Mode {#mesh-visual-shading-mode}
513
514 When specifying the shading mode, if anything the mode requires is missing, a simpler mode that can be handled with what has been supplied will be used instead.
515  
516 **Possible values:**
517  
518 | Enumeration                                                                     | String                                   | Description                                                                                                             |
519 |---------------------------------------------------------------------------------|------------------------------------------|-------------------------------------------------------------------------------------------------------------------------|
520 | Dali::Toolkit::MeshVisual::ShaderType::TEXTURELESS_WITH_DIFFUSE_LIGHTING        | TEXTURELESS_WITH_DIFFUSE_LIGHTING        | *Simplest*. One color that is lit by ambient and diffuse lighting.                                                      |
521 | Dali::Toolkit::MeshVisual::ShaderType::TEXTURED_WITH_SPECULAR_LIGHTING          | TEXTURED_WITH_SPECULAR_LIGHTING          | Uses only the visual image textures provided with specular lighting in addition to ambient and diffuse lighting.        |
522 | Dali::Toolkit::MeshVisual::ShaderType::TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING | TEXTURED_WITH_DETAILED_SPECULAR_LIGHTING | Uses all textures provided including a gloss, normal and texture map along with specular, ambient and diffuse lighting. |
523
524 ### Usage
525
526 ~~~{.cpp}
527 // C++
528 Dali::Stage stage = Dali::Stage::GetCurrent();
529 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
530
531 Dali::Property::Map map;
532
533 map[ Visual::Property::TYPE  ] = Dali::Toolkit::Visual::MESH;
534 map[ MeshVisual::Property::OBJECT_URL ] = "home/models/Dino.obj";
535 map[ MeshVisual::Property::MATERIAL_URL ] = "home/models/Dino.mtl";
536 map[ MeshVisual::Property::TEXTURES_PATH ] = "home/images/";
537
538 control.SetProperty( Control::Property::BACKGROUND, map );
539 ~~~
540
541 ___________________________________________________________________________________________________
542
543 ## Primitive Visual {#primitive-visual}
544
545 Renders a simple 3D shape, such as a cube or sphere. Scaled to fit the control.
546
547 The shapes are generated with clockwise winding and back-face culling on by default.
548
549 ![ ](../assets/img/visuals/cube.png)
550 ![ ](visuals/cube.png)
551  
552 ### Properties Supported
553
554 **VisualType:** Dali::Toolkit::Visual::PRIMITIVE, "PRIMITIVE"
555
556 | Property                                                      | String            | Type               | Description                                                                                                     | Default Value                                           | Range                          |
557 |---------------------------------------------------------------|-------------------|:------------------:|-----------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------:|:------------------------------:|
558 | Dali::Toolkit::PrimitiveVisual::Property::SHAPE               | shape             | INTEGER or STRING  | The specific shape to render. [More info](@ref shape-details)                                                   | Dali::Toolkit::PrimitiveVisual::Shape::SPHERE, "SPHERE" | [See list](@ref shape-details) |
559 | Dali::Toolkit::PrimitiveVisual::Property::MIX_COLOR           | mixColor          | VECTOR4            | The color of the shape.                                                                                         | (0.5, 0.5, 0.5, 1.0)                                    | 0.0 - 1.0 for each             |
560 | Dali::Toolkit::PrimitiveVisual::Property::SLICES              | slices            | INTEGER            | The number of slices as you go around the shape. [More info](@ref slices-details)                               | 128                                                     | 1 - 255                        |
561 | Dali::Toolkit::PrimitiveVisual::Property::STACKS              | stacks            | INTEGER            | The number of stacks as you go down the shape. [More info](@ref stacks-details)                                 | 128                                                     | 1 - 255                        |
562 | Dali::Toolkit::PrimitiveVisual::Property::SCALE_TOP_RADIUS    | scaleTopRadius    | FLOAT              | The scale of the radius of the top circle of a conical frustrum.                                                | 1.0                                                     | ≥ 0.0                          |
563 | Dali::Toolkit::PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS | scaleBottomRadius | FLOAT              | The scale of the radius of the bottom circle of a conical frustrum.                                             | 1.5                                                     | ≥ 0.0                          |
564 | Dali::Toolkit::PrimitiveVisual::Property::SCALE_HEIGHT        | scaleHeight       | FLOAT              | The scale of the height of a conic.                                                                             | 3.0                                                     | > 0.0                          |
565 | Dali::Toolkit::PrimitiveVisual::Property::SCALE_RADIUS        | scaleRadius       | FLOAT              | The scale of the radius of a cylinder.                                                                          | 1.0                                                     | > 0.0                          |
566 | Dali::Toolkit::PrimitiveVisual::Property::SCALE_DIMENSIONS    | scaleDimensions   | VECTOR3            | The dimensions of a cuboid. Scales in the same fashion as a 9-patch image.                                      | Vector3::ONE                                            | > 0.0 for each                 |
567 | Dali::Toolkit::PrimitiveVisual::Property::BEVEL_PERCENTAGE    | bevelPercentage   | FLOAT              | Determines how bevelled the cuboid should be, based off the smallest dimension. [More info](@ref bevel-details) | 0.0 (no bevel)                                          | 0.0 - 1.0                      |
568 | Dali::Toolkit::PrimitiveVisual::Property::BEVEL_SMOOTHNESS    | bevelSmoothness   | FLOAT              | Defines how smooth the bevelled edges should be.                                                                | 0.0 (sharp edges)                                       | 0.0 - 1.0                      |
569 | Dali::Toolkit::PrimitiveVisual::Property::LIGHT_POSITION      | lightPosition     | VECTOR3            | The position, in stage space, of the point light that applies lighting to the model.                            | (Offset outwards from the center of the screen.)        | Unlimited                      |
570
571 ### Shapes {#shape-details}
572
573 There are six shapes that can be chosen, some of which are simplified specialisations of another.
574
575 | Enumeration                                             | String           | Description                                                                       | Parameters                                                    |
576 |---------------------------------------------------------|------------------|-----------------------------------------------------------------------------------|---------------------------------------------------------------|
577 | Dali::Toolkit::PrimitiveVisual::Shape::SPHERE           | SPHERE           | *Default*.                                                                        | color, slices, stacks                                         |
578 | Dali::Toolkit::PrimitiveVisual::Shape::CONICAL_FRUSTRUM | CONICAL_FRUSTRUM | The area bound between two circles, i.e. a cone with the tip removed.             | color, scaleTopRadius, scaleBottomRadius, scaleHeight, slices |
579 | Dali::Toolkit::PrimitiveVisual::Shape::CONE             | CONE             | Equivalent to a conical frustrum with top radius of zero.                         | color, scaleBottomRadius, scaleHeight, slices                 |
580 | Dali::Toolkit::PrimitiveVisual::Shape::CYLINDER         | CYLINDER         | Equivalent to a conical frustrum with equal radii for the top and bottom circles. | color, scaleRadius, scaleHeight, slices                       |
581 | Dali::Toolkit::PrimitiveVisual::Shape::CUBE             | CUBE             | Equivalent to a bevelled cube with a bevel percentage of zero.                    | color, scaleDimensions                                        |
582 | Dali::Toolkit::PrimitiveVisual::Shape::OCTAHEDRON       | OCTAHEDRON       | Equivalent to a bevelled cube with a bevel percentage of one.                     | color, scaleDimensions                                        |
583 | Dali::Toolkit::PrimitiveVisual::Shape::BEVELLED_CUBE    | BEVELLED_CUBE    | A cube/cuboid with all edges flattened to some degree.                            | color, scaleDimensions, bevelPercentage, bevelSmoothness      |
584
585 #### Examples below:
586
587 **sphere:**
588  
589 ![ ](../assets/img/visuals/sphere.png)
590 ![ ](visuals/sphere.png)
591  
592 **conics:**
593  
594 | Frustrum | Cone | Cylinder |
595 |----------|------|----------|
596 | ![ ](../assets/img/visuals/conical-frustrum.png) ![ ](visuals/conical-frustrum.png) | ![ ](../assets/img/visuals/cone.png) ![ ](visuals/cone.png) | ![ ](../assets/img/visuals/cylinder.png) ![ ](visuals/cylinder.png) |
597  
598 ### Bevel {#bevel-details}
599  
600 Bevel percentage ranges from 0.0 to 1.0. It affects the ratio of the outer face widths to the width of the overall cube, as shown:
601  
602 | 0.0 ( cube) | 0.3 | 0.7 | 1.0 (octahedron) |
603 |-------------|-----|-----|------------------|
604 | ![ ](../assets/img/visuals/cube.png) ![ ](visuals/cube.png) | ![ ](../assets/img/visuals/bevelled-cube-low.png) ![ ](visuals/bevelled-cube-low.png) | ![ ](../assets/img/visuals/bevelled-cube-high.png) ![ ](visuals/bevelled-cube-high.png) | ![ ](../assets/img/visuals/octahedron.png) ![ ](visuals/octahedron.png) |
605  
606 ### Slices {#slices-details}
607  
608 For spheres and conical frustrums, 'slices' determines how many divisions there are as you go around the object.
609  
610 ![ ](../assets/img/visuals/slices.png)
611 ![ ](visuals/slices.png)
612  
613 ### Stacks {#stacks-details}
614  
615 For spheres, 'stacks' determines how many layers there are as you go down the object.
616  
617 ![ ](../assets/img/visuals/stacks.png)
618 ![ ](visuals/stacks.png)
619  
620 ### Usage
621  
622 **sphere**
623  
624 ~~~{.cpp}
625 // C++
626 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
627
628 Dali::Property::Map map;
629
630 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
631 map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::SPHERE;
632 map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
633
634 control.SetProperty( Control::Property::BACKGROUND, map );
635 ~~~
636
637 **conical frustrum**
638
639 ~~~{.cpp}
640 // C++
641 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
642
643 Dali::Property::Map map;
644
645 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
646 map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::CONICAL_FRUSTRUM;
647 map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
648 map[ PrimitiveVisual::Property::SCALE_TOP_RADIUS ] = 1.0f;
649 map[ PrimitiveVisual::Property::SCALE_BOTTOM_RADIUS ] = 1.5f;
650 map[ PrimitiveVisual::Property::SCALE_HEIGHT ] = 3.0f;
651
652 control.SetProperty( Control::Property::BACKGROUND, map );
653 ~~~
654
655 **bevelled cube**
656
657 ~~~{.cpp}
658 // C++
659 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
660
661 Dali::Property::Map map;
662
663 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::PRIMITIVE;
664 map[ PrimitiveVisual::Property::SHAPE ] = PrimitiveVisual::Shape::BEVELLED_CUBE;
665 map[ PrimitiveVisual::Property::MIX_COLOR ] = Vector4( 1.0, 0.5, 0.0, 1.0 );
666 map[ PrimitiveVisual::Property::BEVEL_PERCENTAGE ] = 0.4f;
667
668 control.SetProperty( Control::Property::BACKGROUND, map );
669 ~~~
670 ___________________________________________________________________________________________________
671
672 ## Wireframe Visual {#wireframe-visual}
673
674 Renders a wireframe around a quad geometry.
675 Is mainly used for debugging and is the visual that replaces all other visuals when [Visual Debug Rendering](@ref debugrendering) is turned on.
676  
677 ![ ](../assets/img/visuals/wireframe-visual.png)
678 ![ ](visuals/wireframe-visual.png)
679
680 ### Properties
681
682 **VisualType:** Dali::Toolkit::Visual::WIREFRAME, "WIREFRAME"
683
684 ### Usage
685
686 ~~~{.cpp}
687 // C++
688 Dali::Toolkit::Control control = Dali::Toolkit::Control::New();
689
690 Dali::Property::Map map;
691 map[ Visual::Property::TYPE ] = Dali::Toolkit::Visual::WIREFRAME;
692
693 control.SetProperty( Control::Property::BACKGROUND, map );
694 ~~~
695
696 ~~~{.js}
697 // JavaScript
698 var control = new dali.Control( "Control" );
699
700 control.background =
701 {
702   visualType : "WIREFRAME"
703 };
704 ~~~
705
706
707 @class _Guide_Control_Visuals
708
709 */