Hi, I am using Graphics to encode information as Colour in Graphics for rapid data look up. But by default JUCE is anti-aliased. Which means that when I draw lines, the edges of the lines would have altered data due to antialiasing. Is it possible to disable anti aliasing in JUCE? Or if not, is there an alternative to achieve this approach? (Ex. using some small external library?)
Graphics? Surely a straight
std::vector<uint32_t> would be a better storage method?
I am drawing many primitive lines, (bezier) curves, and circles using Graphics, and need to detect which line or circle to highlight or draw extra elements on top of it depending on their distance to the current mouse position. Instead of iterating through each graphic element and calculate the distance using
point.getDistanceSquaredFrom(point2) on each mouseMove event, I wanted to use a technique that’s sometimes used in game development: use an extra buffer to store the same graphic elements (but invisible to the users since they are not drawn), and set their colors to -
Colour (indexOfReferencePoint). So when I call int
value = image.getPixelAt(mousePosX, mousePosY), value is actually the index of the point that the mouse is currently hovering.
more about this technique:
but this will not work if there is anti-aliasing, as it changes the color at the edge of lines and that means it also changes the index that pixel represents. Also an experienced peer developer just told me that - in case the data set is huge, it could cause slow view redraw during zoom-in/out etc. events and have to recreate the buffer when the screen size changed, which makes it a less ideal solution.
Ah ok, sorry I misread your post and thought you were just using that has a shortcut to a 2D array.