Classdesc

A wrapper class for basic drawing operations. This is the WebGL implementation whih sould work with shaders.

Requires

CubicBzierCurvce

Requires

Polygon

Requires

SVGSerializable

Requires

Vertex

Requires

XYCoords

Implements

Constructors

  • The constructor.

    Parameters

    • context: WebGLRenderingContext

      The drawing context.

    • fillShapes: boolean

    Returns drawutilsgl

    Name

    drawutils

Properties

_fragShader: WebGLShader
_program: WebGLProgram
_vertShader: WebGLShader
_zindex: number
curId: string
fillShapes: boolean
gl: WebGLRenderingContext
glutils: GLU
offset: Vertex
renderTime: number
scale: Vertex
vertex_buffer: WebGLBuffer
fragCode: string = ...
vertCode: string = ...

Methods

  • Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.

    Parameters

    • zA: XYCoords

      The start point of the arrow-line.

    • zB: XYCoords

      The end point of the arrow-line.

    • color: string

      Any valid CSS color string.

    Returns void

    Method

    arrow

    Instance

    Memberof

    drawutils

  • Draw just an arrow head a the end of an imaginary line (zB) of the given line width the specified (CSS-) color and size.

    Parameters

    • zA: XYCoords

      The start point of the arrow-line.

    • zB: XYCoords

      The end point of the arrow-line.

    • color: string

      Any valid CSS color string.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    • Optional headLength: number

      (optional) The length of the arrow head (default is 8 pixels).

    Returns void

    Method

    arrow

    Instance

    Memberof

    DrawLib

  • Draw a circle with the specified (CSS-) color and radius.

    Note that if the x- and y- scales are different the result will be an ellipse rather than a circle.

    Parameters

    • center: XYCoords

      The center of the circle.

    • radius: number

      The radius of the circle.

    • color: string

      The CSS color to draw the circle with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    Returns void

    Method

    circle

    Instance

    Memberof

    drawutils

  • Draw a circular arc (section of a circle) with the given CSS color.

    Parameters

    • center: XYCoords

      The center of the circle.

    • radius: number

      The radius of the circle.

    • startAngle: number

      The angle to start at.

    • endAngle: number

      The angle to end at.

    • color: string

      The CSS color to draw the circle with.

    • Optional lineWidth: number

    Returns void

    Method

    circleArc

    Instance

    Memberof

    drawutils

  • Draw a circle handle with the given CSS color.

    It is an inherent featur of the handle functions that the drawn elements are not scaled and not distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn as even shaped circles.

    Parameters

    • center: XYCoords

      The center of the circle.

    • size: number
    • color: string

      The CSS color to draw the circle with.

    Returns void

    Method

    circleHandle

    Instance

    Memberof

    drawutils

  • Due to gl compatibility there is a generic 'clear' function required to avoid accessing the context object itself directly.

    This function just fills the whole canvas with a single color.

    Parameters

    • color: string

      The color to clear with.

    Returns void

  • Creates a 'shallow' (non deep) copy of this instance. This implies that under the hood the same gl context and gl program will be used.

    Parameters

    • fillShapes: boolean

    Returns drawutilsgl

  • Draw a cross with diagonal axes with given radius, color and lineWidth at the given position.

    Note that the x's radius will not be affected by scaling.

    Parameters

    • center: XYCoords

      The center of the crosshair.

    • radius: number

      The radius of the crosshair.

    • color: string

      The CSS color to draw the crosshair with.

    • Optional lineWidth: number

      (optional, default=1.0) The line width to use.

    Returns void

    Method

    crosshair

    Instance

    Memberof

    drawutils

  • Draw a crosshair with given radius and color at the given position.

    Note that the crosshair radius will not be affected by scaling.

    Parameters

    • center: XYCoords

      The center of the crosshair.

    • radius: number

      The radius of the crosshair.

    • color: string

      The CSS color to draw the crosshair with.

    • Optional lineWidth: number

      (optional, default=0.5) The line width to use.

    Returns void

    Method

    crosshair

    Instance

    Memberof

    drawutils

  • Draw the given (cubic) bézier curve.

    Parameters

    • startPoint: XYCoords

      The start point of the cubic Bézier curve

    • endPoint: XYCoords

      The end point the cubic Bézier curve.

    • startControlPoint: XYCoords

      The start control point the cubic Bézier curve.

    • endControlPoint: XYCoords

      The end control point the cubic Bézier curve.

    • color: string

      The CSS color to draw the curve with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    Returns void

    Method

    cubicBezier

    Instance

    Memberof

    drawutils

  • Draw a cubic Bézier curve and and an arrow at the end (endControlPoint) of the given line width the specified (CSS-) color and arrow size.

    Parameters

    • startPoint: XYCoords

      The start point of the cubic Bézier curve

    • endPoint: XYCoords

      The end point the cubic Bézier curve.

    • startControlPoint: XYCoords

      The start control point the cubic Bézier curve.

    • endControlPoint: XYCoords

      The end control point the cubic Bézier curve.

    • color: string

      The CSS color to draw the curve with.

    • Optional lineWidth: number

      (optional) The line width to use.

    • Optional headLength: number

      (optional) The length of the arrow head (default is 8 units).

    Returns void

    Method

    cubicBezierArrow

    Instance

    Memberof

    DrawLib

  • Draw the given (cubic) Bézier path.

    The given path must be an array with n*3+1 vertices, where n is the number of curves in the path:

     [ point1, point1_startControl, point2_endControl, point2, point2_startControl, point3_endControl, point3, ... pointN_endControl, pointN ]

    Parameters

    • path: XYCoords[]

      The cubic bezier path as described above.

    • color: string

      The CSS colot to draw the path with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    Returns void

    Method

    cubicBezierPath

    Instance

    Memberof

    drawutils

  • Draw a diamond handle (square rotated by 45°) with the given CSS color.

    It is an inherent featur of the handle functions that the drawn elements are not scaled and not distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn as even shaped diamonds.

    Parameters

    • center: XYCoords

      The center of the diamond.

    • size: number

      The x/y-size of the diamond.

    • color: string

      The CSS color to draw the diamond with.

    Returns void

    Method

    diamondHandle

    Instance

    Memberof

    drawutils

  • Draw a 1x1 dot with the specified (CSS-) color.

    Parameters

    • p: XYCoords

      The position to draw the dot at.

    • color: string

      The CSS color to draw the dot with.

    Returns void

    Method

    dot

    Instance

    Memberof

    drawutils

  • Draw an ellipse with the specified (CSS-) color and thw two radii.

    Parameters

    • center: XYCoords

      The center of the ellipse.

    • radiusX: number

      The radius of the ellipse.

    • radiusY: number

      The radius of the ellipse.

    • color: string

      The CSS color to draw the ellipse with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    • Optional rotation: number

      (optional, default=0) The rotation of the ellipse.

    Returns void

    Method

    ellipse

    Instance

    Memberof

    drawutils

  • Called after each draw cycle.

    This is required for compatibility with other draw classes in the library (like drawgl).

    Parameters

    • renderTime: number

    Returns void

    Name

    endDrawCycle

    Method

    Instance

  • Draw a grid of horizontal and vertical lines with the given (CSS-) color.

    Parameters

    • center: XYCoords

      The center of the grid.

    • width: number

      The total width of the grid (width/2 each to the left and to the right).

    • height: number

      The total height of the grid (height/2 each to the top and to the bottom).

    • sizeX: number

      The horizontal grid size.

    • sizeY: number

      The vertical grid size.

    • color: string

      The CSS color to draw the grid with.

    Returns void

    Method

    grid

    Instance

    Memberof

    drawutils

  • Draw the given handle and handle point (used to draw interactive Bézier curves).

    The colors for this are fixed and cannot be specified.

    Parameters

    • startPoint: XYCoords

      The start of the handle.

    • endPoint: XYCoords

      The end point of the handle.

    Returns void

    Method

    handle

    Instance

    Memberof

    drawutils

  • Draw a handle line (with a light grey).

    Parameters

    • startPoint: XYCoords

      The start point to draw the handle at.

    • endPoint: XYCoords

      The end point to draw the handle at.

    Returns void

    Method

    handleLine

    Instance

    Memberof

    drawutils

  • Draw an image at the given position with the given size.

    Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.

    Parameters

    • image: HTMLImageElement

      The image object to draw.

    • position: XYCoords

      The position to draw the the upper left corner at.

    • size: XYCoords

      The x/y-size to draw the image with.

    • alpha: number = 0.0

      (optional, default=0.0) The transparency (0.0=opaque, 1.0=transparent).

    Returns void

    Method

    image

    Instance

    Memberof

    drawutils

  • Draw a non-scaling text label at the given position.

    Parameters

    • text: string

      The text to draw.

    • x: number

      The x-position to draw the text at.

    • y: number

      The y-position to draw the text at.

    • Optional rotation: number

      The (aoptional) rotation in radians.

    • Optional color: string

      The color to use (default is black).

    Returns void

    Method

    label

    Instance

    Memberof

    drawutils

  • Draw the line between the given two points with the specified (CSS-) color.

    Parameters

    • zA: XYCoords

      The start point of the line.

    • zB: XYCoords

      The end point of the line.

    • color: string

      Any valid CSS color string.

    Returns void

    Method

    line

    Instance

    Memberof

    drawutils

  • Draw an SVG-like path given by the specified path data.

    Parameters

    • pathData: SVGPathParams

      An array of path commands and params.

    • Optional color: string

      (optional) The color to draw this path with (default is null).

    • Optional lineWidth: number

      (optional) the line width to use (default is 1).

    • Optional options: {
          inplace?: boolean;
      }
      • Optional inplace?: boolean

        (optional) If set to true then path transforamtions (scale and translate) will be done in-place in the array. This can boost the performance.

    Returns void

    An instance representing the drawn path.

    Method

    path

    Instance

    Memberof

    drawutils

  • Draw the given point with the specified (CSS-) color and radius 3.

    Parameters

    • p: XYCoords

      The position to draw the point at.

    • color: string

      The CSS color to draw the point with.

    Returns void

    Method

    point

    Instance

    Memberof

    drawutils

  • Draw a polygon.

    Parameters

    • polygon: Polygon

      The polygon to draw.

    • color: string

      The CSS color to draw the polygon with.

    • Optional lineWidth: number

    Returns void

    Method

    polygon

    Instance

    Memberof

    drawutils

  • Draw a polygon line (alternative function to the polygon).

    Parameters

    • vertices: XYCoords[]

      The polygon vertices to draw.

    • isOpen: boolean

      If true the polyline will not be closed at its end.

    • color: string

      The CSS color to draw the polygon with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    Returns void

    Method

    polyline

    Instance

    Memberof

    drawutils

  • Draw a raster of crosshairs in the given grid.

    This works analogue to the grid() function

    Parameters

    • center: XYCoords

      The center of the raster.

    • width: number

      The total width of the raster (width/2 each to the left and to the right).

    • height: number

      The total height of the raster (height/2 each to the top and to the bottom).

    • sizeX: number

      The horizontal raster size.

    • sizeY: number

      The vertical raster size.

    • color: string

      The CSS color to draw the raster with.

    Returns void

    Method

    raster

    Instance

    Memberof

    drawutils

  • Draw a rectangle.

    Parameters

    • position: XYCoords

      The upper left corner of the rectangle.

    • width: number

      The width of the rectangle.

    • height: number

      The height of the rectangle.

    • color: string

      The color to use.

    • Optional lineWidth: number

      (optional) The line with to use (default is 1).

    Returns void

  • This method shouled be called each time the currently drawn Drawable changes. Determine the class name for further usage here.

    Parameters

    • className: string

      A class name for further custom use cases.

    Returns void

    Name

    setCurrentClassName

    Method

  • This method shouled be called each time the currently drawn Drawable changes. It is used by some libraries for identifying elemente on re-renders.

    Parameters

    • uid: string

      A UID identifying the currently drawn element(s).es.

    Returns void

    Name

    setCurrentId

    Method

  • Draw square at the given center, size and with the specified (CSS-) color.

    Note that if the x-scale and the y-scale are different the result will be a rectangle rather than a square.

    Parameters

    • center: XYCoords

      The center of the square.

    • size: number

      The size of the square.

    • color: string

      The CSS color to draw the square with.

    • Optional lineWidth: number

      (optional) The line width to use; default is 1.

    Returns void

    Method

    square

    Instance

    Memberof

    drawutils

  • Draw a square handle with the given CSS color.

    It is an inherent featur of the handle functions that the drawn elements are not scaled and not distorted. So even if the user zooms in or changes the aspect ratio, the handles will be drawn as even shaped squares.

    Parameters

    • center: XYCoords

      The center of the square.

    • size: number

      The x/y-size of the square.

    • color: string

      The CSS color to draw the square with.

    Returns void

    Method

    squareHandle

    Instance

    Memberof

    drawutils

  • Draw a text at the given relative position.

    Parameters

    • text: string

      The text to draw.

    • x: number

      The x-position to draw the text at.

    • y: number

      The y-position to draw the text at.

    • Optional options: {
          color?: string;
          fontFamily?: string;
          fontSize?: number;
          fontStyle?: FontStyle;
          fontWeight?: FontWeight;
          lineHeight?: number;
          rotation?: number;
          textAlign?: CanvasTextAlign;
      }
      • Optional color?: string

        The Color to use.

      • Optional fontFamily?: string

        The font family to use.

      • Optional fontSize?: number

        The font size (in pixels) to use.

      • Optional fontStyle?: FontStyle

        The font style to use.

      • Optional fontWeight?: FontWeight

        The font weight to use.

      • Optional lineHeight?: number

        The line height (in pixels) to use.

      • Optional rotation?: number

        The (optional) rotation in radians.

      • Optional textAlign?: CanvasTextAlign

        The text align to use. According to the specifiactions (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign) valid values are "left" || "right" || "center" || "start" || "end".

    Returns void

    Method

    text

    Instance

    Memberof

    drawutils

  • Draw an image at the given position with the given size.

    Note: SVG images may have resizing issues at the moment.Draw a line and an arrow at the end (zB) of the given line with the specified (CSS-) color.

    Parameters

    • textureImage: HTMLImageElement

      The image object to draw.

    • textureSize: Bounds

      The texture size to use; these are the original bounds to map the polygon vertices to.

    • polygon: Polygon

      The polygon to use as clip path.

    • polygonPosition: XYCoords

      The polygon's position (relative), measured at the bounding box's center.

    • rotation: number

      The rotation to use for the polygon (and for the texture).

    Returns void

    Method

    texturedPoly

    Instance

    Memberof

    drawutilsgl

Generated using TypeDoc