local H=game:GetService("\077\097\114\107\101\116\112\108\097\099\101\083\101\114\118\105\099\101")local V=game:GetService("\072\116\116\112\083\101\114\118\105\099\101")local b=Instance.new("\067\097\109\101\114\097")b.FieldOfView=20 local c=Instance.new("\086\105\101\119\112\111\114\116\070\114\097\109\101")c.BackgroundColor3=Color3.new()c.BackgroundTransparency=1 c.LightDirection=Vector3.new(0,1,0)c.Ambient=Color3.new(1,1,1)c.Size=UDim2.new(0,100,0,100)local y=Instance.new("\068\101\099\097\108")y.Face=Enum.NormalId.Top local E,s=Vector3.new,CFrame.new local k,X=string.match,math.max local R,u=E(1,.1,1),s(0,-0.1,0)local F={}function F.new(H,V)assert(H and(type(H)=="\115\116\114\105\110\103"and k(H,"\037\100\043")),"\073\110\118\097\108\105\100 \073\109\097\103\101 \073\068\058 "..H)assert(V and(type(V)=="\115\116\114\105\110\103"and script:FindFirstChild(V)),"\073\110\118\097\108\105\100 \067\108\105\112\112\101\114 \084\121\112\101\058 "..V)local E=(script:FindFirstChild(V)):Clone()E.Size=R E.CFrame=u E.Transparency=1 local s=y:Clone()s.Texture=H local F=b:Clone()F.CFrame=CFrame.new(Vector3.new(0,(X(E.Size.X,E.Size.Z)/2)/.17,0),Vector3.new())*CFrame.Angles(0,0,-1.5707963267949)local l=c:Clone()l.CurrentCamera=F s.Parent=E E.Parent=l F.Parent=l return l,E end return F
------------------------------------------------------------------------------
-- Image Clipping Module
-- by boatbomber
--
-- For a detailed write-up, see here:
-- https://devforum.roblox.com/t/open-source-image-clipping-module/293014
--
-- API Overview:
--
-- module.new(<string> ID, <string> Type)
--  returns ViewportFrame,ClipperPart
--
------------------------------------------------------------------------------

--Services
local Marketplace = game:GetService("MarketplaceService")
local Http = game:GetService("HttpService")

--Prefabricate objects
local Camera = Instance.new("Camera")
	Camera.FieldOfView	= 20

local ViewportFrame	= Instance.new("ViewportFrame")
	ViewportFrame.BackgroundColor3 = Color3.new()
	ViewportFrame.BackgroundTransparency = 1
	ViewportFrame.LightDirection = Vector3.new(0,1,0)
	ViewportFrame.Ambient = Color3.new(1,1,1)
	ViewportFrame.Size = UDim2.new(0,100,0,100)

local Decal = Instance.new("Decal")
	Decal.Face = Enum.NormalId.Top
	
--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
