संदर्भ resizeCanvas()

resizeCanvas()

Resizes the canvas to a given width and height.

resizeCanvas() immediately clears the canvas and calls redraw(). It's common to call resizeCanvas() within the body of windowResized() like so:

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

The first two parameters, width and height, set the dimensions of the canvas. They also the values of the width and height system variables. For example, calling resizeCanvas(300, 500) resizes the canvas to 300×500 pixels, then sets width to 300 and height 500.

The third parameter, noRedraw, is optional. If true is passed, as in resizeCanvas(300, 500, true), then the canvas will be canvas to 300×500 pixels but the redraw() function won't be called immediately. By default, redraw() is called immediately when resizeCanvas() finishes executing.

उदाहरण

सिंटैक्स

resizeCanvas(width, height, [noRedraw])

पैरामीटर्स

width
Number:

width of the canvas.

height
Number:

height of the canvas.

noRedraw
Boolean:

whether to delay calling redraw(). Defaults to false.

Notice any errors or typos? Please let us know. Please feel free to edit src/core/rendering.js and open a pull request!

संबंधित संदर्भ