GeezerVison is showing maxgraph.github.io — AbstractCanvas2D | @maxgraph/core
Class AbstractCanvas2DAbstract
Base class for all canvases.
The following methods make up the public interface of the canvas 2D for all painting in mxGraph:
- save, restore
- scale, translate, rotate
- setAlpha, setFillAlpha, setStrokeAlpha, setFillColor, setGradient,
setStrokeColor, setStrokeWidth, setDashed, setDashPattern, setLineCap,
setLineJoin, setMiterLimit
- setFontColor, setFontBackgroundColor, setFontBorderColor, setFontSize,
setFontFamily, setFontStyle
- setShadow, setShadowColor, setShadowAlpha, setShadowOffset
- rect, roundrect, ellipse, image, text
- begin, moveTo, lineTo, quadTo, curveTo
- stroke, fill, fillAndStroke
arcTo is an additional method for drawing paths.
This is a synthetic method, meaning that it is turned into a sequence of curves by default.
Subclasses may add native support for arcs.
All color values of NONE will be converted to null in the state.
Constructors
Protectedconstructor
-
new AbstractCanvas2D(): AbstractCanvas2D
Properties
closeOp
closeOp: string = 'Z'
Holds the operator for closing curves. Default is 'Z'.
converter
Holds the to convert image URLs.
curveOp
curveOp: string = 'C'
Contains the string used for bezier curves. Default is 'C'.
lastX
lastX: number = 0
Holds the last x coordinate.
lastY
lastY: number = 0
Holds the last y coordinate.
lineOp
lineOp: string = 'L'
Contains the string used for moving in paths. Default is 'L'.
moveOp
moveOp: string = 'M'
Contains the string used for moving in paths. Default is 'M'.
path
path: (string | number)[] = []
Holds the current path as an array.
pointerEvents
pointerEvents: boolean = false
Boolean value that specifies if events should be handled. Default is false.
pointerEventsValue
pointerEventsValue: string | null = null
quadOp
quadOp: string = 'Q'
Contains the string used for quadratic paths. Default is 'Q'.
rotateHtml
rotateHtml: boolean = true
Switch for rotation of HTML. Default is false.
Methods
addOp
-
addOp(op: string, ...args: number[]): void
Adds the given operation to the path.
Parameters
- op: string
- ...args: number[]
Returns void
arcTo
-
arcTo( rx: number, ry: number, angle: number, largeArcFlag: boolean, sweepFlag: boolean, x: number, y: number,): void
Adds the given arc to the current path. This is a synthetic operation that
is broken down into curves.
Parameters
- rx: number
- ry: number
- angle: number
- largeArcFlag: boolean
- sweepFlag: boolean
- x: number
- y: number
Returns void
close
-
close( x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number,): void
Parameters
Optionalx1: number
Optionaly1: number
Optionalx2: number
Optionaly2: number
Optionalx3: number
Optionaly3: number
Returns void
createState
-
Creates the state of the this canvas.
createUrlConverter
-
Create a new and returns it.
curveTo
-
curveTo( x1: number, y1: number, x2: number, y2: number, x3: number, y3: number,): void
Adds a bezier curve to the current path.
Parameters
- x1: number
- y1: number
- x2: number
- y2: number
- x3: number
- y3: number
Returns void
Abstractellipse
-
ellipse(x: number, y: number, w: number, h: number): void
Parameters
- x: number
- y: number
- w: number
- h: number
Returns void
Abstractend
-
Empty implementation for backwards compatibility. This will be removed.
Returns void
format
-
format(value: number): number
Rounds all numbers to integers.
Returns number
Abstractimage
-
image( x: number, y: number, w: number, h: number, src: string, aspect: boolean, flipH: boolean, flipV: boolean,): void
Parameters
- x: number
- y: number
- w: number
- h: number
- src: string
- aspect: boolean
- flipH: boolean
- flipV: boolean
Returns void
lineTo
-
lineTo(x: number, y: number): void
Draws a line to the given coordinates. Uses moveTo with the op argument.
Returns void
moveTo
-
moveTo(x: number, y: number): void
Moves the current path the given coordinates.
Returns void
quadTo
-
quadTo(x1: number, y1: number, x2: number, y2: number): void
Adds a quadratic curve to the current path.
Parameters
- x1: number
- y1: number
- x2: number
- y2: number
Returns void
Abstractrect
-
rect(x: number, y: number, w: number, h: number): void
Parameters
- x: number
- y: number
- w: number
- h: number
Returns void
reset
-
Resets the state of this canvas.
Returns void
restore
-
Restores the current state.
Returns void
rotate
-
rotate( theta: number, flipH: boolean, flipV: boolean, cx: number, cy: number,): void
Rotates the current state.
Parameters
- theta: number
- flipH: boolean
- flipV: boolean
- cx: number
- cy: number
Returns void
rotatePoint
-
rotatePoint(x: number, y: number, theta: number, cx: number, cy: number): Point
Rotates the given point and returns the result as an Point.
Parameters
- x: number
- y: number
- theta: number
- cx: number
- cy: number
Abstractroundrect
-
roundrect( x: number, y: number, w: number, h: number, r1: number, r2: number,): void
Parameters
- x: number
- y: number
- w: number
- h: number
- r1: number
- r2: number
Returns void
scale
-
scale(value: number): void
Scales the current state.
Returns void
setAlpha
-
setAlpha(value: number): void
setDashed
-
setDashed(value: boolean, fixDash?: boolean): void
Enables or disables dashed lines.
Parameters
- value: boolean
- fixDash: boolean = false
Returns void
setDashPattern
-
setDashPattern(value: string): void
Sets the current dash pattern.
Returns void
setFillAlpha
-
setFillAlpha(value: number): void
Sets the current solid fill alpha.
Returns void
setFillColor
-
setFillColor(value: string | null): void
Sets the current fill color.
Returns void
setFontBackgroundColor
-
setFontBackgroundColor(value: string | null): void
Sets the current font background color.
Returns void
setFontBorderColor
-
setFontBorderColor(value: string | null): void
Sets the current font border color.
Returns void
setFontColor
-
setFontColor(value: string | null): void
Sets the current font color.
Returns void
setFontFamily
-
setFontFamily(value: string): void
Sets the current font family.
Returns void
setFontSize
-
setFontSize(value: number): void
Sets the current font size.
Returns void
setFontStyle
-
setFontStyle(value: number): void
Sets the current font style.
Returns void
setGradient
-
setGradient( color1: string, color2: string, x: number, y: number, w: number, h: number, direction: DirectionValue, alpha1?: number, alpha2?: number,): void
Sets the current gradient.
Parameters
- color1: string
- color2: string
- x: number
- y: number
- w: number
- h: number
- direction: DirectionValue
- alpha1: number = 1
- alpha2: number = 1
Returns void
setLineCap
-
setLineCap(value: string): void
Sets the current line cap.
Returns void
setLineJoin
-
setLineJoin(value: string): void
Sets the current line join.
Returns void
setLink
-
setLink(link: string | null): void
Sets the current link. Hook for subclassers.
Returns void
setMiterLimit
-
setMiterLimit(value: number): void
Sets the current miter limit.
Returns void
setShadow
-
setShadow(enabled: boolean): void
Enables or disables and configures the current shadow.
Returns void
setShadowAlpha
-
setShadowAlpha(value: number): void
Sets the current shadow alpha.
Parameters
- value: number
Number that represents the new alpha. Possible values are between 1 (opaque) and 0 (transparent).
Returns void
setShadowColor
-
setShadowColor(value: string | null): void
Sets the current shadow color.
Parameters
- value: string | null
Hexadecimal representation of the color or none.
Returns void
setShadowOffset
-
setShadowOffset(dx: number, dy: number): void
Sets the current shadow offset.
Parameters
- dx: number
Number that represents the horizontal offset of the shadow.
- dy: number
Number that represents the vertical offset of the shadow.
Returns void
setStrokeAlpha
-
setStrokeAlpha(value: number): void
Sets the current stroke alpha.
Returns void
setStrokeColor
-
setStrokeColor(value: string | null): void
Sets the current stroke color.
Returns void
setStrokeWidth
-
setStrokeWidth(value: number): void
Sets the current stroke width.
Returns void
Abstracttext
-
text( x: number, y: number, w: number, h: number, str: string, align: AlignValue, valign: VAlignValue, wrap: boolean, format: string, overflow: OverflowValue, clip: boolean, rotation: number, dir: TextDirectionValue,): void
translate
-
translate(dx: number, dy: number): void
Translates the current state.
Returns void
AbstractupdateText
-
updateText( x: number, y: number, w: number, h: number, align: AlignValue, valign: VAlignValue, wrap: boolean, overflow: OverflowValue, clip: boolean, rotation: number, node: SVGElement,): void
On This Page
Constructors
Properties
Methods
|