How exactly does the Moon’s canvas.Compose() work?

Asked

Viewed 232 times

3

canvas:Compose (x, y, canvas_src)

Make pixel-by-pixel composition between two canvas.

The canvas passed as src`is drawn on the canvas in use (canvas) in the past position.

Receives:

  • x: [number] Position x of the composition.
  • y: [number] Position and composition.
  • canvas_src: [canvas] Canvas to be composed on canvas.

After the operation, the canvas target canvas has the result of the composition and canvas src does not change at all.

Source: http://www.telemidia.puc-rio.br/~francisco/nclua/referencia/canvas.html#function_compose

Example:

canvas -> 1920 x 1080
imagem -> 1280 x 720

canvas.compose(0, 0, imagem)

How the image should be composed on canvas?

  1. The image is in the 0.0 position (left/top) with the original size of 1280x720 and is left space below and right side.

  2. The image starts at 0.0 (left/top) and is enlarged to fill the entire canvas size (1920x1080).

1 answer

0

  1. The image is in the 0.0 position (left/top) with the original size of 1280x720 and is left space below and right side.

  2. Canvas does not auto-resize by default. To resize a canvas you can try using the function: canvas:attrSize(height, width).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.