How to fill empty spaces with borders

Hello,Im trying to make a 2D light system,The red lines are rays going into each corner in the room and the box, To make the light there i actually need to fill those ‘triangles’ with more frames making it fill the space

I have no idea how to achieve that and if its even possible

local Source = script.Parent:WaitForChild("Cube")
local run = game:GetService("RunService")
local Objects = {}
local World = script.Parent.Parent.Parent
local rayEngine = require(game.StarterGui:WaitForChild("RayCast2"))
for i,v in pairs(script.Parent:GetChildren()) do
	if v.Name == "fram" then
	elseif v.Name == "Obs" then

local function GetCorners(Element)
	local LT =,Element.Position.Y.Offset)
	local LB =,Element.Position.Y.Offset + Element.Size.Y.Offset)
	local RT = + Element.Size.X.Offset,Element.Position.Y.Offset)
	local RB = + Element.Size.X.Offset,Element.Position.Y.Offset + Element.Size.Y.Offset)
	return {LT,LB,RT,RB}
	for i,v in pairs(Objects) do
		for i,v in pairs(GetCorners(v)) do
			local x_center = Source.AbsolutePosition.X + (Source.AbsoluteSize.X / 2)
			local y_center = Source.AbsolutePosition.Y + (Source.AbsoluteSize.Y / 2)
			local ray =, y_center),,v.Y))
			ray.Visible = true
			local hit, pointPosition = ray:Cast(World, {World:GetDescendants()})

I don’t have any super in-depth experience with this type of thing but perhaps you could try uploading a right angle triangle as an image and then use this right triangle to fill what needs to be filled. EgoMoose wrote a good article on how to fill in an arbitrary triangle using right-angle triangles, so this could probably work in your case as well.

I’ve worked with that article before so I can probably get a somewhat functional product with a lot of testing, let me know if this is something you’d be interested in.

Thank you, this really helped me so now i have to convert it into 2d so possibly filtering out the z

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.