Skip to main content

DrawImageTrapezify

Callable

  • DrawImageTrapezify(image: HTMLCanvasElement | HTMLImageElement, targetCanvas: HTMLCanvasElement, topToBottomRatio: number, x?: number, y?: number): void

  • Draws a source canvas or image onto a canvas, with a shear transformation (such that the width of the top and bottom are different). If the topToBottomRatio is greater than 1, then the bottom edge of the image will be smaller in the original image. If it's less than 1, then the top edge will be smaller than in the original (like the Star Wars title text transform).


    Parameters

    • image: HTMLCanvasElement | HTMLImageElement

      The source image

    • targetCanvas: HTMLCanvasElement

      The target canvas to draw the transformed image onto

    • topToBottomRatio: number

      The ratio between the desired length of the top edge and the bottom edge of the final image.

    • optionalx: number = 0

      The x-position on the target canvas that the final image should be drawn at

    • optionaly: number = 0

      The y-position on the target canvas that the final image should be drawn at

    Returns void