omniJS – Something for the documentation: Shape+Line defaults

I notice that Edit > Copy As > JavaScript is quite economical, giving the impression that it generates code only for property values which depart from some set of defaults.

I’m not quite sure yet what those defaults are, and whether they are derived from app settings or provided by omniJS itself. (They don’t appear to derive from the active template).

Perhaps that could be a useful addition to the documentation ?

My current (unconfirmed) impression is that the defaults used in simple calls to Canvas.newShape() or Canvas.newLine() may be:

Apparent shape defaults:
{
    "type": "Shape",
    "actionURL": null,
    "alignsEdgesToGrid": true,
    "allowsConnections": true,
    "automationAction": [],
    "autosizing": "TextAutosizing.Overflow",
    "blendColor": null,
    "blendFraction": 0,
    "connectedLines": [],
    "cornerRadius": 0,
    "fillColor": {
      "type": "Color.RGB",
      "args": [
        1,
        1,
        1
      ]
    },
    "fillType": "FillType.Solid",
    "flippedHorizontally": false,
    "flippedVertically": false,
    "fontName": "HelveticaNeue",
    "gradientAngle": 90,
    "gradientCenter": {
      "type": "Point",
      "args": [
        0,
        0
      ]
    },
    "gradientColor": {
      "type": "Color.RGB",
      "args": [
        0.20000000298023224,
        0.20000000298023224,
        0.20000000298023224
      ]
    },
    "image": null,
    "imageOffset": {
      "type": "Point",
      "args": [
        0,
        0
      ]
    },
    "imageOpacity": 0,
    "imagePage": 0,
    "imageSizing": "ImageSizing.Manual",
    "incomingLines": [],
    "locked": false,
    "magnets": [],
    "name": null,
    "notes": "",
    "outgoingLines": [],
    "plasticCurve": null,
    "plasticHighlightAngle": null,
    "rotation": 0,
    "shadowColor": {
      "type": "Color.RGB",
      "args": [
        0,
        0,
        0
      ]
    },
    "shadowFuzziness": 3,
    "shadowVector": {
      "type": "Point",
      "args": [
        0,
        2
      ]
    },
    "shape": "Rectangle",
    "strokeCap": "LineCap.Round",
    "strokeColor": {
      "type": "Color.RGB",
      "args": [
        0,
        0,
        0
      ]
    },
    "strokeJoin": "LineJoin.Round",
    "strokePattern": "StrokeDash.Solid",
    "strokeThickness": 1,
    "strokeType": "StrokeType.Single",
    "text": "",
    "textColor": {
      "type": "Color.RGB",
      "args": [
        0,
        0,
        0
      ]
    },
    "textGeometry": {
      "type": "Rect",
      "args": [
        0,
        0,
        0,
        0
      ]
    },
    "textHorizontalAlignment": "HorizontalTextAlignment.Center",
    "textHorizontalPadding": 5,
    "textRotation": 0,
    "textRotationIsRelative": true,
    "textSize": 0,
    "textUnitRect": {
      "type": "Rect",
      "args": [
        0,
        0,
        1,
        1
      ]
    },
    "textVerticalPadding": 5,
    "textVerticalPlacement": "VerticalTextPlacement.Middle",
    "textWraps": true,
    "tripleBlend": false,
    "userData": {}
  }

Apparent line defaults:
{
    "type": "Line",
    "actionURL": null,
    "alignsEdgesToGrid": true,
    "allowsConnections": true,
    "automationAction": [],
    "bezierPoints": [],
    "connectedLines": [],
    "cornerRadius": 0,
    "flippedHorizontally": false,
    "flippedVertically": false,
    "head": null,
    "headMagnet": 0,
    "headScale": 1,
    "headType": "",
    "hopType": "HopType.None",
    "incomingLines": [],
    "lineType": "LineType.Straight",
    "locked": false,
    "name": null,
    "notes": "",
    "outgoingLines": [],
    "plasticCurve": null,
    "plasticHighlightAngle": null,
    "rotation": 0,
    "shadowColor": {
      "type": "Color.RGB",
      "args": [
        0,
        0,
        0
      ]
    },
    "shadowFuzziness": 3,
    "shadowVector": {
      "type": "Point",
      "args": [
        0,
        2
      ]
    },
    "strokeCap": "LineCap.Round",
    "strokeColor": {
      "type": "Color.RGB",
      "args": [
        0,
        0,
        0
      ]
    },
    "strokeJoin": "LineJoin.Round",
    "strokePattern": "StrokeDash.Solid",
    "strokeThickness": 1,
    "strokeType": "StrokeType.Single",
    "tail": null,
    "tailMagnet": 0,
    "tailScale": 1,
    "tailType": "",
    "userData": {}
  }
]

You’re right, this would be a good thing to document. The Copy As > JavaScript code quite literally internally creates a new default shape and line and then compares all property values of the copied shape/line to that internal default shape/line and only emits code where they differ.

So these defaults are internal to Graffle’s model and aren’t effected by settings or templates or defined by OmniJS.

1 Like