API / core/frame
core/frame
이미지 영역.
Image region.
Frameextends Object
이미지 영역.
Image region.
예제Example스프라이트 시트의 한 칸을 조각으로Make a frame from one cell of a sprite sheet
import { ImageAsset, Frame, Rect } from "./build/vanilla.js";
const imageAsset = new ImageAsset();
await imageAsset.load("examples/assets/spritesheet.png");
const image = imageAsset.getImage();
const frame = new Frame(image, Rect.create(200, 0, 200, 200));
const imageRect = frame.getImageRect();
console.log(imageRect.x, imageRect.y, imageRect.width, imageRect.height);
const wholeFrame = new Frame(image);
const wholeRect = wholeFrame.getImageRect();
console.log(wholeRect.width, wholeRect.height);생성.
Constructor.
- imageHTMLImageElement
- 이미지. (null 이나 undefined 면 예외를 낸다)Image. (throws if null or undefined)
- rectRect | null
- 이미지 안의 영역. (픽셀, null 이면 이미지 전체, 이미지 밖으로 넘어도 자르지 않는다)Region inside the image. (pixels, the whole image if null, not clipped even if it goes outside the image)
짝Counterpart: vanilla-engine Frame.new
이미지 반환.
Returns the image.
반환ReturnsHTMLImageElement 이미지.Image.
짝Counterpart: vanilla-engine Frame.get_image
이미지 내부 영역 반환.
Returns the image inner region.
반환ReturnsRect 이미지 안의 영역. (픽셀)Region inside the image. (pixels)
짝Counterpart: vanilla-engine Frame.get_image_rect