From d96ddad9022176c9c6942da871c3ff4ca3c32c54 Mon Sep 17 00:00:00 2001 From: Alexis Deveria Date: Wed, 30 Jun 2010 18:27:36 +0000 Subject: [PATCH] More wacky internal changes and documentation updates git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1620 eee81c28-f429-11dd-99c0-75d572ba1ddd --- docs/files/svgcanvas-js.html | 76 +- docs/index/Functions.html | 22 +- docs/index/General.html | 22 +- docs/javascript/searchdata.js | 2 +- docs/search/FunctionsA.html | 2 +- docs/search/FunctionsC.html | 2 +- docs/search/FunctionsD.html | 2 +- docs/search/FunctionsG.html | 2 +- docs/search/FunctionsR.html | 2 +- docs/search/FunctionsS.html | 2 +- docs/search/GeneralA.html | 2 +- docs/search/GeneralC.html | 2 +- docs/search/GeneralD.html | 2 +- docs/search/GeneralF.html | 2 +- docs/search/GeneralG.html | 2 +- docs/search/GeneralR.html | 2 +- docs/search/GeneralS.html | 2 +- editor/locale/locale.js | 1 + editor/svg-editor.js | 2 +- editor/svgcanvas.js | 2198 +++++++++++++++++---------------- 20 files changed, 1251 insertions(+), 1098 deletions(-) diff --git a/docs/files/svgcanvas-js.html b/docs/files/svgcanvas-js.html index 8b164cdb..6f1b0b36 100644 --- a/docs/files/svgcanvas-js.html +++ b/docs/files/svgcanvas-js.html @@ -11,11 +11,23 @@ if (browserType) {document.write("
");if (browserV -

SvgCanvas

The main SvgCanvas class that manages all SVG-related functions

Parameters

containerThe container HTML element that should hold the SVG root element
configAn object that contains configuration data
Summary
SvgCanvasThe main SvgCanvas class that manages all SVG-related functions
toXmlConverts characters in a string to XML-friendly entities.
fromXmlConverts XML entities in a string to single characters.
Unit conversion functions
convertToNumConverts given values to numbers.
setUnitAttrSets an element’s attribute based on the unit in its current value.
isValidUnitCheck if an attribute’s value is in a valid format
Undo/Redo history management
ChangeElementCommandHistory command to make a change to an element.
ChangeElementCommand.applyPerforms the stored change action
ChangeElementCommand.unapplyReverses the stored change action
ChangeElementCommand.elementsReturns array with element associated with this command
InsertElementCommandHistory command for an element that was added to the DOM
InsertElementCommand.applyRe-Inserts the new element
InsertElementCommand.unapplyRemoves the element
InsertElementCommand.elementsReturns array with element associated with this command
RemoveElementCommandHistory command for an element removed from the DOM
RemoveElementCommand.applyRe-removes the new element
RemoveElementCommand.unapplyRe-adds the new element
RemoveElementCommand.elementsReturns array with element associated with this command
MoveElementCommandHistory command for an element that had its DOM position changed
MoveElementCommand.unapplyRe-positions the element
MoveElementCommand.unapplyPositions the element back to its original location
MoveElementCommand.elementsReturns array with element associated with this command
BatchCommandHistory command that can contain/execute multiple other commands
BatchCommand.applyRuns “apply” on all subcommands
BatchCommand.unapplyRuns “unapply” on all subcommands
BatchCommand.elementsIterate through all our subcommands and returns all the elements we are changing
BatchCommand.addSubCommandAdds a given command to the history stack
BatchCommand.isEmptyReturns a boolean indicating whether or not the batch command is empty
resetUndoStackResets the undo stack, effectively clearing the undo/redo history
undoMgr.getUndoStackSizeInteger with the current size of the undo history stack
undoMgr.getRedoStackSizeInteger with the current size of the redo history stack
undoMgr.getNextUndoCommandTextString associated with the next undo command
undoMgr.getNextRedoCommandTextString associated with the next redo command
undoMgr.undoPerforms an undo step
undoMgr.redoPerforms a redo step
addCommandToHistoryAdds a command object to the undo history stack
beginUndoableChangeThis function tells the canvas to remember the old values of the attrName attribute for each element sent in.
finishUndoableChangeThis function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
SelectorPrivate class for DOM element selection boxes
Functions
Selector.resetUsed to reset the id and element that the selector is attached to
Selector.showGripsShow the resize grips of this selector
Selector.updateGripCursorsUpdates cursors for corner grips on rotation so arrows point the right way
Selector.resizeUpdates the selector to match the element’s size
SelectorManagerPublic class to manage all selector objects (selection boxes)
SelectorManager.initGroupResets the parent selector group element
SelectorManager.requestSelectorReturns the selector based on the given element
SelectorManager.releaseSelectorRemoves the selector of the given element (hides selection box)
SelectorManager.getRubberBandBoxReturns the rubberBandBox DOM element.
Helper functions
walkTreeWalks the tree and executes the callback on each element in a top-down fashion
walkTreePostWalks the tree and executes the callback on each element in a depth-first fashion
assignAttributesAssigns multiple attributes to an element.
cleanupElementRemove unneeded (default) attributes, makes resulting SVG smaller
addSvgElementFromJsonCreate a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
shortFloatRounds a given value to a float with number of digits defined in save_options
getIdReturns the last created DOM element ID string
getNextIdCreates and returns a unique ID string for a DOM element
bindAttaches a callback function to an event
setIdPrefixChanges the ID prefix to the given value
sanitizeSvgSanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
getUrlFromAttrExtracts the URL from the url(...)
getBBoxGet the given/selected element’s bounding box object, convert it to be more usable when necessary
ffCloneHack for Firefox bugs where text element features aren’t updated.
getPathBBoxGet correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Element Transforms
getRotationAngleGet the rotation angle of the given/selected DOM element
setRotationAngleRemoves any old rotations if present, prepends a new rotation at the transformed center
getTransformListReturns an object that behaves like a SVGTransformList for the given DOM element
recalculateAllSelectedDimensionsRuns recalculateDimensions on the selected elements, adding the changes to a single batch command
remapElementApplies coordinate changes to an element based on the given matrix
recalculateDimensionsDecides the course of action based on the element’s transform list
transformPointA (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
isIdentityHelper function to check if the matrix performs no actual transform (i.e.
matrixMultiplyThis function tries to return a SVGMatrix that is the multiplication m1*m2.
transformListToTransformThis returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
hasMatrixTransformSee if the given transformlist includes a non-indentity matrix transform
getMatrixGet the matrix object for a given element
transformBoxTransforms a rectangle based on the given matrix
Selection
clearSelectionClears the selection.
addToSelectionAdds a list of elements to the selection.
removeFromSelectionRemoves elements from the selection.
selectAllInCurrentLayerClears the selection, then adds all elements in the current layer to the selection.
smoothControlPointsTakes three points and creates a smoother line based on them
getMouseTargetGets the desired element from a mouse event
Text edit functionsFunctions relating to editing text elements
Path edit functionsFunctions relating to editing path elements
Serialization
removeUnusedDefElemsLooks at DOM elements inside the <defs> to see if they are referred to, removes them from the DOM if they are not.
svgCanvasToStringMain function to set up the SVG content for output
svgToStringSub function ran on each SVG element to convert it to a string as desired
embedImageConverts a given image file to a data URL when possible, then runs a given callback
saveSerializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
rasterExportGenerates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
getSvgStringReturns the current drawing as raw SVG XML text.
setSvgStringThis function sets the current drawing as the input SVG XML.
importSvgStringThis function imports the input SVG XML into the current layer in the drawing
Layers
identifyLayersUpdates layer system
createLayerCreates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
deleteCurrentLayerDeletes the current layer from the drawing and then clears the selection.
getNumLayersReturns the number of layers in the current drawing.
getLayerReturns the name of the ith layer.
getCurrentLayerReturns the name of the currently selected layer.
setCurrentLayerSets the current layer.
renameCurrentLayerRenames the current layer.
setCurrentLayerPositionChanges the position of the current layer to the new value.
getLayerVisibilityReturns whether the layer is visible.
setLayerVisibilitySets the visibility of the layer.
moveSelectedToLayerMoves the selected elements to layername.
getLayerOpacityReturns the opacity of the given layer.
setLayerOpacitySets the opacity of the given layer.
Document functions
clearClears the current document.
linkControlPointsAlias function
getContentElemReturns the content DOM element
getRootElemReturns the root DOM element
getSelectedElemsReturns the array with selected DOM elements
getResolutionReturns the current dimensions and zoom level in an object
getDocumentTitleReturns the current document title or an empty string if not found
setDocumentTitleAdds/updates a title element for the document with the given name.
getEditorNSReturns the editor’s namespace URL, optionally adds it to root element
setResolutionChanges the document’s dimensions to the given size
getOffsetReturns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
setBBoxZoomSets the zoom level on the canvas-side based on the given value
setZoomSets the zoom to the given level
getModeReturns the current editor mode string
setModeSets the editor’s mode to the given string
Element Styling
getColorReturns the current fill/stroke option
setColorChange the current stroke/fill color/gradient value
findDefsReturn the document’s <defs> element, create it first if necessary
setGradientApply the current gradient to selected element’s fill or stroke
findDuplicateGradientCheck if exact gradient already exists
setPaintSet a color/gradient to a fill/stroke
getStrokeWidthReturns the current stroke-width value
setStrokeWidthSets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
setStrokeAttrSet the given stroke-related attribute the given value for selected elements
getOpacityReturns the current opacity
setOpacitySets the given opacity to the current selected elements
getOpacityReturns the current fill opacity
getStrokeOpacityReturns the current stroke opacity
setPaintOpacitySets the current fill/stroke opacity
getBlurGets the stdDeviation blur value of the given element
setBlurNoUndoSets the stdDeviation blur value on the selected element without being undoable
setBlurOffsetsSets the x, y, with, height values of the filter element in order to make the blur not be clipped.
setBlurAdds/updates the blur filter to the selected element
getBoldCheck whether selected element is bold or not
setBoldMake the selected element bold or normal
getItalicCheck whether selected element is italic or not
setItalicMake the selected element italic or normal
getFontFamilyReturns the current font family
setFontFamilySet the new font family
getFontSizeReturns the current font size
setFontSizeApplies the given font size to the selected element
getTextReturns the current text (textContent) of the selected element
setTextContentUpdates the text element with the given string
setImageURLSets the new image URL for the selected image element.
setRectRadiusSets the rx & ry values to the selected rect element to change its corner radius
setSegTypeSets the new segment type to the selected segment(s).
changeSelectedAttributeNoUndoThis function makes the changes to the elements.
changeSelectedAttributeChange the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
deleteSelectedElementsRemoves all selected elements from the DOM and adds the change to the history stack
groupSelectedElementsWraps all the selected elements in a group (g) element
ungroupSelectedElementUnwraps all the elements in a selected group (g) element.
convertToPathConvert selected element to a path, or get the BBox of an element-as-path
moveToTopSelectedElementRepositions the selected element to the bottom in the DOM to appear on top of other elements
moveToBottomSelectedElementRepositions the selected element to the top in the DOM to appear under other elements
moveSelectedElementsMoves selected elements on the X/Y axis
updateCanvasUpdates the editor canvas width/height/position after a zoom has occurred
getVersionReturns a string which describes the revision number of SvgCanvas.
+

SvgCanvas

The main SvgCanvas class that manages all SVG-related functions

Parameters

containerThe container HTML element that should hold the SVG root element
configAn object that contains configuration data
Summary
SvgCanvasThe main SvgCanvas class that manages all SVG-related functions
Utils.toXmlConverts characters in a string to XML-friendly entities.
Utils.fromXmlConverts XML entities in a string to single characters.
Utils.encode64Converts a string to base64
Utils.decode64Converts a string from base64
Utils.convertToXMLReferencesConverts a string to use XML references
rectsIntersectCheck if two rectangles (BBoxes objects) intersect each other
snapToAngleReturns a 45 degree angle coordinate associated with the two given coordinates
text2xmlCross-browser compatible method of converting a string to an XML tree found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f
Unit conversion functions
convertToNumConverts given values to numbers.
setUnitAttrSets an element’s attribute based on the unit in its current value.
isValidUnitCheck if an attribute’s value is in a valid format
Undo/Redo history management
ChangeElementCommandHistory command to make a change to an element.
ChangeElementCommand.applyPerforms the stored change action
ChangeElementCommand.unapplyReverses the stored change action
ChangeElementCommand.elementsReturns array with element associated with this command
InsertElementCommandHistory command for an element that was added to the DOM
InsertElementCommand.applyRe-Inserts the new element
InsertElementCommand.unapplyRemoves the element
InsertElementCommand.elementsReturns array with element associated with this command
RemoveElementCommandHistory command for an element removed from the DOM
RemoveElementCommand.applyRe-removes the new element
RemoveElementCommand.unapplyRe-adds the new element
RemoveElementCommand.elementsReturns array with element associated with this command
MoveElementCommandHistory command for an element that had its DOM position changed
MoveElementCommand.unapplyRe-positions the element
MoveElementCommand.unapplyPositions the element back to its original location
MoveElementCommand.elementsReturns array with element associated with this command
BatchCommandHistory command that can contain/execute multiple other commands
BatchCommand.applyRuns “apply” on all subcommands
BatchCommand.unapplyRuns “unapply” on all subcommands
BatchCommand.elementsIterate through all our subcommands and returns all the elements we are changing
BatchCommand.addSubCommandAdds a given command to the history stack
BatchCommand.isEmptyReturns a boolean indicating whether or not the batch command is empty
resetUndoStackResets the undo stack, effectively clearing the undo/redo history
undoMgr.getUndoStackSizeInteger with the current size of the undo history stack
undoMgr.getRedoStackSizeInteger with the current size of the redo history stack
undoMgr.getNextUndoCommandTextString associated with the next undo command
undoMgr.getNextRedoCommandTextString associated with the next redo command
undoMgr.undoPerforms an undo step
undoMgr.redoPerforms a redo step
addCommandToHistoryAdds a command object to the undo history stack
beginUndoableChangeThis function tells the canvas to remember the old values of the attrName attribute for each element sent in.
finishUndoableChangeThis function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
SelectorPrivate class for DOM element selection boxes
Functions
Selector.resetUsed to reset the id and element that the selector is attached to
Selector.showGripsShow the resize grips of this selector
Selector.updateGripCursorsUpdates cursors for corner grips on rotation so arrows point the right way
Selector.resizeUpdates the selector to match the element’s size
SelectorManagerPublic class to manage all selector objects (selection boxes)
SelectorManager.initGroupResets the parent selector group element
SelectorManager.requestSelectorReturns the selector based on the given element
SelectorManager.releaseSelectorRemoves the selector of the given element (hides selection box)
SelectorManager.getRubberBandBoxReturns the rubberBandBox DOM element.
Helper functions
walkTreeWalks the tree and executes the callback on each element in a top-down fashion
walkTreePostWalks the tree and executes the callback on each element in a depth-first fashion
assignAttributesAssigns multiple attributes to an element.
cleanupElementRemove unneeded (default) attributes, makes resulting SVG smaller
addSvgElementFromJsonCreate a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
addExtensionAdd an extension to the editor
shortFloatRounds a given value to a float with number of digits defined in save_options
getStrokedBBoxGet the bounding box for one or more stroked and/or transformed elements
getVisibleElementsGet all elements that have a BBox (excludes <defs>, <title>, etc).
copyElemCreate a clone of an element, updating its ID and its children’s IDs when needed
getElemGet a DOM element by ID within the SVG root element.
getIdReturns the last created DOM element ID string
getNextIdCreates and returns a unique ID string for a DOM element
bindAttaches a callback function to an event
setIdPrefixChanges the ID prefix to the given value
sanitizeSvgSanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
getUrlFromAttrExtracts the URL from the url(...)
getBBoxGet the given/selected element’s bounding box object, convert it to be more usable when necessary
ffCloneHack for Firefox bugs where text element features aren’t updated.
getPathBBoxGet correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Element Transforms
getRotationAngleGet the rotation angle of the given/selected DOM element
setRotationAngleRemoves any old rotations if present, prepends a new rotation at the transformed center
getTransformListReturns an object that behaves like a SVGTransformList for the given DOM element
recalculateAllSelectedDimensionsRuns recalculateDimensions on the selected elements, adding the changes to a single batch command
remapElementApplies coordinate changes to an element based on the given matrix
recalculateDimensionsDecides the course of action based on the element’s transform list
transformPointA (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
isIdentityHelper function to check if the matrix performs no actual transform (i.e.
matrixMultiplyThis function tries to return a SVGMatrix that is the multiplication m1*m2.
transformListToTransformThis returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
hasMatrixTransformSee if the given transformlist includes a non-indentity matrix transform
getMatrixGet the matrix object for a given element
transformBoxTransforms a rectangle based on the given matrix
Selection
clearSelectionClears the selection.
addToSelectionAdds a list of elements to the selection.
removeFromSelectionRemoves elements from the selection.
selectAllInCurrentLayerClears the selection, then adds all elements in the current layer to the selection.
smoothControlPointsTakes three points and creates a smoother line based on them
getMouseTargetGets the desired element from a mouse event
preventClickDefaultPrevents default browser click behaviour on the given element
Text edit functionsFunctions relating to editing text elements
Path edit functionsFunctions relating to editing path elements
Serialization
removeUnusedDefElemsLooks at DOM elements inside the <defs> to see if they are referred to, removes them from the DOM if they are not.
svgCanvasToStringMain function to set up the SVG content for output
svgToStringSub function ran on each SVG element to convert it to a string as desired
embedImageConverts a given image file to a data URL when possible, then runs a given callback
saveSerializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
rasterExportGenerates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
getSvgStringReturns the current drawing as raw SVG XML text.
setSvgStringThis function sets the current drawing as the input SVG XML.
importSvgStringThis function imports the input SVG XML into the current layer in the drawing
Layers
identifyLayersUpdates layer system
createLayerCreates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
deleteCurrentLayerDeletes the current layer from the drawing and then clears the selection.
getNumLayersReturns the number of layers in the current drawing.
getLayerReturns the name of the ith layer.
getCurrentLayerReturns the name of the currently selected layer.
setCurrentLayerSets the current layer.
renameCurrentLayerRenames the current layer.
setCurrentLayerPositionChanges the position of the current layer to the new value.
getLayerVisibilityReturns whether the layer is visible.
setLayerVisibilitySets the visibility of the layer.
moveSelectedToLayerMoves the selected elements to layername.
getLayerOpacityReturns the opacity of the given layer.
setLayerOpacitySets the opacity of the given layer.
Document functions
clearClears the current document.
linkControlPointsAlias function
getContentElemReturns the content DOM element
getRootElemReturns the root DOM element
getSelectedElemsReturns the array with selected DOM elements
getResolutionReturns the current dimensions and zoom level in an object
getZoomReturns the current zoom level
getVersionReturns a string which describes the revision number of SvgCanvas.
setUiStringsUpdate interface strings with given values
setConfigUpdate configuration options with given values
getDocumentTitleReturns the current document title or an empty string if not found
setDocumentTitleAdds/updates a title element for the document with the given name.
getEditorNSReturns the editor’s namespace URL, optionally adds it to root element
setResolutionChanges the document’s dimensions to the given size
getOffsetReturns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
setBBoxZoomSets the zoom level on the canvas-side based on the given value
setZoomSets the zoom to the given level
getModeReturns the current editor mode string
setModeSets the editor’s mode to the given string
Element Styling
getColorReturns the current fill/stroke option
setColorChange the current stroke/fill color/gradient value
findDefsReturn the document’s <defs> element, create it first if necessary
setGradientApply the current gradient to selected element’s fill or stroke
findDuplicateGradientCheck if exact gradient already exists
setPaintSet a color/gradient to a fill/stroke
getStrokeWidthReturns the current stroke-width value
setStrokeWidthSets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
setStrokeAttrSet the given stroke-related attribute the given value for selected elements
getOpacityReturns the current opacity
setOpacitySets the given opacity to the current selected elements
getOpacityReturns the current fill opacity
getStrokeOpacityReturns the current stroke opacity
setPaintOpacitySets the current fill/stroke opacity
getBlurGets the stdDeviation blur value of the given element
setBlurNoUndoSets the stdDeviation blur value on the selected element without being undoable
setBlurOffsetsSets the x, y, with, height values of the filter element in order to make the blur not be clipped.
setBlurAdds/updates the blur filter to the selected element
getBoldCheck whether selected element is bold or not
setBoldMake the selected element bold or normal
getItalicCheck whether selected element is italic or not
setItalicMake the selected element italic or normal
getFontFamilyReturns the current font family
setFontFamilySet the new font family
getFontSizeReturns the current font size
setFontSizeApplies the given font size to the selected element
getTextReturns the current text (textContent) of the selected element
setTextContentUpdates the text element with the given string
setImageURLSets the new image URL for the selected image element.
setRectRadiusSets the rx & ry values to the selected rect element to change its corner radius
Element manipulation
setSegTypeSets the new segment type to the selected segment(s).
convertToPathConvert selected element to a path, or get the BBox of an element-as-path
changeSelectedAttributeNoUndoThis function makes the changes to the elements.
changeSelectedAttributeChange the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
deleteSelectedElementsRemoves all selected elements from the DOM and adds the change to the history stack
groupSelectedElementsWraps all the selected elements in a group (g) element
ungroupSelectedElementUnwraps all the elements in a selected group (g) element.
moveToTopSelectedElementRepositions the selected element to the bottom in the DOM to appear on top of other elements
moveToBottomSelectedElementRepositions the selected element to the top in the DOM to appear under other elements
moveSelectedElementsMoves selected elements on the X/Y axis
cloneSelectedElementsCreate deep DOM copies (clones) of all selected elements and move them slightly from their originals
alignSelectedElementsAligns selected elements
Additional editor tools
updateCanvasUpdates the editor canvas width/height/position after a zoom has occurred
setBackgroundSet the background of the editor (NOT the actual document)
cycleElementSelect the next/previous element within the current layer
-

toXml

toXml = function(str)

Converts characters in a string to XML-friendly entities.

Example: “&” becomes “&amp;”

Parameters

strThe string to be converted

Returns

The converted string

+

Utils.toXml

Converts characters in a string to XML-friendly entities.

Example: “&” becomes “&amp;”

Parameters

strThe string to be converted

Returns

The converted string

-

fromXml

fromXml = function(str)

Converts XML entities in a string to single characters.  Example: “&amp;” becomes “&”

Parameters

strThe string to be converted

Returns

The converted string

+

Utils.fromXml

Converts XML entities in a string to single characters.  Example: “&amp;” becomes “&”

Parameters

strThe string to be converted

Returns

The converted string

+ +

Utils.encode64

Converts a string to base64

+ +

Utils.decode64

Converts a string from base64

+ +

Utils.convertToXMLReferences

Converts a string to use XML references

+ +

rectsIntersect

"rectsIntersect": function(r1,
r2)

Check if two rectangles (BBoxes objects) intersect each other

Paramaters

r1The first BBox-like object
r2The second BBox-like object

Returns

Boolean that’s true if rectangles intersect

+ +

snapToAngle

"snapToAngle": function(x1,
y1,
x2,
y2)

Returns a 45 degree angle coordinate associated with the two given coordinates

Parameters

x1First coordinate’s x value
x2Second coordinate’s x value
y1First coordinate’s y value
y2Second coordinate’s y value

Returns

Object with the following values: x - The angle-snapped x value y - The angle-snapped y value snapangle - The angle at which to snap

+ +

text2xml

"text2xml": function(sXML)

Cross-browser compatible method of converting a string to an XML tree found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f

Unit conversion functions

@@ -103,7 +115,7 @@ if (browserType) {document.write("
");if (browserV

Selector.resize

Updates the selector to match the element’s size

-

SelectorManager

Public class to manage all selector objects (selection boxes)

Summary
SelectorManager.initGroupResets the parent selector group element
SelectorManager.requestSelectorReturns the selector based on the given element
SelectorManager.releaseSelectorRemoves the selector of the given element (hides selection box)
SelectorManager.getRubberBandBoxReturns the rubberBandBox DOM element.
Helper functions
walkTreeWalks the tree and executes the callback on each element in a top-down fashion
walkTreePostWalks the tree and executes the callback on each element in a depth-first fashion
assignAttributesAssigns multiple attributes to an element.
cleanupElementRemove unneeded (default) attributes, makes resulting SVG smaller
addSvgElementFromJsonCreate a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
shortFloatRounds a given value to a float with number of digits defined in save_options
getIdReturns the last created DOM element ID string
getNextIdCreates and returns a unique ID string for a DOM element
bindAttaches a callback function to an event
setIdPrefixChanges the ID prefix to the given value
sanitizeSvgSanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
getUrlFromAttrExtracts the URL from the url(...)
getBBoxGet the given/selected element’s bounding box object, convert it to be more usable when necessary
ffCloneHack for Firefox bugs where text element features aren’t updated.
getPathBBoxGet correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Element Transforms
getRotationAngleGet the rotation angle of the given/selected DOM element
setRotationAngleRemoves any old rotations if present, prepends a new rotation at the transformed center
getTransformListReturns an object that behaves like a SVGTransformList for the given DOM element
recalculateAllSelectedDimensionsRuns recalculateDimensions on the selected elements, adding the changes to a single batch command
remapElementApplies coordinate changes to an element based on the given matrix
recalculateDimensionsDecides the course of action based on the element’s transform list
transformPointA (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
isIdentityHelper function to check if the matrix performs no actual transform (i.e.
matrixMultiplyThis function tries to return a SVGMatrix that is the multiplication m1*m2.
transformListToTransformThis returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
hasMatrixTransformSee if the given transformlist includes a non-indentity matrix transform
getMatrixGet the matrix object for a given element
transformBoxTransforms a rectangle based on the given matrix
Selection
clearSelectionClears the selection.
addToSelectionAdds a list of elements to the selection.
removeFromSelectionRemoves elements from the selection.
selectAllInCurrentLayerClears the selection, then adds all elements in the current layer to the selection.
smoothControlPointsTakes three points and creates a smoother line based on them
getMouseTargetGets the desired element from a mouse event
Text edit functionsFunctions relating to editing text elements
Path edit functionsFunctions relating to editing path elements
Serialization
removeUnusedDefElemsLooks at DOM elements inside the <defs> to see if they are referred to, removes them from the DOM if they are not.
svgCanvasToStringMain function to set up the SVG content for output
svgToStringSub function ran on each SVG element to convert it to a string as desired
embedImageConverts a given image file to a data URL when possible, then runs a given callback
saveSerializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
rasterExportGenerates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
getSvgStringReturns the current drawing as raw SVG XML text.
setSvgStringThis function sets the current drawing as the input SVG XML.
importSvgStringThis function imports the input SVG XML into the current layer in the drawing
Layers
identifyLayersUpdates layer system
createLayerCreates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
deleteCurrentLayerDeletes the current layer from the drawing and then clears the selection.
getNumLayersReturns the number of layers in the current drawing.
getLayerReturns the name of the ith layer.
getCurrentLayerReturns the name of the currently selected layer.
setCurrentLayerSets the current layer.
renameCurrentLayerRenames the current layer.
setCurrentLayerPositionChanges the position of the current layer to the new value.
getLayerVisibilityReturns whether the layer is visible.
setLayerVisibilitySets the visibility of the layer.
moveSelectedToLayerMoves the selected elements to layername.
getLayerOpacityReturns the opacity of the given layer.
setLayerOpacitySets the opacity of the given layer.
Document functions
clearClears the current document.
linkControlPointsAlias function
getContentElemReturns the content DOM element
getRootElemReturns the root DOM element
getSelectedElemsReturns the array with selected DOM elements
getResolutionReturns the current dimensions and zoom level in an object
getDocumentTitleReturns the current document title or an empty string if not found
setDocumentTitleAdds/updates a title element for the document with the given name.
getEditorNSReturns the editor’s namespace URL, optionally adds it to root element
setResolutionChanges the document’s dimensions to the given size
getOffsetReturns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
setBBoxZoomSets the zoom level on the canvas-side based on the given value
setZoomSets the zoom to the given level
getModeReturns the current editor mode string
setModeSets the editor’s mode to the given string
Element Styling
getColorReturns the current fill/stroke option
setColorChange the current stroke/fill color/gradient value
findDefsReturn the document’s <defs> element, create it first if necessary
setGradientApply the current gradient to selected element’s fill or stroke
findDuplicateGradientCheck if exact gradient already exists
setPaintSet a color/gradient to a fill/stroke
getStrokeWidthReturns the current stroke-width value
setStrokeWidthSets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
setStrokeAttrSet the given stroke-related attribute the given value for selected elements
getOpacityReturns the current opacity
setOpacitySets the given opacity to the current selected elements
getOpacityReturns the current fill opacity
getStrokeOpacityReturns the current stroke opacity
setPaintOpacitySets the current fill/stroke opacity
getBlurGets the stdDeviation blur value of the given element
setBlurNoUndoSets the stdDeviation blur value on the selected element without being undoable
setBlurOffsetsSets the x, y, with, height values of the filter element in order to make the blur not be clipped.
setBlurAdds/updates the blur filter to the selected element
getBoldCheck whether selected element is bold or not
setBoldMake the selected element bold or normal
getItalicCheck whether selected element is italic or not
setItalicMake the selected element italic or normal
getFontFamilyReturns the current font family
setFontFamilySet the new font family
getFontSizeReturns the current font size
setFontSizeApplies the given font size to the selected element
getTextReturns the current text (textContent) of the selected element
setTextContentUpdates the text element with the given string
setImageURLSets the new image URL for the selected image element.
setRectRadiusSets the rx & ry values to the selected rect element to change its corner radius
setSegTypeSets the new segment type to the selected segment(s).
changeSelectedAttributeNoUndoThis function makes the changes to the elements.
changeSelectedAttributeChange the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
deleteSelectedElementsRemoves all selected elements from the DOM and adds the change to the history stack
groupSelectedElementsWraps all the selected elements in a group (g) element
ungroupSelectedElementUnwraps all the elements in a selected group (g) element.
convertToPathConvert selected element to a path, or get the BBox of an element-as-path
moveToTopSelectedElementRepositions the selected element to the bottom in the DOM to appear on top of other elements
moveToBottomSelectedElementRepositions the selected element to the top in the DOM to appear under other elements
moveSelectedElementsMoves selected elements on the X/Y axis
updateCanvasUpdates the editor canvas width/height/position after a zoom has occurred
getVersionReturns a string which describes the revision number of SvgCanvas.
+

SelectorManager

Public class to manage all selector objects (selection boxes)

Summary
SelectorManager.initGroupResets the parent selector group element
SelectorManager.requestSelectorReturns the selector based on the given element
SelectorManager.releaseSelectorRemoves the selector of the given element (hides selection box)
SelectorManager.getRubberBandBoxReturns the rubberBandBox DOM element.
Helper functions
walkTreeWalks the tree and executes the callback on each element in a top-down fashion
walkTreePostWalks the tree and executes the callback on each element in a depth-first fashion
assignAttributesAssigns multiple attributes to an element.
cleanupElementRemove unneeded (default) attributes, makes resulting SVG smaller
addSvgElementFromJsonCreate a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
addExtensionAdd an extension to the editor
shortFloatRounds a given value to a float with number of digits defined in save_options
getStrokedBBoxGet the bounding box for one or more stroked and/or transformed elements
getVisibleElementsGet all elements that have a BBox (excludes <defs>, <title>, etc).
copyElemCreate a clone of an element, updating its ID and its children’s IDs when needed
getElemGet a DOM element by ID within the SVG root element.
getIdReturns the last created DOM element ID string
getNextIdCreates and returns a unique ID string for a DOM element
bindAttaches a callback function to an event
setIdPrefixChanges the ID prefix to the given value
sanitizeSvgSanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
getUrlFromAttrExtracts the URL from the url(...)
getBBoxGet the given/selected element’s bounding box object, convert it to be more usable when necessary
ffCloneHack for Firefox bugs where text element features aren’t updated.
getPathBBoxGet correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Element Transforms
getRotationAngleGet the rotation angle of the given/selected DOM element
setRotationAngleRemoves any old rotations if present, prepends a new rotation at the transformed center
getTransformListReturns an object that behaves like a SVGTransformList for the given DOM element
recalculateAllSelectedDimensionsRuns recalculateDimensions on the selected elements, adding the changes to a single batch command
remapElementApplies coordinate changes to an element based on the given matrix
recalculateDimensionsDecides the course of action based on the element’s transform list
transformPointA (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
isIdentityHelper function to check if the matrix performs no actual transform (i.e.
matrixMultiplyThis function tries to return a SVGMatrix that is the multiplication m1*m2.
transformListToTransformThis returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
hasMatrixTransformSee if the given transformlist includes a non-indentity matrix transform
getMatrixGet the matrix object for a given element
transformBoxTransforms a rectangle based on the given matrix
Selection
clearSelectionClears the selection.
addToSelectionAdds a list of elements to the selection.
removeFromSelectionRemoves elements from the selection.
selectAllInCurrentLayerClears the selection, then adds all elements in the current layer to the selection.
smoothControlPointsTakes three points and creates a smoother line based on them
getMouseTargetGets the desired element from a mouse event
preventClickDefaultPrevents default browser click behaviour on the given element
Text edit functionsFunctions relating to editing text elements
Path edit functionsFunctions relating to editing path elements
Serialization
removeUnusedDefElemsLooks at DOM elements inside the <defs> to see if they are referred to, removes them from the DOM if they are not.
svgCanvasToStringMain function to set up the SVG content for output
svgToStringSub function ran on each SVG element to convert it to a string as desired
embedImageConverts a given image file to a data URL when possible, then runs a given callback
saveSerializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
rasterExportGenerates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
getSvgStringReturns the current drawing as raw SVG XML text.
setSvgStringThis function sets the current drawing as the input SVG XML.
importSvgStringThis function imports the input SVG XML into the current layer in the drawing
Layers
identifyLayersUpdates layer system
createLayerCreates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
deleteCurrentLayerDeletes the current layer from the drawing and then clears the selection.
getNumLayersReturns the number of layers in the current drawing.
getLayerReturns the name of the ith layer.
getCurrentLayerReturns the name of the currently selected layer.
setCurrentLayerSets the current layer.
renameCurrentLayerRenames the current layer.
setCurrentLayerPositionChanges the position of the current layer to the new value.
getLayerVisibilityReturns whether the layer is visible.
setLayerVisibilitySets the visibility of the layer.
moveSelectedToLayerMoves the selected elements to layername.
getLayerOpacityReturns the opacity of the given layer.
setLayerOpacitySets the opacity of the given layer.
Document functions
clearClears the current document.
linkControlPointsAlias function
getContentElemReturns the content DOM element
getRootElemReturns the root DOM element
getSelectedElemsReturns the array with selected DOM elements
getResolutionReturns the current dimensions and zoom level in an object
getZoomReturns the current zoom level
getVersionReturns a string which describes the revision number of SvgCanvas.
setUiStringsUpdate interface strings with given values
setConfigUpdate configuration options with given values
getDocumentTitleReturns the current document title or an empty string if not found
setDocumentTitleAdds/updates a title element for the document with the given name.
getEditorNSReturns the editor’s namespace URL, optionally adds it to root element
setResolutionChanges the document’s dimensions to the given size
getOffsetReturns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
setBBoxZoomSets the zoom level on the canvas-side based on the given value
setZoomSets the zoom to the given level
getModeReturns the current editor mode string
setModeSets the editor’s mode to the given string
Element Styling
getColorReturns the current fill/stroke option
setColorChange the current stroke/fill color/gradient value
findDefsReturn the document’s <defs> element, create it first if necessary
setGradientApply the current gradient to selected element’s fill or stroke
findDuplicateGradientCheck if exact gradient already exists
setPaintSet a color/gradient to a fill/stroke
getStrokeWidthReturns the current stroke-width value
setStrokeWidthSets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
setStrokeAttrSet the given stroke-related attribute the given value for selected elements
getOpacityReturns the current opacity
setOpacitySets the given opacity to the current selected elements
getOpacityReturns the current fill opacity
getStrokeOpacityReturns the current stroke opacity
setPaintOpacitySets the current fill/stroke opacity
getBlurGets the stdDeviation blur value of the given element
setBlurNoUndoSets the stdDeviation blur value on the selected element without being undoable
setBlurOffsetsSets the x, y, with, height values of the filter element in order to make the blur not be clipped.
setBlurAdds/updates the blur filter to the selected element
getBoldCheck whether selected element is bold or not
setBoldMake the selected element bold or normal
getItalicCheck whether selected element is italic or not
setItalicMake the selected element italic or normal
getFontFamilyReturns the current font family
setFontFamilySet the new font family
getFontSizeReturns the current font size
setFontSizeApplies the given font size to the selected element
getTextReturns the current text (textContent) of the selected element
setTextContentUpdates the text element with the given string
setImageURLSets the new image URL for the selected image element.
setRectRadiusSets the rx & ry values to the selected rect element to change its corner radius
Element manipulation
setSegTypeSets the new segment type to the selected segment(s).
convertToPathConvert selected element to a path, or get the BBox of an element-as-path
changeSelectedAttributeNoUndoThis function makes the changes to the elements.
changeSelectedAttributeChange the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
deleteSelectedElementsRemoves all selected elements from the DOM and adds the change to the history stack
groupSelectedElementsWraps all the selected elements in a group (g) element
ungroupSelectedElementUnwraps all the elements in a selected group (g) element.
moveToTopSelectedElementRepositions the selected element to the bottom in the DOM to appear on top of other elements
moveToBottomSelectedElementRepositions the selected element to the top in the DOM to appear under other elements
moveSelectedElementsMoves selected elements on the X/Y axis
cloneSelectedElementsCreate deep DOM copies (clones) of all selected elements and move them slightly from their originals
alignSelectedElementsAligns selected elements
Additional editor tools
updateCanvasUpdates the editor canvas width/height/position after a zoom has occurred
setBackgroundSet the background of the editor (NOT the actual document)
cycleElementSelect the next/previous element within the current layer

SelectorManager.initGroup

Resets the parent selector group element

@@ -125,8 +137,18 @@ if (browserType) {document.write("
");if (browserV

addSvgElementFromJson

var addSvgElementFromJson = this.addSvgElementFromJson = function(data)

Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned

Parameters

dataObject with the following keys/values:
  • element - DOM element to create
  • attr - Object with attributes/values to assign to the new element
  • curStyles - Boolean indicating that current style attributes should be applied first

Returns: The new element

+

addExtension

this.addExtension = function(name,
ext_func)

Add an extension to the editor

Parameters

nameString with the ID of the extension
ext_funcFunction supplied by the extension with its data
+

shortFloat

var shortFloat = function(val)

Rounds a given value to a float with number of digits defined in save_options

Parameters

valThe value as a String, Number or Array of two numbers to be rounded

Returns

If a string/number was given, returns a Float.  If an array, return a string with comma-seperated floats

+

getStrokedBBox

var getStrokedBBox = this.getStrokedBBox = function(elems)

Get the bounding box for one or more stroked and/or transformed elements

Parameters

elemsArray with DOM elements to check

Returns

A single bounding box object

+ +

getVisibleElements

var getVisibleElements = this.getVisibleElements = function(parent,
includeBBox)

Get all elements that have a BBox (excludes <defs>, <title>, etc).  Note that 0-opacity, off-screen etc elements are still considered “visible” for this function

Parameters

parentThe parent DOM element to search within
includeBBoxBoolean to indicate that an object should return with the element and its bbox

Returns

An array with all “visible” elements, or if includeBBox is true, an array with objects that include:

  • elem - The element
  • bbox - The element’s BBox as retrieved from getStrokedBBox
+ +

copyElem

var copyElem = function(el)

Create a clone of an element, updating its ID and its children’s IDs when needed

Parameters

elDOM element to clone

Returns: The cloned element

+ +

getElem

function getElem(id)

Get a DOM element by ID within the SVG root element.

Parameters

idString with the element’s new ID
+

getId

getId = c.getId = function()

Returns the last created DOM element ID string

getNextId

getNextId = c.getNextId = function()

Creates and returns a unique ID string for a DOM element

@@ -139,7 +161,7 @@ if (browserType) {document.write("
");if (browserV

getUrlFromAttr

var getUrlFromAttr = this.getUrlFromAttr = function(attrVal)

Extracts the URL from the url(...) syntax of some attributes.  Three variants:

  • <circle fill=”url(someFile.svg#foo)” />
  • <circle fill=”url(‘someFile.svg#foo’)” />
  • <circle fill=’url(“someFile.svg#foo”)’ />

Parameters

attrValThe attribute value as a string

Returns

String with just the URL, like someFile.svg#foo

-

getBBox

this.getBBox = function(elem)

Get the given/selected element’s bounding box object, convert it to be more usable when necessary

Parameters

elemOptional DOM element to get the BBox for
+

getBBox

var getBBox = this.getBBox = function(elem)

Get the given/selected element’s bounding box object, convert it to be more usable when necessary

Parameters

elemOptional DOM element to get the BBox for

ffClone

var ffClone = function(elem)

Hack for Firefox bugs where text element features aren’t updated.  This function clones the element and re-selects it TODO: Test for this bug on load and add it to “support” object instead of browser sniffing

Parameters

elemThe (text) DOM element to clone
@@ -147,11 +169,11 @@ if (browserType) {document.write("
");if (browserV

Element Transforms

-

getRotationAngle

this.getRotationAngle = function(elem,
to_rad)

Get the rotation angle of the given/selected DOM element

Parameters

elemOptional DOM element to get the angle for
to_radBoolean that when true returns the value in radians rather than degrees

Returns

Float with the angle in degrees or radians

+

getRotationAngle

var getRotationAngle = this.getRotationAngle = function(elem,
to_rad)

Get the rotation angle of the given/selected DOM element

Parameters

elemOptional DOM element to get the angle for
to_radBoolean that when true returns the value in radians rather than degrees

Returns

Float with the angle in degrees or radians

setRotationAngle

this.setRotationAngle = function(val,
preventUndo)

Removes any old rotations if present, prepends a new rotation at the transformed center

Parameters

valThe new rotation angle in degrees
preventUndoBoolean indicating whether the action should be undoable or not
-

getTransformList

this.getTransformList = function(elem)

Returns an object that behaves like a SVGTransformList for the given DOM element

Parameters

elemDOM element to get a transformlist from
+

getTransformList

var getTransformList = this.getTransformList = function(elem)

Returns an object that behaves like a SVGTransformList for the given DOM element

Parameters

elemDOM element to get a transformlist from

recalculateAllSelectedDimensions

var recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = function()

Runs recalculateDimensions on the selected elements, adding the changes to a single batch command

@@ -175,11 +197,11 @@ if (browserType) {document.write("
");if (browserV

Selection

-

clearSelection

this.clearSelection = function(noCall)

Clears the selection.  The ‘selected’ handler is then called.  Parameters: noCall - Optional boolean that when true does not call the “selected” handler

+

clearSelection

var clearSelection = this.clearSelection = function(noCall)

Clears the selection.  The ‘selected’ handler is then called.  Parameters: noCall - Optional boolean that when true does not call the “selected” handler

-

addToSelection

this.addToSelection = function(elemsToAdd,
showGrips)

Adds a list of elements to the selection.  The ‘selected’ handler is then called.

Parameters

elemsToAddan array of DOM elements to add to the selection
showGripsa boolean flag indicating whether the resize grips should be shown
+

addToSelection

var addToSelection = this.addToSelection = function(elemsToAdd,
showGrips)

Adds a list of elements to the selection.  The ‘selected’ handler is then called.

Parameters

elemsToAddan array of DOM elements to add to the selection
showGripsa boolean flag indicating whether the resize grips should be shown
-

removeFromSelection

this.removeFromSelection = function(elemsToRemove)

Removes elements from the selection.

Parameters

elemsToRemovean array of elements to remove from selection
+

removeFromSelection

var removeFromSelection = this.removeFromSelection = function(elemsToRemove)

Removes elements from the selection.

Parameters

elemsToRemovean array of elements to remove from selection

selectAllInCurrentLayer

this.selectAllInCurrentLayer = function()

Clears the selection, then adds all elements in the current layer to the selection.  This function then fires the selected event.

@@ -187,6 +209,8 @@ if (browserType) {document.write("
");if (browserV

getMouseTarget

var getMouseTarget = this.getMouseTarget = function(evt)

Gets the desired element from a mouse event

Parameters

evtEvent object from the mouse event

Returns

DOM element we want

+

preventClickDefault

var preventClickDefault = function(img)

Prevents default browser click behaviour on the given element

Parameters

imgThe DOM element to prevent the cilck on
+

Text edit functions

Functions relating to editing text elements

Path edit functions

Functions relating to editing path elements

@@ -253,7 +277,15 @@ if (browserType) {document.write("
");if (browserV

getSelectedElems

this.getSelectedElems = function()

Returns the array with selected DOM elements

-

getResolution

this.getResolution = function()

Returns the current dimensions and zoom level in an object

+

getResolution

var getResolution = this.getResolution = function()

Returns the current dimensions and zoom level in an object

+ +

getZoom

this.getZoom = function()

Returns the current zoom level

+ +

getVersion

this.getVersion = function()

Returns a string which describes the revision number of SvgCanvas.

+ +

setUiStrings

this.setUiStrings = function(strs)

Update interface strings with given values

Parameters

strsObject with strings (see uiStrings for examples)
+ +

setConfig

this.setConfig = function(opts)

Update configuration options with given values

Parameters

optsObject with options (see curConfig for examples)

getDocumentTitle

this.getDocumentTitle = function()

Returns the current document title or an empty string if not found

@@ -335,11 +367,15 @@ if (browserType) {document.write("
");if (browserV

setRectRadius

this.setRectRadius = function(val)

Sets the rx & ry values to the selected rect element to change its corner radius

Parameters

valThe new radius
+

Element manipulation

+

setSegType

this.setSegType = function(new_type)

Sets the new segment type to the selected segment(s).

Parameters

new_typeInteger with the new segment type See http://www.w3.org/TR/SVG/paths.html#InterfaceSVGPathSeg for list
-

changeSelectedAttributeNoUndo

this.changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)

This function makes the changes to the elements.  It does not add the change to the history stack.

Parameters

attrString with the attribute name
newValueString or number with the new attribute value
elemsThe DOM elements to apply the change to
+

convertToPath

this.convertToPath = function(elem,
getBBox)

Convert selected element to a path, or get the BBox of an element-as-path

Parameters

elemThe DOM element to be converted
getBBoxBoolean on whether or not to only return the path’s BBox

Returns

If the getBBox flag is true, the resulting path’s bounding box object.  Otherwise the resulting path element is returned.

-

changeSelectedAttribute

this.changeSelectedAttribute = function(attr,
val,
elems)

Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.  If you want to change only a subset of selectedElements, then send the subset to this function in the elems argument.

Parameters

attrString with the attribute name
newValueString or number with the new attribute value
elemsThe DOM elements to apply the change to
+

changeSelectedAttributeNoUndo

var changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)

This function makes the changes to the elements.  It does not add the change to the history stack.

Parameters

attrString with the attribute name
newValueString or number with the new attribute value
elemsThe DOM elements to apply the change to
+ +

changeSelectedAttribute

var changeSelectedAttribute = this.changeSelectedAttribute = function(attr,
val,
elems)

Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.  If you want to change only a subset of selectedElements, then send the subset to this function in the elems argument.

Parameters

attrString with the attribute name
newValueString or number with the new attribute value
elemsThe DOM elements to apply the change to

deleteSelectedElements

this.deleteSelectedElements = function()

Removes all selected elements from the DOM and adds the change to the history stack

@@ -347,17 +383,23 @@ if (browserType) {document.write("
");if (browserV

ungroupSelectedElement

this.ungroupSelectedElement = function()

Unwraps all the elements in a selected group (g) element.  This requires significant recalculations to apply group’s transforms, etc to its children

-

convertToPath

this.convertToPath = function(elem,
getBBox)

Convert selected element to a path, or get the BBox of an element-as-path

Parameters

elemThe DOM element to be converted
getBBoxBoolean on whether or not to only return the path’s BBox

Returns

If the getBBox flag is true, the resulting path’s bounding box object.  Otherwise the resulting path element is returned.

-

moveToTopSelectedElement

this.moveToTopSelectedElement = function()

Repositions the selected element to the bottom in the DOM to appear on top of other elements

moveToBottomSelectedElement

this.moveToBottomSelectedElement = function()

Repositions the selected element to the top in the DOM to appear under other elements

moveSelectedElements

this.moveSelectedElements = function(dx,
dy,
undoable)

Moves selected elements on the X/Y axis

Parameters

dxFloat with the distance to move on the x-axis
dyFloat with the distance to move on the y-axis
undoableBoolean indicating whether or not the action should be undoable

Returns

Batch command for the move

+

cloneSelectedElements

this.cloneSelectedElements = function()

Create deep DOM copies (clones) of all selected elements and move them slightly from their originals

+ +

alignSelectedElements

this.alignSelectedElements = function(type,
relative_to)

Aligns selected elements

Parameters

typeString with single character indicating the alignment type
relative_toString that must be one of the following: “selected”, “largest”, “smallest”, “page”
+ +

Additional editor tools

+

updateCanvas

this.updateCanvas = function(w,
h)

Updates the editor canvas width/height/position after a zoom has occurred

Parameters

wFloat with the new width
hFloat with the new height

Returns

Object with the following values:

  • x - The canvas’ new x coordinate
  • y - The canvas’ new y coordinate
  • old_x - The canvas’ old x coordinate
  • old_y - The canvas’ old y coordinate
  • d_x - The x position difference
  • d_y - The y position difference
-

getVersion

this.getVersion = function()

Returns a string which describes the revision number of SvgCanvas.

+

setBackground

this.setBackground = function(color,
url)

Set the background of the editor (NOT the actual document)

Parameters

colorString with fill color to apply
urlURL or path to image to use
+ +

cycleElement

this.cycleElement = function(next)

Select the next/previous element within the current layer

Parameters

nextBoolean where true = next and false = previous element
@@ -372,7 +414,7 @@ var searchPanel = new SearchPanel("searchPanel", "HTML", "../search"); -
toXml = function(str)
Converts characters in a string to XML-friendly entities.
fromXml = function(str)
Converts XML entities in a string to single characters.
convertToNum = function(attr,
val)
Converts given values to numbers.
setUnitAttr = function(elem,
attr,
val)
Sets an element’s attribute based on the unit in its current value.
canvas.isValidUnit = function(attr,
val)
Check if an attribute’s value is in a valid format
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
var InsertElementCommand = this.undoCmd.insertElement = function(elem,
text)
History command for an element that was added to the DOM
var RemoveElementCommand = this.undoCmd.removeElement = function(elem,
parent,
text)
History command for an element removed from the DOM
var MoveElementCommand = this.undoCmd.moveElement = function(elem,
oldNextSibling,
oldParent,
text)
History command for an element that had its DOM position changed
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
resetUndoStack = function()
Resets the undo stack, effectively clearing the undo/redo history
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
function walkTree(elem,
cbFn)
Walks the tree and executes the callback on each element in a top-down fashion
function walkTreePost(elem,
cbFn)
Walks the tree and executes the callback on each element in a depth-first fashion
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
var shortFloat = function(val)
Rounds a given value to a float with number of digits defined in save_options
getId = c.getId = function()
Returns the last created DOM element ID string
getNextId = c.getNextId = function()
Creates and returns a unique ID string for a DOM element
c.bind = function(event,
f)
Attaches a callback function to an event
c.setIdPrefix = function(p)
Changes the ID prefix to the given value
var sanitizeSvg = this.sanitizeSvg = function(node)
Sanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
var getUrlFromAttr = this.getUrlFromAttr = function(attrVal)
Extracts the URL from the url(...)
this.getBBox = function(elem)
Get the given/selected element’s bounding box object, convert it to be more usable when necessary
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var getPathBBox = function(path)
Get correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
this.getRotationAngle = function(elem,
to_rad)
Get the rotation angle of the given/selected DOM element
this.setRotationAngle = function(val,
preventUndo)
Removes any old rotations if present, prepends a new rotation at the transformed center
this.getTransformList = function(elem)
Returns an object that behaves like a SVGTransformList for the given DOM element
var recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = function()
Runs recalculateDimensions on the selected elements, adding the changes to a single batch command
var remapElement = this.remapElement = function(selected,
changes,
m)
Applies coordinate changes to an element based on the given matrix
var recalculateDimensions = this.recalculateDimensions = function(selected)
Decides the course of action based on the element’s transform list
var transformPoint = function(x,
y,
m)
A (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
var isIdentity = function(m)
Helper function to check if the matrix performs no actual transform (i.e.
var matrixMultiply = this.matrixMultiply = function()
This function tries to return a SVGMatrix that is the multiplication m1*m2.
var transformListToTransform = this.transformListToTransform = function(tlist,
min,
max)
This returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
var hasMatrixTransform = this.hasMatrixTransform = function(tlist)
See if the given transformlist includes a non-indentity matrix transform
var getMatrix = function(elem)
Get the matrix object for a given element
var transformBox = this.transformBox = function(l,
t,
w,
h,
m)
Transforms a rectangle based on the given matrix
this.clearSelection = function(noCall)
Clears the selection.
this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
this.removeFromSelection = function(elemsToRemove)
Removes elements from the selection.
this.selectAllInCurrentLayer = function()
Clears the selection, then adds all elements in the current layer to the selection.
var smoothControlPoints = this.smoothControlPoints = function(ct1,
ct2,
pt)
Takes three points and creates a smoother line based on them
var getMouseTarget = this.getMouseTarget = function(evt)
Gets the desired element from a mouse event
var removeUnusedDefElems = this.removeUnusedDefElems = function()
Looks at DOM elements inside the defs to see if they are referred to, removes them from the DOM if they are not.
var svgCanvasToString = this.svgCanvasToString = function()
Main function to set up the SVG content for output
var svgToString = this.svgToString = function(elem,
indent)
Sub function ran on each SVG element to convert it to a string as desired
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
this.save = function(opts)
Serializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
this.rasterExport = function()
Generates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
this.getSvgString = function()
Returns the current drawing as raw SVG XML text.
this.setSvgString = function(xmlString)
This function sets the current drawing as the input SVG XML.
this.importSvgString = function(xmlString)
This function imports the input SVG XML into the current layer in the drawing
var identifyLayers = function()
Updates layer system
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.getNumLayers = function()
Returns the number of layers in the current drawing.
this.getLayer = function(i)
Returns the name of the ith layer.
this.getCurrentLayer = function()
Returns the name of the currently selected layer.
this.setCurrentLayer = function(name)
Sets the current layer.
this.renameCurrentLayer = function(newname)
Renames the current layer.
this.setCurrentLayerPosition = function(newpos)
Changes the position of the current layer to the new value.
this.getLayerVisibility = function(layername)
Returns whether the layer is visible.
this.setLayerVisibility = function(layername,
bVisible)
Sets the visibility of the layer.
this.moveSelectedToLayer = function(layername)
Moves the selected elements to layername.
this.getLayerOpacity = function(layername)
Returns the opacity of the given layer.
this.setLayerOpacity = function(layername,
opacity)
Sets the opacity of the given layer.
this.clear = function()
Clears the current document.
this.getContentElem = function()
Returns the content DOM element
this.getRootElem = function()
Returns the root DOM element
this.getSelectedElems = function()
Returns the array with selected DOM elements
this.getResolution = function()
Returns the current dimensions and zoom level in an object
this.getDocumentTitle = function()
Returns the current document title or an empty string if not found
this.setDocumentTitle = function(newtitle)
Adds/updates a title element for the document with the given name.
this.getEditorNS = function(add)
Returns the editor’s namespace URL, optionally adds it to root element
this.setResolution = function(x,
y)
Changes the document’s dimensions to the given size
this.getOffset = function()
Returns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
this.setBBoxZoom = function(val,
editor_w,
editor_h)
Sets the zoom level on the canvas-side based on the given value
this.setZoom = function(zoomlevel)
Sets the zoom to the given level
this.getMode = function()
Returns the current editor mode string
this.setMode = function(name)
Sets the editor’s mode to the given string
this.getColor = function(type)
Returns the current fill/stroke option
this.setColor = function(type,
val,
preventUndo)
Change the current stroke/fill color/gradient value
var findDefs = function()
Return the document’s defs element, create it first if necessary
var setGradient = this.setGradient = function(type)
Apply the current gradient to selected element’s fill or stroke
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
this.setPaint = function(type,
paint)
Set a color/gradient to a fill/stroke
this.getStrokeWidth = function()
Returns the current stroke-width value
this.setStrokeWidth = function(val)
Sets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
this.setStrokeAttr = function(attr,
val)
Set the given stroke-related attribute the given value for selected elements
this.getOpacity = function()
Returns the current opacity
this.setOpacity = function(val)
Sets the given opacity to the current selected elements
this.getStrokeOpacity = function()
Returns the current stroke opacity
this.setPaintOpacity = function(type,
val,
preventUndo)
Sets the current fill/stroke opacity
this.getBlur = function(elem)
Gets the stdDeviation blur value of the given element
canvas.setBlurNoUndo = function(val)
Sets the stdDeviation blur value on the selected element without being undoable
canvas.setBlurOffsets = function(filter,
stdDev)
Sets the x, y, with, height values of the filter element in order to make the blur not be clipped.
canvas.setBlur = function(val,
complete)
Adds/updates the blur filter to the selected element
this.getBold = function()
Check whether selected element is bold or not
this.setBold = function(b)
Make the selected element bold or normal
this.getItalic = function()
Check whether selected element is italic or not
this.setItalic = function(i)
Make the selected element italic or normal
this.getFontFamily = function()
Returns the current font family
this.setFontFamily = function(val)
Set the new font family
this.getFontSize = function()
Returns the current font size
this.setFontSize = function(val)
Applies the given font size to the selected element
this.getText = function()
Returns the current text (textContent) of the selected element
this.setTextContent = function(val)
Updates the text element with the given string
this.setImageURL = function(val)
Sets the new image URL for the selected image element.
this.setRectRadius = function(val)
Sets the rx & ry values to the selected rect element to change its corner radius
this.setSegType = function(new_type)
Sets the new segment type to the selected segment(s).
this.changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
this.groupSelectedElements = function()
Wraps all the selected elements in a group (g) element
this.ungroupSelectedElement = function()
Unwraps all the elements in a selected group (g) element.
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
this.moveToTopSelectedElement = function()
Repositions the selected element to the bottom in the DOM to appear on top of other elements
this.moveToBottomSelectedElement = function()
Repositions the selected element to the top in the DOM to appear under other elements
this.moveSelectedElements = function(dx,
dy,
undoable)
Moves selected elements on the X/Y axis
this.updateCanvas = function(w,
h)
Updates the editor canvas width/height/position after a zoom has occurred
this.getVersion = function()
Returns a string which describes the revision number of SvgCanvas.
+
"rectsIntersect": function(r1,
r2)
Check if two rectangles (BBoxes objects) intersect each other
"snapToAngle": function(x1,
y1,
x2,
y2)
Returns a 45 degree angle coordinate associated with the two given coordinates
"text2xml": function(sXML)
Cross-browser compatible method of converting a string to an XML tree found this function here: http://groups.google.com/group/jquery-dev/browse_thread/thread/c6d11387c580a77f
convertToNum = function(attr,
val)
Converts given values to numbers.
setUnitAttr = function(elem,
attr,
val)
Sets an element’s attribute based on the unit in its current value.
canvas.isValidUnit = function(attr,
val)
Check if an attribute’s value is in a valid format
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
var InsertElementCommand = this.undoCmd.insertElement = function(elem,
text)
History command for an element that was added to the DOM
var RemoveElementCommand = this.undoCmd.removeElement = function(elem,
parent,
text)
History command for an element removed from the DOM
var MoveElementCommand = this.undoCmd.moveElement = function(elem,
oldNextSibling,
oldParent,
text)
History command for an element that had its DOM position changed
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
resetUndoStack = function()
Resets the undo stack, effectively clearing the undo/redo history
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
function walkTree(elem,
cbFn)
Walks the tree and executes the callback on each element in a top-down fashion
function walkTreePost(elem,
cbFn)
Walks the tree and executes the callback on each element in a depth-first fashion
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
this.addExtension = function(name,
ext_func)
Add an extension to the editor
var shortFloat = function(val)
Rounds a given value to a float with number of digits defined in save_options
var getStrokedBBox = this.getStrokedBBox = function(elems)
Get the bounding box for one or more stroked and/or transformed elements
var getVisibleElements = this.getVisibleElements = function(parent,
includeBBox)
Get all elements that have a BBox (excludes defs, title, etc).
var copyElem = function(el)
Create a clone of an element, updating its ID and its children’s IDs when needed
function getElem(id)
Get a DOM element by ID within the SVG root element.
getId = c.getId = function()
Returns the last created DOM element ID string
getNextId = c.getNextId = function()
Creates and returns a unique ID string for a DOM element
c.bind = function(event,
f)
Attaches a callback function to an event
c.setIdPrefix = function(p)
Changes the ID prefix to the given value
var sanitizeSvg = this.sanitizeSvg = function(node)
Sanitizes the input node and its children It only keeps what is allowed from our whitelist defined above
var getUrlFromAttr = this.getUrlFromAttr = function(attrVal)
Extracts the URL from the url(...)
var getBBox = this.getBBox = function(elem)
Get the given/selected element’s bounding box object, convert it to be more usable when necessary
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var getPathBBox = function(path)
Get correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
var getRotationAngle = this.getRotationAngle = function(elem,
to_rad)
Get the rotation angle of the given/selected DOM element
this.setRotationAngle = function(val,
preventUndo)
Removes any old rotations if present, prepends a new rotation at the transformed center
var getTransformList = this.getTransformList = function(elem)
Returns an object that behaves like a SVGTransformList for the given DOM element
var recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions = function()
Runs recalculateDimensions on the selected elements, adding the changes to a single batch command
var remapElement = this.remapElement = function(selected,
changes,
m)
Applies coordinate changes to an element based on the given matrix
var recalculateDimensions = this.recalculateDimensions = function(selected)
Decides the course of action based on the element’s transform list
var transformPoint = function(x,
y,
m)
A (hopefully) quicker function to transform a point by a matrix (this function avoids any DOM calls and just does the math)
var isIdentity = function(m)
Helper function to check if the matrix performs no actual transform (i.e.
var matrixMultiply = this.matrixMultiply = function()
This function tries to return a SVGMatrix that is the multiplication m1*m2.
var transformListToTransform = this.transformListToTransform = function(tlist,
min,
max)
This returns a single matrix Transform for a given Transform List (this is the equivalent of SVGTransformList.consolidate() but unlike that method, this one does not modify the actual SVGTransformList) This function is very liberal with its min,max arguments
var hasMatrixTransform = this.hasMatrixTransform = function(tlist)
See if the given transformlist includes a non-indentity matrix transform
var getMatrix = function(elem)
Get the matrix object for a given element
var transformBox = this.transformBox = function(l,
t,
w,
h,
m)
Transforms a rectangle based on the given matrix
var clearSelection = this.clearSelection = function(noCall)
Clears the selection.
var addToSelection = this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
var removeFromSelection = this.removeFromSelection = function(elemsToRemove)
Removes elements from the selection.
this.selectAllInCurrentLayer = function()
Clears the selection, then adds all elements in the current layer to the selection.
var smoothControlPoints = this.smoothControlPoints = function(ct1,
ct2,
pt)
Takes three points and creates a smoother line based on them
var getMouseTarget = this.getMouseTarget = function(evt)
Gets the desired element from a mouse event
var preventClickDefault = function(img)
Prevents default browser click behaviour on the given element
var removeUnusedDefElems = this.removeUnusedDefElems = function()
Looks at DOM elements inside the defs to see if they are referred to, removes them from the DOM if they are not.
var svgCanvasToString = this.svgCanvasToString = function()
Main function to set up the SVG content for output
var svgToString = this.svgToString = function(elem,
indent)
Sub function ran on each SVG element to convert it to a string as desired
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
this.save = function(opts)
Serializes the current drawing into SVG XML text and returns it to the ‘saved’ handler.
this.rasterExport = function()
Generates a PNG Data URL based on the current image, then calls “exported” with an object including the string and any issues found
this.getSvgString = function()
Returns the current drawing as raw SVG XML text.
this.setSvgString = function(xmlString)
This function sets the current drawing as the input SVG XML.
this.importSvgString = function(xmlString)
This function imports the input SVG XML into the current layer in the drawing
var identifyLayers = function()
Updates layer system
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.getNumLayers = function()
Returns the number of layers in the current drawing.
this.getLayer = function(i)
Returns the name of the ith layer.
this.getCurrentLayer = function()
Returns the name of the currently selected layer.
this.setCurrentLayer = function(name)
Sets the current layer.
this.renameCurrentLayer = function(newname)
Renames the current layer.
this.setCurrentLayerPosition = function(newpos)
Changes the position of the current layer to the new value.
this.getLayerVisibility = function(layername)
Returns whether the layer is visible.
this.setLayerVisibility = function(layername,
bVisible)
Sets the visibility of the layer.
this.moveSelectedToLayer = function(layername)
Moves the selected elements to layername.
this.getLayerOpacity = function(layername)
Returns the opacity of the given layer.
this.setLayerOpacity = function(layername,
opacity)
Sets the opacity of the given layer.
this.clear = function()
Clears the current document.
this.getContentElem = function()
Returns the content DOM element
this.getRootElem = function()
Returns the root DOM element
this.getSelectedElems = function()
Returns the array with selected DOM elements
var getResolution = this.getResolution = function()
Returns the current dimensions and zoom level in an object
this.getZoom = function()
Returns the current zoom level
this.getVersion = function()
Returns a string which describes the revision number of SvgCanvas.
this.setUiStrings = function(strs)
Update interface strings with given values
this.setConfig = function(opts)
Update configuration options with given values
this.getDocumentTitle = function()
Returns the current document title or an empty string if not found
this.setDocumentTitle = function(newtitle)
Adds/updates a title element for the document with the given name.
this.getEditorNS = function(add)
Returns the editor’s namespace URL, optionally adds it to root element
this.setResolution = function(x,
y)
Changes the document’s dimensions to the given size
this.getOffset = function()
Returns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
this.setBBoxZoom = function(val,
editor_w,
editor_h)
Sets the zoom level on the canvas-side based on the given value
this.setZoom = function(zoomlevel)
Sets the zoom to the given level
this.getMode = function()
Returns the current editor mode string
this.setMode = function(name)
Sets the editor’s mode to the given string
this.getColor = function(type)
Returns the current fill/stroke option
this.setColor = function(type,
val,
preventUndo)
Change the current stroke/fill color/gradient value
var findDefs = function()
Return the document’s defs element, create it first if necessary
var setGradient = this.setGradient = function(type)
Apply the current gradient to selected element’s fill or stroke
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
this.setPaint = function(type,
paint)
Set a color/gradient to a fill/stroke
this.getStrokeWidth = function()
Returns the current stroke-width value
this.setStrokeWidth = function(val)
Sets the stroke width for the current selected elements When attempting to set a line’s width to 0, this changes it to 1 instead
this.setStrokeAttr = function(attr,
val)
Set the given stroke-related attribute the given value for selected elements
this.getOpacity = function()
Returns the current opacity
this.setOpacity = function(val)
Sets the given opacity to the current selected elements
this.getStrokeOpacity = function()
Returns the current stroke opacity
this.setPaintOpacity = function(type,
val,
preventUndo)
Sets the current fill/stroke opacity
this.getBlur = function(elem)
Gets the stdDeviation blur value of the given element
canvas.setBlurNoUndo = function(val)
Sets the stdDeviation blur value on the selected element without being undoable
canvas.setBlurOffsets = function(filter,
stdDev)
Sets the x, y, with, height values of the filter element in order to make the blur not be clipped.
canvas.setBlur = function(val,
complete)
Adds/updates the blur filter to the selected element
this.getBold = function()
Check whether selected element is bold or not
this.setBold = function(b)
Make the selected element bold or normal
this.getItalic = function()
Check whether selected element is italic or not
this.setItalic = function(i)
Make the selected element italic or normal
this.getFontFamily = function()
Returns the current font family
this.setFontFamily = function(val)
Set the new font family
this.getFontSize = function()
Returns the current font size
this.setFontSize = function(val)
Applies the given font size to the selected element
this.getText = function()
Returns the current text (textContent) of the selected element
this.setTextContent = function(val)
Updates the text element with the given string
this.setImageURL = function(val)
Sets the new image URL for the selected image element.
this.setRectRadius = function(val)
Sets the rx & ry values to the selected rect element to change its corner radius
this.setSegType = function(new_type)
Sets the new segment type to the selected segment(s).
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
var changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
var changeSelectedAttribute = this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
this.groupSelectedElements = function()
Wraps all the selected elements in a group (g) element
this.ungroupSelectedElement = function()
Unwraps all the elements in a selected group (g) element.
this.moveToTopSelectedElement = function()
Repositions the selected element to the bottom in the DOM to appear on top of other elements
this.moveToBottomSelectedElement = function()
Repositions the selected element to the top in the DOM to appear under other elements
this.moveSelectedElements = function(dx,
dy,
undoable)
Moves selected elements on the X/Y axis
this.cloneSelectedElements = function()
Create deep DOM copies (clones) of all selected elements and move them slightly from their originals
this.alignSelectedElements = function(type,
relative_to)
Aligns selected elements
this.updateCanvas = function(w,
h)
Updates the editor canvas width/height/position after a zoom has occurred
this.setBackground = function(color,
url)
Set the background of the editor (NOT the actual document)
this.cycleElement = function(next)
Select the next/previous element within the current layer
diff --git a/docs/index/Functions.html b/docs/index/Functions.html index 5797a517..9c282c28 100644 --- a/docs/index/Functions.html +++ b/docs/index/Functions.html @@ -11,37 +11,29 @@ if (browserType) {document.write("
");if (browserV -
Function Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
A
 addCommandToHistory, SvgCanvas
 addSubCommand, SvgCanvas.BatchCommand
 addSvgElementFromJson, SelectorManager
 addToSelection, SelectorManager
 apply
 assignAttributes, SelectorManager
B
 BatchCommand, SvgCanvas
 beginUndoableChange, SvgCanvas
 bind, SelectorManager
C
 ChangeElementCommand, SvgCanvas
 changeSelectedAttribute, SelectorManager
 changeSelectedAttributeNoUndo, SelectorManager
 cleanupElement, SelectorManager
 clear, SelectorManager
 clearSelection, SelectorManager
 convertToNum, SvgCanvas
 convertToPath, SelectorManager
 createLayer, SelectorManager
D
 deleteCurrentLayer, SelectorManager
 deleteSelectedElements, SelectorManager
E
 elements
 embedImage, SelectorManager
F
 ffClone, SelectorManager
 findDefs, SelectorManager
 findDuplicateGradient, SelectorManager
 finishUndoableChange, SvgCanvas
 fromXml, SvgCanvas
G
 getBBox, SelectorManager
 getBlur, SelectorManager
 getBold, SelectorManager
 getColor, SelectorManager
 getContentElem, SelectorManager
 getCurrentLayer, SelectorManager
 getDocumentTitle, SelectorManager
 getEditorNS, SelectorManager
 getFontFamily, SelectorManager
 getFontSize, SelectorManager
 getId, SelectorManager
 getItalic, SelectorManager
 getLayer, SelectorManager
 getLayerOpacity, SelectorManager
 getLayerVisibility, SelectorManager
 getMatrix, SelectorManager
 getMode, SelectorManager
 getMouseTarget, SelectorManager
 getNextId, SelectorManager
 getNextRedoCommandText, SvgCanvas.undoMgr
 getNextUndoCommandText, SvgCanvas.undoMgr
 getNumLayers, SelectorManager
 getOffset, SelectorManager
 getOpacity, SelectorManager
 getPathBBox, SelectorManager
 getRedoStackSize, SvgCanvas.undoMgr
 getResolution, SelectorManager
 getRootElem, SelectorManager
 getRotationAngle, SelectorManager
 getRubberBandBox, SelectorManager.SelectorManager
 getSelectedElems, SelectorManager
 getStrokeOpacity, SelectorManager
 getStrokeWidth, SelectorManager
 getSvgString, SelectorManager
 getText, SelectorManager
 getTransformList, SelectorManager
 getUndoStackSize, SvgCanvas.undoMgr
 getUrlFromAttr, SelectorManager
 getVersion, SelectorManager
 groupSelectedElements, SelectorManager
H
 hasMatrixTransform, SelectorManager
+
Function Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
A
 addCommandToHistory, SvgCanvas
 addExtension, SelectorManager
 addSubCommand, SvgCanvas.BatchCommand
 addSvgElementFromJson, SelectorManager
 addToSelection, SelectorManager
 alignSelectedElements, SelectorManager
 apply
 assignAttributes, SelectorManager
B
 BatchCommand, SvgCanvas
 beginUndoableChange, SvgCanvas
 bind, SelectorManager
C
 ChangeElementCommand, SvgCanvas
 changeSelectedAttribute, SelectorManager
 changeSelectedAttributeNoUndo, SelectorManager
 cleanupElement, SelectorManager
 clear, SelectorManager
 clearSelection, SelectorManager
 cloneSelectedElements, SelectorManager
 convertToNum, SvgCanvas
 convertToPath, SelectorManager
 convertToXMLReferences, SvgCanvas.Utils
 copyElem, SelectorManager
 createLayer, SelectorManager
 cycleElement, SelectorManager
D
 decode64, SvgCanvas.Utils
 deleteCurrentLayer, SelectorManager
 deleteSelectedElements, SelectorManager
E
 elements
 embedImage, SelectorManager
 encode64, SvgCanvas.Utils
F
 ffClone, SelectorManager
 findDefs, SelectorManager
 findDuplicateGradient, SelectorManager
 finishUndoableChange, SvgCanvas
 fromXml, SvgCanvas.Utils
-
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
Adds a given command to the history stack
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
Runs “apply” on all subcommands
Performs the stored change action
Re-Inserts the new element
Re-removes the new element
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
+
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
this.addExtension = function(name,
ext_func)
Add an extension to the editor
Adds a given command to the history stack
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
var addToSelection = this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
this.alignSelectedElements = function(type,
relative_to)
Aligns selected elements
Runs “apply” on all subcommands
Performs the stored change action
Re-Inserts the new element
Re-removes the new element
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
-
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.bind = function(event,
f)
Attaches a callback function to an event
+
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.bind = function(event,
f)
Attaches a callback function to an event
-
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
this.changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
this.clear = function()
Clears the current document.
this.clearSelection = function(noCall)
Clears the selection.
convertToNum = function(attr,
val)
Converts given values to numbers.
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
+
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
var changeSelectedAttribute = this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
var changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
this.clear = function()
Clears the current document.
var clearSelection = this.clearSelection = function(noCall)
Clears the selection.
this.cloneSelectedElements = function()
Create deep DOM copies (clones) of all selected elements and move them slightly from their originals
convertToNum = function(attr,
val)
Converts given values to numbers.
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
Converts a string to use XML references
var copyElem = function(el)
Create a clone of an element, updating its ID and its children’s IDs when needed
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
this.cycleElement = function(next)
Select the next/previous element within the current layer
-
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
+
Converts a string from base64
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
-
Iterate through all our subcommands and returns all the elements we are changing
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
+
Iterate through all our subcommands and returns all the elements we are changing
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
Converts a string to base64
-
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var findDefs = function()
Return the document’s defs element, create it first if necessary
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
fromXml = function(str)
Converts XML entities in a string to single characters.
- - - -
this.getBBox = function(elem)
Get the given/selected element’s bounding box object, convert it to be more usable when necessary
this.getBlur = function(elem)
Gets the stdDeviation blur value of the given element
this.getBold = function()
Check whether selected element is bold or not
this.getColor = function(type)
Returns the current fill/stroke option
this.getContentElem = function()
Returns the content DOM element
this.getCurrentLayer = function()
Returns the name of the currently selected layer.
this.getDocumentTitle = function()
Returns the current document title or an empty string if not found
this.getEditorNS = function(add)
Returns the editor’s namespace URL, optionally adds it to root element
this.getFontFamily = function()
Returns the current font family
this.getFontSize = function()
Returns the current font size
getId = c.getId = function()
Returns the last created DOM element ID string
this.getItalic = function()
Check whether selected element is italic or not
this.getLayer = function(i)
Returns the name of the ith layer.
this.getLayerOpacity = function(layername)
Returns the opacity of the given layer.
this.getLayerVisibility = function(layername)
Returns whether the layer is visible.
var getMatrix = function(elem)
Get the matrix object for a given element
this.getMode = function()
Returns the current editor mode string
var getMouseTarget = this.getMouseTarget = function(evt)
Gets the desired element from a mouse event
getNextId = c.getNextId = function()
Creates and returns a unique ID string for a DOM element
String associated with the next redo command
String associated with the next undo command
this.getNumLayers = function()
Returns the number of layers in the current drawing.
this.getOffset = function()
Returns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
this.getOpacity = function()
Returns the current opacity
var getPathBBox = function(path)
Get correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Integer with the current size of the redo history stack
this.getResolution = function()
Returns the current dimensions and zoom level in an object
this.getRootElem = function()
Returns the root DOM element
this.getRotationAngle = function(elem,
to_rad)
Get the rotation angle of the given/selected DOM element
Returns the rubberBandBox DOM element.
this.getSelectedElems = function()
Returns the array with selected DOM elements
this.getStrokeOpacity = function()
Returns the current stroke opacity
this.getStrokeWidth = function()
Returns the current stroke-width value
this.getSvgString = function()
Returns the current drawing as raw SVG XML text.
this.getText = function()
Returns the current text (textContent) of the selected element
this.getTransformList = function(elem)
Returns an object that behaves like a SVGTransformList for the given DOM element
Integer with the current size of the undo history stack
var getUrlFromAttr = this.getUrlFromAttr = function(attrVal)
Extracts the URL from the url(...)
this.getVersion = function()
Returns a string which describes the revision number of SvgCanvas.
this.groupSelectedElements = function()
Wraps all the selected elements in a group (g) element
- - - -
var hasMatrixTransform = this.hasMatrixTransform = function(tlist)
See if the given transformlist includes a non-indentity matrix transform
+
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var findDefs = function()
Return the document’s defs element, create it first if necessary
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
Converts XML entities in a string to single characters.
diff --git a/docs/index/General.html b/docs/index/General.html index bcd43ed5..69d5a0b5 100644 --- a/docs/index/General.html +++ b/docs/index/General.html @@ -11,37 +11,29 @@ if (browserType) {document.write("
");if (browserV -
Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
A
 addCommandToHistory, SvgCanvas
 addSubCommand, SvgCanvas.BatchCommand
 addSvgElementFromJson, SelectorManager
 addToSelection, SelectorManager
 apply
 assignAttributes, SelectorManager
B
 BatchCommand, SvgCanvas
 beginUndoableChange, SvgCanvas
 bind, SelectorManager
C
 ChangeElementCommand, SvgCanvas
 changeSelectedAttribute, SelectorManager
 changeSelectedAttributeNoUndo, SelectorManager
 cleanupElement, SelectorManager
 clear, SelectorManager
 clearSelection, SelectorManager
 convertToNum, SvgCanvas
 convertToPath, SelectorManager
 createLayer, SelectorManager
D
 deleteCurrentLayer, SelectorManager
 deleteSelectedElements, SelectorManager
 Document functions, SelectorManager
E
 Element Styling, SelectorManager
 Element Transforms, SelectorManager
 elements
 embedImage, SelectorManager
F
 ffClone, SelectorManager
 findDefs, SelectorManager
 findDuplicateGradient, SelectorManager
 finishUndoableChange, SvgCanvas
 fromXml, SvgCanvas
 Functions, Selector
G
 getBBox, SelectorManager
 getBlur, SelectorManager
 getBold, SelectorManager
 getColor, SelectorManager
 getContentElem, SelectorManager
 getCurrentLayer, SelectorManager
 getDocumentTitle, SelectorManager
 getEditorNS, SelectorManager
 getFontFamily, SelectorManager
 getFontSize, SelectorManager
 getId, SelectorManager
 getItalic, SelectorManager
 getLayer, SelectorManager
 getLayerOpacity, SelectorManager
 getLayerVisibility, SelectorManager
 getMatrix, SelectorManager
 getMode, SelectorManager
 getMouseTarget, SelectorManager
 getNextId, SelectorManager
 getNextRedoCommandText, SvgCanvas.undoMgr
 getNextUndoCommandText, SvgCanvas.undoMgr
 getNumLayers, SelectorManager
 getOffset, SelectorManager
 getOpacity, SelectorManager
 getPathBBox, SelectorManager
 getRedoStackSize, SvgCanvas.undoMgr
 getResolution, SelectorManager
 getRootElem, SelectorManager
 getRotationAngle, SelectorManager
 getRubberBandBox, SelectorManager.SelectorManager
 getSelectedElems, SelectorManager
 getStrokeOpacity, SelectorManager
 getStrokeWidth, SelectorManager
 getSvgString, SelectorManager
 getText, SelectorManager
 getTransformList, SelectorManager
 getUndoStackSize, SvgCanvas.undoMgr
 getUrlFromAttr, SelectorManager
 getVersion, SelectorManager
 groupSelectedElements, SelectorManager
H
 hasMatrixTransform, SelectorManager
 Helper functions, SelectorManager
+
Index
$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
A
 addCommandToHistory, SvgCanvas
 addExtension, SelectorManager
 Additional editor tools, SelectorManager
 addSubCommand, SvgCanvas.BatchCommand
 addSvgElementFromJson, SelectorManager
 addToSelection, SelectorManager
 alignSelectedElements, SelectorManager
 apply
 assignAttributes, SelectorManager
B
 BatchCommand, SvgCanvas
 beginUndoableChange, SvgCanvas
 bind, SelectorManager
C
 ChangeElementCommand, SvgCanvas
 changeSelectedAttribute, SelectorManager
 changeSelectedAttributeNoUndo, SelectorManager
 cleanupElement, SelectorManager
 clear, SelectorManager
 clearSelection, SelectorManager
 cloneSelectedElements, SelectorManager
 convertToNum, SvgCanvas
 convertToPath, SelectorManager
 convertToXMLReferences, SvgCanvas.Utils
 copyElem, SelectorManager
 createLayer, SelectorManager
 cycleElement, SelectorManager
D
 decode64, SvgCanvas.Utils
 deleteCurrentLayer, SelectorManager
 deleteSelectedElements, SelectorManager
 Document functions, SelectorManager
E
 Element manipulation, SelectorManager
 Element Styling, SelectorManager
 Element Transforms, SelectorManager
 elements
 embedImage, SelectorManager
 encode64, SvgCanvas.Utils
F
 ffClone, SelectorManager
 findDefs, SelectorManager
 findDuplicateGradient, SelectorManager
 finishUndoableChange, SvgCanvas
 fromXml, SvgCanvas.Utils
 Functions, Selector
-
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
Adds a given command to the history stack
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
Runs “apply” on all subcommands
Performs the stored change action
Re-Inserts the new element
Re-removes the new element
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
+
addCommandToHistory = c.undoCmd.add = function(cmd)
Adds a command object to the undo history stack
this.addExtension = function(name,
ext_func)
Add an extension to the editor
Adds a given command to the history stack
var addSvgElementFromJson = this.addSvgElementFromJson = function(data)
Create a new SVG element based on the given object keys/values and add it to the current layer The element will be ran through cleanupElement before being returned
var addToSelection = this.addToSelection = function(elemsToAdd,
showGrips)
Adds a list of elements to the selection.
this.alignSelectedElements = function(type,
relative_to)
Aligns selected elements
Runs “apply” on all subcommands
Performs the stored change action
Re-Inserts the new element
Re-removes the new element
var assignAttributes = this.assignAttributes = function(node,
attrs,
suspendLength,
unitCheck)
Assigns multiple attributes to an element.
-
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.bind = function(event,
f)
Attaches a callback function to an event
+
var BatchCommand = this.undoCmd.batch = function(text)
History command that can contain/execute multiple other commands
c.beginUndoableChange = function(attrName,
elems)
This function tells the canvas to remember the old values of the attrName attribute for each element sent in.
c.bind = function(event,
f)
Attaches a callback function to an event
-
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
this.changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
this.clear = function()
Clears the current document.
this.clearSelection = function(noCall)
Clears the selection.
convertToNum = function(attr,
val)
Converts given values to numbers.
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
+
var ChangeElementCommand = this.undoCmd.changeElement = function(elem,
attrs,
text)
History command to make a change to an element.
var changeSelectedAttribute = this.changeSelectedAttribute = function(attr,
val,
elems)
Change the given/selected element and add the original value to the history stack If you want to change all selectedElements, ignore the elems argument.
var changeSelectedAttributeNoUndo = function(attr,
newValue,
elems)
This function makes the changes to the elements.
var cleanupElement = this.cleanupElement = function(element)
Remove unneeded (default) attributes, makes resulting SVG smaller
this.clear = function()
Clears the current document.
var clearSelection = this.clearSelection = function(noCall)
Clears the selection.
this.cloneSelectedElements = function()
Create deep DOM copies (clones) of all selected elements and move them slightly from their originals
convertToNum = function(attr,
val)
Converts given values to numbers.
this.convertToPath = function(elem,
getBBox)
Convert selected element to a path, or get the BBox of an element-as-path
Converts a string to use XML references
var copyElem = function(el)
Create a clone of an element, updating its ID and its children’s IDs when needed
this.createLayer = function(name)
Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler.
this.cycleElement = function(next)
Select the next/previous element within the current layer
-
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
+
Converts a string from base64
this.deleteCurrentLayer = function()
Deletes the current layer from the drawing and then clears the selection.
this.deleteSelectedElements = function()
Removes all selected elements from the DOM and adds the change to the history stack
-
Iterate through all our subcommands and returns all the elements we are changing
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
+
Iterate through all our subcommands and returns all the elements we are changing
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
Returns array with element associated with this command
this.embedImage = function(val,
callback)
Converts a given image file to a data URL when possible, then runs a given callback
Converts a string to base64
-
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var findDefs = function()
Return the document’s defs element, create it first if necessary
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
fromXml = function(str)
Converts XML entities in a string to single characters.
- - - -
this.getBBox = function(elem)
Get the given/selected element’s bounding box object, convert it to be more usable when necessary
this.getBlur = function(elem)
Gets the stdDeviation blur value of the given element
this.getBold = function()
Check whether selected element is bold or not
this.getColor = function(type)
Returns the current fill/stroke option
this.getContentElem = function()
Returns the content DOM element
this.getCurrentLayer = function()
Returns the name of the currently selected layer.
this.getDocumentTitle = function()
Returns the current document title or an empty string if not found
this.getEditorNS = function(add)
Returns the editor’s namespace URL, optionally adds it to root element
this.getFontFamily = function()
Returns the current font family
this.getFontSize = function()
Returns the current font size
getId = c.getId = function()
Returns the last created DOM element ID string
this.getItalic = function()
Check whether selected element is italic or not
this.getLayer = function(i)
Returns the name of the ith layer.
this.getLayerOpacity = function(layername)
Returns the opacity of the given layer.
this.getLayerVisibility = function(layername)
Returns whether the layer is visible.
var getMatrix = function(elem)
Get the matrix object for a given element
this.getMode = function()
Returns the current editor mode string
var getMouseTarget = this.getMouseTarget = function(evt)
Gets the desired element from a mouse event
getNextId = c.getNextId = function()
Creates and returns a unique ID string for a DOM element
String associated with the next redo command
String associated with the next undo command
this.getNumLayers = function()
Returns the number of layers in the current drawing.
this.getOffset = function()
Returns an object with x, y values indicating the svgcontent element’s position in the editor’s canvas.
this.getOpacity = function()
Returns the current opacity
var getPathBBox = function(path)
Get correct BBox for a path in Webkit Converted from code found here: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
Integer with the current size of the redo history stack
this.getResolution = function()
Returns the current dimensions and zoom level in an object
this.getRootElem = function()
Returns the root DOM element
this.getRotationAngle = function(elem,
to_rad)
Get the rotation angle of the given/selected DOM element
Returns the rubberBandBox DOM element.
this.getSelectedElems = function()
Returns the array with selected DOM elements
this.getStrokeOpacity = function()
Returns the current stroke opacity
this.getStrokeWidth = function()
Returns the current stroke-width value
this.getSvgString = function()
Returns the current drawing as raw SVG XML text.
this.getText = function()
Returns the current text (textContent) of the selected element
this.getTransformList = function(elem)
Returns an object that behaves like a SVGTransformList for the given DOM element
Integer with the current size of the undo history stack
var getUrlFromAttr = this.getUrlFromAttr = function(attrVal)
Extracts the URL from the url(...)
this.getVersion = function()
Returns a string which describes the revision number of SvgCanvas.
this.groupSelectedElements = function()
Wraps all the selected elements in a group (g) element
- - - -
var hasMatrixTransform = this.hasMatrixTransform = function(tlist)
See if the given transformlist includes a non-indentity matrix transform
+
var ffClone = function(elem)
Hack for Firefox bugs where text element features aren’t updated.
var findDefs = function()
Return the document’s defs element, create it first if necessary
var findDuplicateGradient = function(grad)
Check if exact gradient already exists
c.finishUndoableChange = function()
This function returns a BatchCommand object which summarizes the change since beginUndoableChange was called.
Converts XML entities in a string to single characters.
diff --git a/docs/javascript/searchdata.js b/docs/javascript/searchdata.js index a895d592..eac176a3 100644 --- a/docs/javascript/searchdata.js +++ b/docs/javascript/searchdata.js @@ -47,7 +47,7 @@ var indexSectionsWithContent = { "M": true, "N": false, "O": false, - "P": false, + "P": true, "Q": false, "R": true, "S": true, diff --git a/docs/search/FunctionsA.html b/docs/search/FunctionsA.html index 69d7343f..de24e1f5 100644 --- a/docs/search/FunctionsA.html +++ b/docs/search/FunctionsA.html @@ -11,7 +11,7 @@ if (browserType) {document.write("
");if (browserV -
Loading...
addSubCommand, SvgCanvas.BatchCommand
addSvgElementFromJson, SelectorManager
addToSelection, SelectorManager
assignAttributes, SelectorManager
Searching...
No Matches