Chalkboard - v3.0.4
    Preparing search index...

    Function field

    • Plots a 2D vector field.

      Parameters

      • vectfield: ChalkboardFunction
      • config: {
            context: CanvasRenderingContext2D;
            domain: [[number, number], [number, number]];
            lineWidth: number;
            res: number;
            size: number;
            strokeStyle: string;
            x: number;
            y: number;
        }
        • context: CanvasRenderingContext2D

          Optional custom canvas context to draw on

        • domain: [[number, number], [number, number]]

          Domain over which to plot (in units of the function, not pixels)

        • lineWidth: number

          Stroke width

        • res: number

          Resolution (distance in pixels between sampled points), higher values result in faster plotting but less smooth plots

        • size: number

          Scale, defaults to 1, divided by 100 internally for finer control

        • strokeStyle: string

          Stroke color

        • x: number

          x-offset (canvas translation), defaults to canvas center

        • y: number

          y-offset (canvas translation), defaults to canvas center

      Returns number[][]

      const rotation = Chalkboard.vect.field((x, y) => -y, (x, y) => x);
      const vectors = Chalkboard.plot.field(rotation, { domain: [[-2, 2], [-2, 2]] }); // Plots a rotational field