Path2D Full Release

nvm lol, it was because the billboard gui was too close to the screen, and I didn’t notice this because the output bar made my fov really big and for some reason made the billboard gui visible.

1 Like

You could also do that with 2D, what’s the point?

1 Like

Hey everyone!

We have a mini update for Path2D!

Path2D.Closed property to connect the first and last control points.
Path2D:GetMaxControlPoints() function to report the maximum number of control points.
Path2D.ControlPointChanged this signal will fire any time any control point(s) changes.
Path2D.GetLength() returns the length of the spline.

And finally, Path2D anti-aliasing is rolled out on all platforms. This will make all Path2Ds look much cleaner. A small note, it is expected that the Paths will get a bit thinner as a result, please keep this in mind.

As always please post any suggestions, feedback, bug reports, or anything else about Path2D!
Thanks

2 Likes

what about for fill? then we could be able to color it or use gradients and make clipdescendants work with in the area of the path?

2 Likes

Will there be support for snapping in the future? I think this feature would be really useful for precision tracing. If given nodes to connect to, either by frames or a part, you can construct the control points with better accuracy and less headache.

1 Like

How do you remove a path point in studio? Selecting and then pressing Del just deletes the Path2D instance

I even thought this is useful to make SVG in roblox but simple
I love it!!

Why not RBXM ,The file should if RBXL had the model ,But the RBXL with an workspace and more services they make the file bigger :unamused:

I’m really an expert that recognize the image is made by AI or handmade
It means this image was made by AI sometimes but good path creation

Hi!

If you right click on a control point, you’ll see an option to delete just that point.

2 Likes

You could add a fill property, this would be very useful for path 2d.

Hello good. I’m creating a node system and it works relatively well, but… there is a strange problem with the ZIndex (or so it seems, my script seems to be quite sane).

This is the starting ZIndex:

zidex

and I have to manually increase (with code it does not change) the ZIndex so that they are visible (it should be noted that my code makes the Path2d visible and invisible but I have already checked and the property is true and it is not yet visible). By the way, I cannot put a number lower than the default ZIndex, it must be higher than the one at the beginning.

numeromayor
visibles

They are already visible (by the way, I think it only happens when they are children of a scrollingFrame). (if I make everything invisible (with transparency) the Path2d are still invisible. Excuse my English and I hope this error is solved (if it is the API).

(I just realized that the error occurs when changing the Visible to true or false). I still believe that the mistake is not mine.

Here I replicate it:


place:
Path2dError.rbxl (93.7 KB)

I already know how to get the error, but I can’t solve it XD
Do I post it in the Forum as an Error, or is this enough?

Duplicate error in your own example file. The error is from the API

Been loving this feature and everything that is possible with it but is it possible to see additional properties from other Gui Objects? This feature opens a lot of technical possibilities but currently lacks a lot of cosmetic options like fill, and other GuiObject properties like LayoutOrder (for like a list divider). It would also be awesome to see UIGradients and additional UIStrokes work, I wanted to look into creating primitive SVG support through Path2D but ran into these limitations.

There also seems to be some issues with the Path2D.Closed property. From what Ive noticed is unlike other corners it appears to be unrounded.


Even after adjusting the last point, the issue persists.

2 Likes

this is literally the reason why I hate roblox dev. This ##### ignores zindex with scrolling frames, once it goes offscreen, it doesn’t render back, doesn’t support uicorner, looks very badly on sharp turns, has basically no customizability, it is literally easier for me to create my own 2d path system with frames than to use this.

5 Likes

Hey, im wondering is there are any updates coming to the path2d?

Im currently using path2d as wires and i need InputBegan and InputEnd (or any input for the mouse on top of the path) for detection of a selected wire, but i dont think either are a thing for Path2ds

And if possible, an option to stop Path2Ds from disappearing when outside the screen since this is causing a lot of unwanted visual bugs

Again, i dont know if there are any plans to update the Path2D but this would be really handy since i will need to try using other methods to detect inputs and i dont think there is anything i can do to stop the visual bugs

Hi, could you check if the Path still disappears off screen? Thanks

Just finished converting my dialog editor to use this. Very nice. I wish it respected UIScale correctly, though. I have to recompute the control points when the editor zoom changes, and it’s quite slow. I could probably optimize a little by checking if the chord intersects the viewport, but it won’t help when trying to get an overview of the dialog tree like you see here.

I’d imagine doing it in the rendering code would be quite a bit faster, but I don’t know how it works.

Might I also recommend a method on Path2D to test for line-segment intersection? I already have some code that does this but it’s specialized for Catmull-Rom splines, not beziers. I had to figure out how to convert. If anyone’s curious, here it is:

local function catmullRomSegmentToBezier(p0, p1, p2, p3)
	local b0 = p1
	local b3 = p2
	local b1 = p1 + (p2 - p0) / 6
	local b2 = p2 - (p3 - p1) / 6
	return b0, b1, b2, b3
end

------------------------------------------------------------------------------
-- bool testSegSpline(
--     Vector2 p0, Vector2 p1, 
--     Vector2 s0, Vector2 s1, Vector2 s2, Vector2 s3)
--
-- Returns true iff the line segment formed by endpoints p0 & p1 intersects 
-- with cubic polynomial `s3*t^3 + s2*t^2 + s1*t + s0` for some t in [0, 1].
------------------------------------------------------------------------------
local testSegSpline do
	local abs   = math.abs
	local atan2 = math.atan2
	local cos   = math.cos
	local pi    = math.pi
	local sqrt  = math.sqrt
	local dot   = Vector2.new().Dot
	local cross = Vector2.new().Cross

	local EPS = 1e-9

	local function findRoots(a, b, c, d)
		if abs(a) > EPS then
			b = b/a
			c = c/a
			d = d/a

			local u = (b*b*(4*b*d - c*c) + c*(4*c*c - 18*b*d) + 27*d*d)/108
			local v = (9*b*c - 27*d - 2*b*b*b)/54

			local off = b/3

			if u > 0 then
				local su = sqrt(u)
				local term2 = (v - su)
				local term2Sign = math.sign(term2)
				return {
					(v + su)^(1/3) + ((math.abs(term2)^(1/3))*term2Sign) - off,
				}
			elseif u < 0 then
				local scale = 2/3*sqrt(b*b - 3*c)
				local angle = atan2(sqrt(abs(u)), v)
				return {
					scale*cos(angle/3) - off,
					scale*cos((angle + 2*pi)/3) - off,
					scale*cos((angle + 4*pi)/3) - off,
				}
			else
				local cr = v^(1/3)
				return {
					2*cr - off,
					cr - off,
				}
			end

		elseif abs(b) > EPS then
			local det = c*c - 4*b*d
			
			if det > 0 then
				local sdet = sqrt(det)
				return {
					(c + sdet)/(-2*b),
					(c - sdet)/(-2*b),
				}
			elseif det == 0 then
				return {
					c/(-2*b),
				}
			end

		elseif abs(c) > EPS then
			return {
				-d/c,
			}
		end
	end

	function testSegSpline(p0, p1, s0, s1, s2, s3)
		if p0.X > p1.X then
			p0, p1 = p1, p0
		end
		local line = Vector2.new(p0.y - p1.y, p1.x - p0.x)

		local d3 = dot(line, s3)
		local d2 = dot(line, s2)
		local d1 = dot(line, s1)
		local d0 = dot(line, s0) + cross(p0, p1)

		local roots = findRoots(d3, d2, d1, d0)

		if roots then 
			for i = 1, #roots do
				local t = roots[i]

				if 0 <= t and t <= 1 then
					local st = ((s3*t + s2)*t + s1)*t + s0
					local dp = p1 - p0

					if dot(dp, st - p0) >= 0 and dot(dp, st - p1) < 0 then
						return true
					end
				end
			end
		end

		return false
	end
end

(Note: I didn’t write this, a much more mathematically-inclined friend (not AI) did. Could probably be optimized more, especially with an AABB early-out. It’s just for an internal tool for me and I’m working with a lot of compute power, so I didn’t bother.)

5 Likes