EditableImage ImageCombineType tester and reference

While trying out the new EditableImage class, I wasn’t sure what each ImageCombineType value did. I wrote this simple mostly future-proof script that goes over all of them and combines the 2 tester images on top into a single image using EditableImage:DrawImage and the ImageCombineType value.

Put the script anywhere where LocalScripts can run (like StarterPlayer) and click play.

image

BlendTester.lua (2.5 KB)

The script's contents if you don't want to download the file
-- Config
local CanvasSize = Vector2.new(1000,1000);
local DrawCheckers = true;
local CheckersSize = 4; -- pixels

local ScreenGui = Instance.new("ScreenGui");
ScreenGui.Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui");

local InputCanvas = game:GetService("AssetService"):CreateEditableImageAsync("rbxassetid://17596549345");
local OutputCanvas = Instance.new("EditableImage");
local OutputImage = Instance.new("ImageLabel");
OutputCanvas.Size = Vector2.new(100,100) * 10;
OutputCanvas.Parent = OutputImage;
OutputImage.Position = UDim2.fromOffset(50,50);
OutputImage.Size = UDim2.fromOffset(CanvasSize.X,CanvasSize.Y);
OutputImage.Parent = ScreenGui;
OutputImage.BackgroundTransparency=1;

local Pos1, Pos2 = Vector2.zero, Vector2.new(100,0);
local Img1 = InputCanvas:Copy(Pos1, Pos1 + Vector2.new(100,100));
local Img2 = InputCanvas:Copy(Pos2, Pos2 + Vector2.new(100,100));

-- Draw checkers
if (DrawCheckers) then
	local CheckersCanvas = Instance.new("EditableImage"); do
		local size = CanvasSize/CheckersSize;
		CheckersCanvas.Size = Vector2.new(math.ceil(size.X), math.ceil(size.Y))*CheckersSize;
	end
	for x=0, CanvasSize.X/CheckersSize-1 do
		for y=0, CanvasSize.Y/CheckersSize-1 do
			local Color = (x+y)%2==0 and 1 or 0;
			local pos = Vector2.new(x,y)*CheckersSize;
			local size = Vector2.new(CheckersSize, CheckersSize);
			CheckersCanvas:DrawRectangle(pos, size, Color3.new(Color, Color, Color), 0)
		end
	end
	local CheckersLabel = Instance.new("ImageLabel");
	CheckersLabel.Parent = ScreenGui;
	CheckersLabel.BackgroundTransparency = 1;
	CheckersLabel.Size = UDim2.fromOffset(CanvasSize.X, CanvasSize.Y);
	CheckersLabel.ZIndex = -1;
	CheckersCanvas.Parent = CheckersLabel;
	CheckersLabel.Parent = ScreenGui;
end

-- Draw base images:
OutputCanvas:DrawImage(Vector2.zero, Img1, Enum.ImageCombineType.Overwrite);
OutputCanvas:DrawImage(Vector2.new(200,0), Img2, Enum.ImageCombineType.Overwrite);

-- Draw examples:
for i,BlendType in ipairs(Enum.ImageCombineType:GetEnumItems()) do
	local PosX = (i-1)*105;
	local PosY = 210;
	OutputCanvas:DrawImage(Vector2.new(PosX, PosY), Img1, Enum.ImageCombineType.Overwrite);
	OutputCanvas:DrawImage(Vector2.new(PosX, PosY), Img2, BlendType.Value);
	local TextLabel = Instance.new("TextLabel");
	TextLabel.TextSize = 10;
	TextLabel.Size = UDim2.fromOffset(100,100);
	TextLabel.Position = UDim2.fromOffset(PosX, PosY-105);
	TextLabel.Text = BlendType.Name;
	TextLabel.Parent = OutputImage;
end

EDIT: Added an optional checkerboard pattern for better alpha visibility. Can be disabled in script