This is a very fast and precise triangle filler. The reason I called it a "Precision Filler" is because 1. it's highly accurate with no known artifacts, and 2. because I couldn't figure out how to make it more efficient with higher res values, so instead made it a set resolution of 1. XD How to use the demo: Click/tap on one of the triangle's vertices and drag it around. You can adjust the bounciness and rotation speed if you want. To do a speed test, press the space key. Select the number of triangles you want it to draw, and then press space again to start it. Note: For an accurate speed test, it needs to run for at least a few seconds. Depending on your computer, this may require as few as 10,000 triangles, or as high as 100,000 triangles. Tags: #trifiller #fill #tri #triangle #filler #Hacker-Cat2
Thanks to @TheLogFather because it uses basically the same algorithm as their filler, and also some of the same math. Link to theirs: https://scratch.mit.edu/projects/24828481/ One key difference is that mine doesn't actually calculate the most efficient rate, with a constant rate of 2. From my tests, it seems that the calculation of this rate (for triangles within a normal stage size) actually slows it down slightly compared to having the fixed rate. I have done several tests* and come to the conclusion that for large triangles my filler is ~6% faster, and for smaller triangles, it's up to about 12% faster! Interestingly, TurboWarp actually runs @TheLogFather's filler faster than mine... I think this has something to do with JavaScript having a higher calculations to movement ratio than Scratch, but don't quote me on that... (I don't know much about JavaScript) *The comparison was against @TheLogFather's tri filler. For all tests, the resolution was set to 1. The tests done included two different sized boxes that triangles were randomly generated in. The large triangle test is the size of the stage at 480 x 360 pixels (the same as the test in the project now), and the smaller triangle test was randomly generated triangles within a 120 x 90 pixel box. I timed each, and took three data points to reach an average. It should be noted that the tri/sec values cannot be directly compared from this project to @TheLogFather's, whether higher or lower, as they are different methods of similar tests. Disclaimer: The percents may vary depending on things like hardware, web browser, operating system, etc. If you have any questions, feel free to ask in the comments, and you can of course use this in your own projects as long as you give credit! :D For more details about how to use in your project, press the "See Inside" button and read the comments.