/** * SetBezierNodePosition sets the position of the passed node to the * position of the point pt parameter. All node control points are * set to this point as well * Requires: SetBezierNodePosition */ SetNodePosition = function(node, pt){ SetBezierNodePosition(node, pt,pt,pt); // set point position for all nodes to pt } /** * SetBezierNodePosition sets the position of the passed node to the * position of the points ptp (node predecessor), pt (main point), and * pts (node successor) */ SetBezierNodePosition = function(node, ptp, pt, pts){ node.predX = ptp.x; node.predY = ptp.y; // Predecessor point node.x = pt.x; node.y = pt.y; // Main points node.succX = pts.x; node.succY = pts.y; // Successor points } // create new path as first element in elements array smartShape.elem.elements[0] = new Path(); // create new contour as first contour in contours array smartShape.elem.elements[0].contours[0] = new Contour(); // set the contour to be a closed contour smartShape.elem.elements[0].contours[0].isClosed = true; // assign a short variable to represent the nodes array var nods = smartShape.elem.elements[0].contours[0].nodes; // create 4 nodes in the contour by altering the nodes array (nods) length nods.length = 4; // set the position of the 4 nodes in the first contour in a box shape SetNodePosition(nods[0], {x:50, y:50}); SetNodePosition(nods[1], {x:100, y:50}); SetNodePosition(nods[2], {x:100, y:100}); SetNodePosition(nods[3], {x:50, y:100}); // create new contour as second contour in contours array smartShape.elem.elements[0].contours[1] = new Contour(); // set the contour to be a closed contour smartShape.elem.elements[0].contours[1].isClosed = true; // assign a short variable to represent the nodes array nods = smartShape.elem.elements[0].contours[0].nodes; // create 4 nodes in the contour by altering the nodes array (nods) length nods.length = 4; // set the position of the 4 nodes in the second contour in a box shape // that lies within the box shape of the first contour SetNodePosition(nods[0], {x:60, y:60}); SetNodePosition(nods[1], {x:90, y:60}); SetNodePosition(nods[2], {x:90, y:90}); SetNodePosition(nods[3], {x:60, y:90});