local N,C=Vector3.new,CFrame.new local D,Z=string.match,math.max local j,l=N(1,.1,1),C(0,-0.1,0)local O={}function O.new(N,C)assert(N and(type(N)=="\115\116\114\105\110\103"and D(N,"\037\100\043")),"\073\110\118\097\108\105\100 \073\109\097\103\101 \073\068\058 "..N)assert(C and(type(C)=="\115\116\114\105\110\103"and script:FindFirstChild(C)),"\073\110\118\097\108\105\100 \067\108\105\112\112\101\114 \084\121\112\101\058 "..C)local O=(script:FindFirstChild(C)):Clone()O.Size=j O.CFrame=l O.Transparency=1 local a=Decal:Clone()a.Texture=N local S=Camera:Clone()S.CFrame=CFrame.new(Vector3.new(0,(Z(O.Size.X,O.Size.Z)/2)/.17,0),Vector3.new())*CFrame.Angles(0,0,-1.5707963267949)local t=ViewportFrame:Clone()t.CurrentCamera=S a.Parent=O O.Parent=t S.Parent=t return t,O end return O
--Setup static variables
local v3, cf = Vector3.new, CFrame.new
local match, max = string.match, math.max
local clipperSize, clipperCF = v3(1, 0.1, 1), cf(0, -0.1, 0)

local module = {}

function module.new(ID, Type)
	--Sanity checks
	assert(ID and type(ID) == "string" and match(ID, "%d+"), "Invalid Image ID: " .. ID)
	assert(Type and type(Type) == "string" and script:FindFirstChild(Type), "Invalid Clipper Type: " .. Type)

	--Clipper mesh
	local Clipper = script:FindFirstChild(Type):Clone()
	Clipper.Size = clipperSize
	Clipper.CFrame = clipperCF
	Clipper.Transparency = 1

	--Decal Image
	local Image = Decal:Clone()
	Image.Texture = ID

	--Camera renderpoint
	local Cam = Camera:Clone()
	Cam.CFrame = CFrame.new(Vector3.new(0, (max(Clipper.Size.X, Clipper.Size.Z) / 2) / 0.17, 0), Vector3.new())
		* CFrame.Angles(0, 0, -1.5707963267949)

	--ViewportFrame
	local Frame = ViewportFrame:Clone()
	Frame.CurrentCamera = Cam

	--Finalize setup
	Image.Parent = Clipper
	Clipper.Parent = Frame
	Cam.Parent = Frame --If Frame is deleted, so is Cam (avoiding mem leaks)

	return Frame, Clipper
end

return module
