@CodeHelp 2 problems have come to my attention:
- The grater the distance between the 2 points, the less accurate the line of best fit.
- If the line of best fit hits the top or bottom of the graph before the edge, it won’t continue forming the line.
Any help will be given credit for. Thanks!
@leaders new topic in #debug-my-code please
How and in which object do you figure out the line of best fit?
This could be a rounding issue with set position. Instead of using the default x and y position variables, make your own, which can be more precise, and set position to those.
Do you want to use trail art anywhere other than the graph?
@Petrichor is correct. The problem is accumulation of rounding error in the Set Position steps.
First, 1 long line is drawn between the 2 points. That part of the line is drawn accurately (since you rounded the Last Touched locations to be exact points on the graph). Subsequently, the remainder of the line is drawn in small steps. Each one of those small steps accumulates a small error as the Set Position block rounds the position to the nearest pixel.
There’s multiple approaches to fixing the issue
- As Petrichor said, implement 2 new variables to track the X & Y locations of each small step more precisely. I’d speculate that this is a more complicated approach.
- Calculate where the line crosses the outer bounds of the graph. Draw 1 single line between these two points. Those points will still get rounded by the Set Position to the nearest pixel, but that won’t be noticeable. This is what I’d recommend.
Ok. Thanks. I will implement the second option.
Then the simplest option would be covering everything else with objects, although if you change the method of drawing the line, you may b not need to.
Ok. I’ll see what I end up doing. Could I use the same code for the x boundary as the y boundary do you think?
Probably. I’m not sure what you’re using now but it should be basically the same but vertical.
Ok. I’ll see if that works.
Pls stop bumping topics that have nothing to do with wut the hser is doing rn