--create window

function Color:Create()
	local sample = script.ColorWindow:Clone()
	sample.Position = self.Params.Position
	sample.Parent = self.Gui
	sample.Visible = true

	self.Instance = sample.Content
	
	--colors
	for i,v in pairs(sample:GetDescendants()) do
		if not self.Params.RoundedCorners and v:IsA("UICorner") and v.Parent.Name ~= "Select" then
			v:Destroy()
		end
		
		if v:IsA("TextLabel") or v:IsA("TextBox") or v:IsA("ImageButton") then
			v[(v:IsA("TextLabel") or v:IsA("TextBox")) and "TextColor3" or "ImageColor3"] = self.Params.TextColor
		end
	end
	
	sample.BackgroundColor3 = self.Params.PrimaryColor
	sample.Properties.BackgroundColor3 = self.Params.PrimaryColor
	
	sample.Properties.Line.BackgroundColor3 = self.Params.SecondaryColor
	sample.Content.Bottom.Hex.Frame.BackgroundColor3 = self.Params.SecondaryColor
	for i,v in pairs({sample.Properties.HSV,sample.Properties.RGB}) do
		for q,e in pairs(v:GetChildren()) do
			if e:IsA("Frame") then
				e.Frame.BackgroundColor3 = self.Params.SecondaryColor
			end
		end
	end
	
	sample.Topbar.BackgroundColor3 = self.Params.TopbarColor
	sample.Topbar.Frame.BackgroundColor3 = self.Params.TopbarColor

	--events
	self.Finished = sample.FinishedEvent.Event
	self.Canceled = sample.CanceledEvent.Event
	self.Updated = sample.UpdateEvent.Event

	--drag
	if self.Params.Draggable and not uis.TouchEnabled then
		self.Drag = Drag.New(self.Instance.Parent)

		local dragButton = self.Instance.Parent.Topbar.Button
		dragButton.MouseButton1Down:Connect(function()
			self.Drag:Start()
		end)

		dragButton.MouseButton1Up:Connect(function()
			self.Drag:Stop()
		end)

		self._dragStopFunc = uis.InputEnded:Connect(function(input,typing)
			if typing then return end

			if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
				if self.Drag.Active then
					self.Drag:Stop()
				end
			end
		end)
	end
end
