# Scaling geometry shapes

Hi,
I’m trying to substitute default rectangles for nodes with custom shapes created from geometry strings.
I have defined the strings inside symbols var then I perform the binding with a custom function as you can see below:

``````var symbols = {
"SYMBBTS":
"F M0 0 L0 30 30 30 30 0 0 0 M0 0 L30 30 M0 30 L30 0z",

"SYMBCOF":
"F M0 50 L50 0 100 50 M10 60 L50 20 90 60 M20 50 L80 50 80 110 20 50 M50 50 L50 110 M20 80 L80 80"
};

function nodeType2Symbol(type)
{
return symbols[type];
}

myDiagram.nodeTemplate = \$(go.Node, "Vertical",
\$(go.Shape,
{
strokeWidth: 2,
portId: ""
},
new go.Binding("geometryString", "symbol", nodeType2Symbol),
new go.Binding("fill", "mptype", nodeType2Color)
),
\$(go.TextBlock, {
margin: 8,
font: "700 14pt helvetica"
},
new go.Binding("text", "", createNodeLabel)
)
);
``````

Everything works fine, but I would like to know if it is possible to proportionally scale the shapes without manually changing the geometry strings. The first shape bounding box, for example, is 30x30px and if I would like to make is smaller, I have to multiply every coordinate for a scaling factor (let’s say 0.7), but it is a bit tedious and I have to add many more symbols.

Is there a way to do it programmatically? I have found this page about Geometry where there is the `scale(x,y)` method, but I do not know how to apply it to my case.

Many thanks,
Guido

The easiest way by far is just setting width and height in your shape:

``````\$(go.Shape,
{
strokeWidth: 2,
portId: "",
width: 30, height: 30 // add me
},
``````

The Shape’s size will be the size of its geometry unless width/height are set, in which case it will correctly scale the geometry to be that size.

Note also the Shape.geometryStretch property: http://gojs.net/latest/intro/shapes.html

Ok, done, thank you!