Problem description:
Can someone show me code for drawing a curved line from one image to another?
I want to create a targeting system that dynamically draws a curved line. I imagine this will be done using calculus- tanget lines and all that. This line will represent the distance from one player an object. The object will be a quest item's location.
Consider an example. It is a video of mind mapping software. In it the ovals are the images and the lines in between are the curves.
https://www.youtube.com/watch?v=Gchwi3rb27s (Starts at 00:52)
ID:2065230
Apr 5 2016, 2:40 pm
|
|
There is a bezier curve drawing library.
http://www.byond.com/developer/Mightymo/BezierCurves However, I don't think this is quite what OP is looking for here. It sounds like he wants to draw a line to lead someone from where they currently are, to some point on the map. Kind of like how the Killing Floor games shows you the path to the trader in between waves. This would take a combination of a pathfinding system to find the path and some particles system to make the shown path look organic ahd fluid. |
In response to D4RK3 54B3R
|
|
D4RK3 54B3R wrote:
There is a bezier curve drawing library. Wow, that code looks even less efficient than mine... It also has a horrendously slow binomial coefficient method. Looks like it's about O(n3), assuming I'm figuring that out correctly (It might be O(n2); I've never really done any complexity stuff). The one I use is linear in k. However, I don't think this is quite what OP is looking for here. I only briefly read over it. It mentioned "Bézier Curve" in the description, and that piqued my interest, so I responded to that. |
Two ovals. A line connects them. Move one the line updates.
This line is a curve. I'd be fine if it worked just like a mind mapping software. Simple mind is the best example that comes to mind- no pun intended. http://www.simpleapps.eu/simplemind/ |
In response to Sir Quizalot
|
|
Sir Quizalot wrote:
Two ovals. A line connects them. Move one the line updates. Yes, then this is simply a Bézier curve where the first point provided to the function is the point attached to the first oval, and the final point is the line attached to the second oval. You can choose to add other points if you want to make the line "curvier", as simply two points will produce a line. But you need to figure out how you want to select those other points. |
I'm thinking add points on the fly based on distance between the two ovals. Then drawing new lines between new points. Lastly, erasing old lines between past connections. How would this be achieved?
|
In response to Popisfizzy
|
|
Popisfizzy wrote:
D4RK3 54B3R wrote: Yeah, I pointed out those issues to Mightymo at one point. Sad to find out he never addressed them properly. The operations are really not as efficient as they should be. |
Come on Lummox JR share some of your expertise. What is Popisfizzy missing? Or are you try to emphasise the use of the library?
|
As you can see here there is a general form for a Bézier curve with n points. For simplicity's sake, I'm going to define a Point class as follows.
Then the BezierCurve function will take a list of Point objects and a "fineness" factor alpha and spit out a list of Point objects to draw a curve between.
Obviously, there's some simplifications and optimizations that can be done, and it doesn't handle actually drawing the lines, but it's the start.
And as a demonstration, assuming we want to have a Bezier curve with the five points,
with a "fineness factor" of 50, we get the following curve (with the listed points plotted as well),
Though here I'm using Mathematica to get the curve rather than BYOND.