How would I get all the nearest frames to a frame?

Hello!

I am trying to get all the nearest frames to another frame.

For example:

Let’s say there is a frame with 4 frames next to it,

first frame is above it, Second frame is below it, etc…

How would I get all the 4 frames without getting the frames on the corner?

.

Sorry I am not the best at English.

2 Likes

I am kinda confused

Can you explain better?

i think this would need extremely complicated maths or im just not getting what algorithm you should use to do this kinda nonsense function
either way can you explain that better

1 Like

All I want is to get the nearest frame to another frame.

For example:

:green_square::white_large_square::green_square:
:white_large_square::white_large_square::white_large_square:
:green_square::white_large_square::green_square:

See the square on the center? I want to get all the squares next to it, and not the green squares.

1 Like

that looks pretty complicated man why do would you even need that?

1 Like

so you want all 4 frame all touching each other’s corners ?

1 Like

that would be edges not corners btw

1 Like

My mistake, well if Mr_Shqah could show me a reference (example) I can help you find a solution.

1 Like

I am trying to make a renderer.

The problem is, It runs on like 15 fps.

So I am trying to get all the pixels near another pixel and then set the pixel’s color to the average colors of all the pixels near it.

I think I can double the fps by guessing half of the pixels color. And I think it would add a little bit of blur, which will make it more realistic.

Btw every pixel is a frame.

1 Like

I dont think going through all the pixels and going through their positions and their magnitudes then setting an average color would really help in optimization… Unless there is a holy grail of a roblox function that finds what frames are touching each other. Try researching for more info

1 Like

If by pixel you mean a frame that is a size by {0, 10},{0, 10} or more then I could show u my script where I make my frames place beside each other else if the frame (pixel) is smaller then it will be harder to help with that since I am a bit lost of how you want the pixels places near each other. So like the other guy said maybe do some more researching.

1 Like

I heard that some render engines do this to help optimization.

Not too sure tho.

1 Like

Render engines use special functions, not getting the nearest frames by going through every single pixel
so it wouldnt be very optimized

1 Like

Example

For example:

See all the squares in this photo?

All of these are pixels.

see this yellow pixel?
I am trying to get all the pixels that are near it.
(In this photo, the white pixels are the pixels that I am trying to get.)

1 Like

I think I can get the nearest pixels without making another loop.

And what do you mean about “special functions”?

1 Like

when you are trying to get all pixels near the yellow one do you mean all the ones touching that pixel?

Yea.

But not the pixels on the edge/corner of the pixel.

And the pixel size is about {0, 5, 0, 5}.

Well this will get a bit complicated but I’ve had a coding like with this exact problem but one thing is that all your pixels are all positioned weird instead of being all nice and perfectly positioned

No, That photo was an example.

I am using UIGridLayout.

Here would be a script that you can use to detect if both pixels are touching
Make sure you loop threw all pixels except the yellow one in your Render

-- MainPixel = Yellow Pixel
-- Pixel = Any other pixel but the Yellow Pixel

local function HitDetection(MainPixel, Pixel)
	local pos1, size1 = MainPixel.AbsolutePosition, MainPixel.AbsoluteSize;
	local pos2, size2 = Pixel.AbsolutePosition, Pixel.AbsoluteSize;
	
	local top = pos2.Y-pos1.Y
	local bottom = pos2.Y+size2.Y-(pos1.Y+size1.Y)
	local left = pos2.X-pos1.X
	local right = pos2.X+size2.X-(pos1.X+size1.X)
	
	if top > 0 then
		-- Touched
	elseif bottom < 0 then
		-- Touched
	end
	if left > 0 then
		-- Touched
	elseif right < 0 then
		-- Touched
	end
end