Skip to content

@ue-too/board / index / invertYAxisForDrawImageWith9Args

関数: invertYAxisForDrawImageWith9Args()

invertYAxisForDrawImageWith9Args(args): any[]

定義: packages/board/src/utils/canvas-position-dimension.ts:799

Inverts y-coordinates for the 9-argument variant of drawImage.

パラメータ

args

any[]

The arguments array for drawImage

戻り値

any[]

Modified arguments with inverted y-coordinates

Remarks

The 9-argument drawImage signature is: drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight)

When inverting y-axis, we need to adjust:

  • sy (source y): Flip relative to image height
  • sHeight: Negate (height becomes negative in flipped space)
  • dy (destination y): Negate
  • dy offset: Subtract destination height

This ensures images render correctly when the canvas y-axis is flipped.

typescript
// Original call (top-left origin):
ctx.drawImage(img, 0, 0, 100, 100, 50, 50, 200, 200);

// With flipped y-axis, this becomes:
// sy = imageHeight - 0, sHeight = -100, dy = -50 - 200, dHeight = -200

参照

reverseYAxis for the main y-axis flipping proxy