EnTerr
10 years agoRoku Guru
BrightScript vs XML: Scenography
I have somewhat of a meta question and that is, is there any particular reason that "SDK 2.0" scenic graphs should be underwritten in XML?
I understand that the tree (that a "scene graph" is) has to be represented somehow - but why not do that in BrightScript proper and instead resort to XML?
Here is what i mean. Let's take an example done in XML (i compacted it from the original, so it's easily viewable in the [code/] box):
The same can be written as B/S structures, in a format i invented - i argue it is no less readable this way:
So back to my question - am i missing something?
Is there a hole in my B/S representation idea?
Am i overestimating how much people hate "coding" in XML?
I am addressing this both to Roku* people, as well as "outsiders" to the Co. that have already done some coding in SDK2.0
I understand that the tree (that a "scene graph" is) has to be represented somehow - but why not do that in BrightScript proper and instead resort to XML?
Here is what i mean. Let's take an example done in XML (i compacted it from the original, so it's easily viewable in the [code/] box):
<component name = "MaskGroupexample" extends = "Group" >
<script>
<![CDATA[
sub init()
maskgroupanimation = m.top.findNode("MaskGroupAnimation")
maskgroupanimation.control = "start"
end sub
]]>
</script>
<children>
<MaskGroup id="exampleMaskGroup" maskuri="pkg:/images/GradientLinear.png" masksize="[512, 288]" maskOffset="[0, 0]" >
<Poster uri = "pkg:/images/dialogpg.jpg" width = "512" height = "288" />
</MaskGroup>
<Animation id = "MaskGroupAnimation" duration = "3" easeFunction = "linear" repeat = "true" >
<Vector2DFieldInterpolator id = "interpolator" fieldToInterp = "exampleMaskGroup.maskOffset" key = "[ 0.0, 0.50, 1.0 ]"
keyValue = "[ [512,0], [-512,0], [512,0] ]" />
</Animation>
</children>
</component>
The same can be written as B/S structures, in a format i invented - i argue it is no less readable this way:
... and this is perfectly valid BrightScript - just nested array and dictionary literals! It may look unusual if you don't know B/S implies comma when new line separates items but yeah... can save on commas there. And since this is all evaluated as B/S, attributes don't have to be string constants like "[ [512,0], [-512,0], [512,0] ]" - they are genuine expressions that can be calculated during object construction.
["component", {name: "MaskGroupexample", extends: "Group"
init: function()
maskgroupanimation = m.top.findNode("MaskGroupAnimation")
maskgroupanimation.control = "start"
end function
}
["children"
["MaskGroup", {id: "exampleMaskGroup", maskuri: "pkg:/images/GradientLinear.png",
masksize: [512, 288], maskOffset: [0, 0]}
"Poster", {uri: "pkg:/images/dialogpg.jpg", width: 512, height: 288}
]
["Animation", {id: "MaskGroupAnimation", duration: 3, easeFunction: "linear", repeat: true}
"Vector2DFieldInterpolator", {id: "interpolator", fieldToInterp: "exampleMaskGroup.maskOffset",
key: [0.0, 0.50, 1.0], keyValue: [[512,0], [-512,0], [512,0]] }
]
]
]
So back to my question - am i missing something?
Is there a hole in my B/S representation idea?
Am i overestimating how much people hate "coding" in XML?
I am addressing this both to Roku* people, as well as "outsiders" to the Co. that have already done some coding in SDK2.0