Graphic Properties

It is a basic tenet of all object-model scripting languages that scriptable objects have properties that define the way they look and interact in their parent containers. Since the Graphic class has subclasses, the properties of the Graphic class are inherited by all graphic items, including shapes, solids, and lines. Here’s a list of the properties of a graphic object in OmniGraffle:

Opacity

The opacity of a graphic is controlled by the alpha value of its fill or stroke color (see Color class). For example, this script will generate an instance of the Color class whose color is red with 50% transparency:

Color.RGB(1, 0, 0, 0.5)

Here is an Omni Automation plug-in for OmniGraffle that will change the opacity of the selected items (shapes, lines, and groups) to the percentage value provided by the plug-in user:

/*{ "type": "action", "targets": ["omnigraffle"], "author": "Otto Automator", "identifier": "com.omni-automation.og.set-opacity-of-selection", "version": "1.0", "description": "This action will set the opacity of the selected graphics to the indicated percentage.", "label": "Set Opacity", "shortLabel": "Opacity" }*/ (() => { function processStroke(item,opacity){ var c = item.strokeColor var newColor = Color.RGB(c.red, c.green, c.blue, opacity) item.strokeColor = newColor } function processFill(item,opacity){ var c = item.fillColor var newColor = Color.RGB(c.red, c.green, c.blue, opacity) item.fillColor = newColor } function processGroup(group,opacity,shouldIncludeStroke){ group.graphics.forEach(item => { if(item instanceof Shape){ processFill(item,opacity) if (shouldIncludeStroke){processStroke(item,opacity)} } if (item instanceof Line){ processStroke(item,opacity) } if (item instanceof Group){ processGroup(item,opacity,shouldIncludeStroke) } }) } var action = new PlugIn.Action(function(selection, sender){ // action code // selection options: canvas, document, graphics, lines, solids, view var textInputField = new Form.Field.String( "textInput", null, "50" ) var checkSwitchField = new Form.Field.Checkbox( "shouldIncludeStroke", "Apply opacity setting to shape’s stroke", true ) var inputForm = new Form() inputForm.addField(textInputField) inputForm.addField(checkSwitchField) var formPrompt = "Enter an opacity value (0-100):" var buttonTitle = "Continue" var formPromise = inputForm.show(formPrompt,buttonTitle) inputForm.validate = function(formObject){ inputText = formObject.values['textInput'] if (!inputText) {return false} var isnum = /^[0-9]+$/i.test(inputText) if (isnum){ var opacityValue = Number(inputText) return ((opacityValue >= 0 && opacityValue <= 100)? true:false) } return false } formPromise.then(function(formObject){ try { var textValue = formObject.values['textInput'] console.log('textValue: ',textValue) var shouldIncludeStroke = formObject.values['shouldIncludeStroke'] var opacityValue = Number(inputText) * .01 selection.graphics.forEach(item => { if (item instanceof Shape){ processFill(item,opacityValue) if (shouldIncludeStroke){processStroke(item,opacityValue)} } if (item instanceof Line){ processStroke(item,opacityValue) } if (item instanceof Group){ processGroup(item,opacityValue,shouldIncludeStroke) } }) } catch(err){ console.error(err.message) new Alert("ERROR",err.message).show() } }) formPromise.catch(function(err){ console.error("form cancelled", err.message) }) }); action.validate = function(selection, sender){ // validation code // selection options: canvas, document, graphics, lines, solids, view return (selection.graphics.length > 0) }; return action; })();
 

LineCap Properties

The LineCap properties are the value for the strokeCap property of the Graphic class:

 

LineJoin Properties

The LineJoin properties are the value for the strokeJoin property of the Graphic class:

 

StrokeDash Properties

The StrokeDash properties are the value for the strokePattern property of the Graphic class:

 

StrokeType Properties

The StrokeType properties are the value for the strokeType property (note lowercase s) of the Graphic class:

UNDER CONSTRUCTION

This webpage is in the process of being developed. Any content may change and may not be accurate or complete at this time.

DISCLAIMER