EditableImage

사용되지 않는 항목 표시
만들 수 없음

EditableImage allows for the runtime creation and manipulation of images.

To create a blank EditableImage, use Instance.new(). To create an EditableImage from an existing image, use AssetService:CreateEditableImageAsync().

EditableImage overrides the image or texture displayed when parented to certain objects:

The EditableImage coordinate system is relative to the top left of the image:

  • Top-left: (0, 0)
  • Bottom-right: (Size.X - 1, Size.Y - 1)

When you use AssetService:PromptCreateAssetAsync() to publish an object that has a property overridden by a child EditableImage, the editable image is published as an image and the overridden property is set to a new asset ID.

요약

속성

메서드

속성

읽기 전용
복제되지 않음
병렬 읽기

Size of the EditableImage in pixels. The maximum size is 1024×1024. Attempting to set this property to a larger size will cause it to be clamped at 1024.

Setting this property changes the canvas size of the editable image but does not resize the contents. If changing to a larger size, new pixels will be set to an RGBA value of [0, 0, 0, 0]. If changing to a smaller size, existing pixels will be cropped. Consider using Resize() to update the contents while changing the size.

메서드

Destroy

void

반환

void

DrawCircle

void

Draws a circle at the specified point on the EditableImage. If the circle is semi-transparent, it will be blended with the pixels behind it using source over blending.

매개 변수

center: Vector2

Center of the circle, relative to the top-left corner of the EditableImage. Positions outside the canvas bounds are allowed.

radius: number

Radius of the circle in pixels.

color: Color3

Color of the circle.

transparency: number

Transparency of the circle with 0 being fully opaque and 1 being fully transparent.

How the pixels of the source image are blended with the pixels of the added image.


반환

void

DrawImage

void

Draws another EditableImage into this EditableImage at the given position. Positions outside the canvas bounds are allowed such that only part of the new image is drawn.

매개 변수

position: Vector2

Position at which the top-left corner of the added image will be drawn.

image: Object

The EditableImage to draw into this EditableImage.

How the pixels of the source image should be blended with the pixels of the added image.


반환

void

DrawLine

void

Draws an anti-aliased line on the EditableImage one pixel thick between the two provided points.

매개 변수

Start point of the line.

End point of the line.

color: Color3

Color of the line.

transparency: number

Transparency of the line.

How the pixels of the source image are blended with the pixels of the added image.


반환

void

DrawProjectionImage

void

매개 변수

mesh: Object
projection: Dictionary
brushConfig: Dictionary

반환

void

DrawRectangle

void

Draws a rectangle on the EditableImage of the given size at the given top-left position.

매개 변수

position: Vector2

Position of the top-left of the rectangle. Unlike other drawing methods, this cannot be outside the canvas bounds of the EditableImage.

size: Vector2

Size of the rectangle to draw, in pixels.

color: Color3

Color of the rectangle.

transparency: number

Transparency of the rectangle.

How the pixels of the source image are blended with the pixels of the added image.


반환

void

ReadPixelsBuffer

병렬 쓰기

A version of ReadPixels() that returns a buffer instead of a table. Each number in the buffer is a single byte, while each number in the table is 4 bytes, making ReadPixelsBuffer() more memory-efficient than ReadPixels().

Note that this method uses alpha instead of transparency, unlike the EditableImage drawing methods.

매개 변수

position: Vector2

Top-left corner of the rectangular region of pixels to read.

size: Vector2

Size of the rectangular region of pixels to read.


반환

Buffer where each pixel is represented by four bytes (red, green, blue and alpha respectively). The length of the buffer can be calculated as Size.X * Size.Y * 4 bytes.

코드 샘플

EditableImage:ReadPixelsBuffer()

local AssetService = game:GetService("AssetService")
local options = { Size = Vector2.new(32,32) }
local editableImage = AssetService:CreateEditableImage(options)
local pixelsBuffer = editableImage:ReadPixelsBuffer(Vector2.zero, Vector2.new(2, 1))
local color1 = Color3.fromRGB(buffer.readu8(pixelsBuffer, 0), buffer.readu8(pixelsBuffer, 1), buffer.readu8(pixelsBuffer, 2))
local transparency1 = 1 - buffer.readu8(pixelsBuffer, 3)
local color2 = Color3.fromRGB(buffer.readu8(pixelsBuffer, 4), buffer.readu8(pixelsBuffer, 5), buffer.readu8(pixelsBuffer, 6))
local transparency2 = 1 - buffer.readu8(pixelsBuffer, 7)
local averageColor = color1:Lerp(color2, 0.5)
local averageTransparency = (transparency1 + transparency2) / 2
local part = Instance.new("Part")
part.Color = averageColor
part.Transparency = averageTransparency
part.Parent = workspace

WritePixelsBuffer

void

A version of WritePixels() that takes a buffer instead of a table. Each number in the buffer is a single byte, while each number in the table is 4 bytes, making WritePixelsBuffer() more memory-efficient than WritePixels().

Note that this method uses alpha instead of transparency, unlike the EditableImage drawing methods.

매개 변수

position: Vector2

Top-left corner of the rectangular region to draw the pixels into.

size: Vector2

Size of the rectangular region of pixels to write.

buffer: buffer

A buffer where each pixel is represented by four bytes (red, green, blue, and alpha respectively). The length of the buffer should be Size.X * Size.Y * 4 bytes.


반환

void

코드 샘플

EditableImage:WritePixelsBuffer()

local AssetService = game:GetService("AssetService")
local options = { Size = Vector2.new(32,32) }
local editableImage = AssetService:CreateEditableImage(options)
local pixelsBuffer = editableImage:ReadPixelsBuffer(Vector2.zero, editableImage.Size)
for i = 1, editableImage.Size.X * editableImage.Size.Y do
local pixelIndex = (i - 1) * 4
buffer.writeu8(pixelsBuffer, pixelIndex, 255 - buffer.readu8(pixelsBuffer, pixelIndex))
buffer.writeu8(pixelsBuffer, pixelIndex + 1, 255 - buffer.readu8(pixelsBuffer, pixelIndex + 1))
buffer.writeu8(pixelsBuffer, pixelIndex + 2, 255 - buffer.readu8(pixelsBuffer, pixelIndex + 2))
end
editableImage:WritePixelsBuffer(Vector2.zero, editableImage.Size, pixelsBuffer)

이벤트