local X=(require(script.Parent.loader)).load(script)local I=game:GetService("\082\117\110\083\101\114\118\105\099\101")local d=X("\066\097\115\101\079\098\106\101\099\116")local T=X("\068\114\097\119")local Q=setmetatable({},d)Q.ClassName="\068\114\097\119\105\110\103\082\101\110\100\101\114\101\114"Q.__index=Q function Q.new(X,T)local v=setmetatable(d.new(),Q)v._serviceBag=assert(X,"\078\111 \115\101\114\118\105\099\101\066\097\103")v._pencilClient=assert(T,"\066\097\100 \112\101\110\099\105\108\067\108\105\101\110\116")v:_drawUpdate()v._maid:GiveTask(I.Stepped:Connect(function()v:_drawUpdate()end))v._maid:GiveTask(function()v:_drawUpdate(true)end)return v end function Q._drawUpdate(I,X)local d=I._pencilClient:GetPosition()if I._lastPosition then local Q=d-I._lastPosition if Q.magnitude<=.05 and not X then return end local v=T.vector(I._lastPosition,Q,I._pencilClient:GetColor())v.Transparency=1 I._pencilClient:GiveDrawPart(v)I._lastPosition=d else I._lastPosition=d end end return Q
--[=[
	@class DrawingRenderer
]=]

local require = require(script.Parent.loader).load(script)

local RunService = game:GetService("RunService")

local BaseObject = require("BaseObject")
local Draw = require("Draw")

local DrawingRenderer = setmetatable({}, BaseObject)
DrawingRenderer.ClassName = "DrawingRenderer"
DrawingRenderer.__index = DrawingRenderer

function DrawingRenderer.new(serviceBag, pencilClient)
	local self = setmetatable(BaseObject.new(), DrawingRenderer)

	self._serviceBag = assert(serviceBag, "No serviceBag")

	self._pencilClient = assert(pencilClient, "Bad pencilClient")

	self:_drawUpdate()

	self._maid:GiveTask(RunService.Stepped:Connect(function()
		self:_drawUpdate()
	end))

	self._maid:GiveTask(function()
		self:_drawUpdate(true)
	end)

	return self
end

function DrawingRenderer:_drawUpdate(forceFinalize)
	local position = self._pencilClient:GetPosition()
	if self._lastPosition then
		local offset = position - self._lastPosition
		if offset.magnitude <= 0.05 and not forceFinalize then
			return
		end

		local vector = Draw.vector(self._lastPosition, offset, self._pencilClient:GetColor())
		vector.Transparency = 1
		self._pencilClient:GiveDrawPart(vector)

		self._lastPosition = position
	else
		self._lastPosition = position
	end
end

return DrawingRenderer