diff --git a/emscripten-examples/dali-doc-demo.html b/emscripten-examples/dali-doc-demo.html index d6a9c95..ac0146d 100644 --- a/emscripten-examples/dali-doc-demo.html +++ b/emscripten-examples/dali-doc-demo.html @@ -1,11 +1,11 @@ +
+ - -
- mScript = Dali::Toolkit::Script::New();
- mScript.ExecuteFile( mScriptFileName);
-
-
+ var fragment = "" +
+ "varying lowp vec4 vColor;" +
+ "uniform lowp vec4 uColor;" +
+ "" +
+ "void main()" +
+ "{" +
+ " gl_FragColor = vColor * uColor;" +
+ "}";
+
+ var shader = new dali.Shader(vertex, fragment, dali.ShaderHints.HINT_NONE);
+ var material = new dali.Material(shader);
+ var renderer = new dali.Renderer(geometry, material);
+ var actor = new dali.Actor();
+ actor.addRenderer(renderer);
+ return actor;
+ }
+
+ // Currently no toolkit, so no image actor so we create from scratch
+ function createExampleImageActor() {
+ var halfQuadSize = 0.5;
+ var verts = dali.createPropertyBuffer( {format: [ ["aPosition", dali.PropertyType.VECTOR3],
+ ["aTexCoord", dali.PropertyType.VECTOR2] ],
+ data: { "aPosition": [ [-halfQuadSize, -halfQuadSize, 0.0],
+ [+halfQuadSize, -halfQuadSize, 0.0],
+ [-halfQuadSize, +halfQuadSize, 0.0],
+ [+halfQuadSize, +halfQuadSize, 0.0]
+ ],
+ "aTexCoord": [ [0, 0],
+ [1, 0],
+ [0, 1],
+ [1, 1]
+ ]
+ }
+ });
+
+ var indices = dali.createPropertyBuffer( { format: [ ["indices", dali.PropertyType.INTEGER]],
+ data: { "indices": [0, 3, 1, 0, 2, 3] } } ) ;
+ var geometry = new dali.Geometry();
+ geometry.addVertexBuffer(verts);
+ geometry.setIndexBuffer(indices);
+
+ var vertex = "" +
+ "// atributes\n" +
+ "attribute mediump vec3 aPosition;" +
+ "attribute mediump vec2 aTexCoord;\n" +
+ "// inbuilt\n" +
+ "uniform mediump mat4 uMvpMatrix;" +
+ "uniform mediump vec3 uSize;" +
+ "uniform lowp vec4 uColor;" +
+ "// varying\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "" +
+ "void main()" +
+ "{" +
+ " mediump vec4 vertexPosition = vec4(aPosition, 1.0);" +
+ " vertexPosition.xyz *= uSize;" +
+ " gl_Position = uMvpMatrix * vertexPosition;" +
+ " vTexCoord = aTexCoord;\n" +
+ "}";
+
+ var fragment = "" +
+ "uniform lowp vec4 uColor;" +
+ "uniform sampler2D sTexture;\n" +
+ "varying mediump vec2 vTexCoord;\n" +
+ "\n" +
+ "void main()" +
+ "{" +
+ " gl_FragColor = texture2D(sTexture, vTexCoord) * uColor;\n" +
+ "}";
+
+ var shader = new dali.Shader(vertex, fragment, dali.ShaderHints.HINT_NONE);
+ var material = new dali.Material(shader);
+ var image = getEmbeddedImage() ;
+ var sampler = new dali.Sampler();
+ material.addTexture(image, "sTexture", sampler);
+ var renderer = new dali.Renderer(geometry, material);
+ var actor = new dali.Actor();
+ actor.addRenderer(renderer);
+ return actor;
+ }
+
-
+ An actor inherits its parent's position. The relative position between the actor & parent is determined by 3 properties:
+The default is "top-left", which can be visualized in 2D as (0, 0), but is actually Vector3(0, 0, 0.5) in the 3D DALi world. The actor's position is relative to this point.
+// to change parent origin to the centre
+myActor.positionExample = [0.5, 0.5, 0.5];
+
+
+
+
+
+ The default is "center", which can be visualized in 2D as (0.5, 0.5), but is actually Vector3(0.5, 0.5, 0.5) in the 3D DALi world. The actor's position is also relative to this point.
+// setting anchor point to the centre
+myActor.anchorPoint = [0.5, 0.5, 0.5];
+
+
+
+
+ Therefore by default, an actors position is the distance between its center and the top-left corner of its parent.
+An actor added directly to the stage with position (X = stageWidth0.5, Y = stageHeight0.5), would appear in the center of the screen. Likewise an actor with position (X = actorWidth0.5, Y = actorWidth0.5), would appear at the top-left of the screen.
+Note that since DALi is a 3D toolkit, this behaviour is the result of a default perspective camera setup.
+The parent in the example already has a parentOrigin [0.5, 0.5, 0.5] so a zero position displays in the centre. This can be changed below
+ + + + +