/** * Draws elements into an SVG node. * * Note that this library uses buffers and draw cycles. To draw onto an SVG canvas, do this: * const drawLib = new drawutilssvg( svgNode, ... ); * const fillLib = drawLib.copyInstance(true); * // Begin draw cycle * drawLib.beginDrawCycle(time); * // ... draw or fill your stuff ... * drawLib.endDrawCycle(time); // Here the elements become visible * * @author Ikaros Kappler * @date 2021-01-03 * @modified 2021-01-24 Fixed the `fillShapes` attribute in the copyInstance function. * @modified 2021-01-26 Changed the `isPrimary` (default true) attribute to `isSecondary` (default false). * @modified 2021-02-03 Added the static `createSvg` function. * @modified 2021-02-03 Fixed the currentId='background' bug on the clear() function. * @modified 2021-02-03 Fixed CSSProperty `stroke-width` (was line-width before, which is wrong). * @modified 2021-02-03 Added the static `HEAD_XML` attribute. * @modified 2021-02-19 Added the static helper function `transformPathData(...)` for svg path transformations (scale and translate). * @modified 2021-02-22 Added the static helper function `copyPathData(...)`. * @modified 2021-02-22 Added the `path` drawing function to draw SVG path data. * @modified 2021-03-01 Fixed a bug in the `clear` function (curClassName was not cleared). * @modified 2021-03-29 Fixed a bug in the `text` function (second y param was wrong, used x here). * @modified 2021-03-29 Moved this file from `src/ts/utils/helpers/` to `src/ts/`. * @modified 2021-03-31 Added 'ellipseSector' the the class names. * @modified 2021-03-31 Implemented buffering using a buffer node and the beginDrawCycle and endDrawCycle methods. * @modified 2021-05-31 Added the `setConfiguration` function from `DrawLib`. * @modified 2021-11-15 Adding more parameters tot the `text()` function: fontSize, textAlign, fontFamily, lineHeight. * @modified 2021-11-19 Fixing the `label(text,x,y)` position. * @modified 2021-11-19 Added the `color` param to the `label(...)` function. * @modified 2022-02-03 Added the `lineWidth` param to the `crosshair` function. * @modified 2022-02-03 Added the `cross(...)` function. * @modified 2022-03-26 Added the private `nodeDefs` and `bufferedNodeDefs` attributes. * @modified 2022-03-26 Added the `texturedPoly` function to draw textures polygons. * @modified 2022-07-26 Adding `alpha` to the `image(...)` function. * @modified 2022-11-10 Tweaking some type issues. * @modified 2023-02-04 Fixed a typo in the CSS classname for cubic Bézier paths: cubicBezier (was cubierBezier). * @modified 2023-02-10 The methods `setCurrentClassName` and `setCurrentId` also accept `null` now. * @modified 2023-09-29 Added initialization checks for null parameters. * @modified 2023-09-29 Added a missing implementation to the `drawurilssvg.do(XYCoords,string)` function. Didn't draw anything. * @modified 2023-09-29 Downgrading all `Vertex` param type to the more generic `XYCoords` type in these render functions: line, arrow, texturedPoly, cubicBezier, cubicBezierPath, handle, handleLine, dot, point, circle, circleArc, ellipse, grid, raster. * @modified 2023-09-29 Added the `headLength` parameter to the 'DrawLib.arrow()` function. * @modified 2023-09-29 Added the `arrowHead(...)` function to the 'DrawLib.arrow()` interface. * @modified 2023-09-29 Added the `cubicBezierArrow(...)` function to the 'DrawLib.arrow()` interface. * @modified 2023-10-04 Adding `strokeOptions` param to these draw function: line, arrow, cubicBezierArrow, cubicBezier, cubicBezierPath, circle, circleArc, ellipse, square, rect, polygon, polyline. * * @version 1.6.7 **/ import { Polygon } from "./Polygon"; import { Vertex } from "./Vertex"; import { DrawConfig, DrawLib, XYCoords, XYDimension, SVGPathParams, UID, DrawLibConfiguration, FontStyle, FontWeight, StrokeOptions } from "./interfaces"; import { Bounds } from "./Bounds"; /** * @classdesc A helper class for basic SVG drawing operations. This class should * be compatible to the default 'draw' class. * * @requires CubicBzierCurvce * @requires Polygon * @requires Vertex * @requires XYCoords */ export declare class drawutilssvg implements DrawLib { static HEAD_XML: string; /** * @member {SVGGElement} * @memberof drawutilssvg * @instance */ svgNode: SVGElement; /** * The root elements container in the svgNode. */ private gNode; /** * To avoid flickering the lib draws on a buffer, which is replacing the old node at the end of the draw cycle. * @member {SVGGelement} * @memberof drawutilssvg * @instance * @private */ private bufferGNode; /** * A style node of type `