Thursday, January 7, 2016

nitro format

Sitting at main computer for first time since Christmas we find the following file waiting.

_test1.nitro

To stay a productive developer I always try and leave a few bones with meat lying around for the following day / week / year.

resource:
{
 palette:
 {
  colors:[[0,0,0,1],[255,255,255,1]],
  name:monochrome
 },
 image:
 {
  id:checker,
  pixels:[
   [1,0,1,0,1,0,1,0],
   [0,1,0,1,0,1,0,1],
   [1,0,1,0,1,0,1,0],
   [0,1,0,1,0,1,0,1],
   [1,0,1,0,1,0,1,0],
   [0,1,0,1,0,1,0,1],
   [1,0,1,0,1,0,1,0],
   [0,1,0,1,0,1,0,1]
  ]
 },
 brush:
 {
  id:shinychecker,
  shininess:0.8 
 }
},
scene:
{
 camera:
 {
  position:[0,3,-10],
  name:Camera1
 },
 light:
 {
  position:[3,-4,0]
 },
 model:
 {
  src:sphere,
  position:[0,1,0]
 }
}


After 2 educational (in the bad way) implementations of json and xml, I adopted a loose json implementation in which quotes are optional for single word strings as the standard file format for my NitroSDK project.

Json beats xml due to native support for numeric arrays which in xml require CSV style extensions that smell bad and offend the xsl purists.

Json however is class less, and so in the above we begin with singleton definitions and a plan to plurify (add plural version) all nouns using array of said objects.

The formatting is attempting to follow output of http://jsonlint.com/ which I find very readable.

The color format follows 8.8.8.20 RGBA precision in which only alpha is floating point.

The current implementation doesn't support any of the above.

[edit]

It turns out I neglected YAML as seen in OpenCV.

YAML looks like a pretty nice standard: http://www.yaml.org/spec/1.2/spec.html