Take a look at this my question at stackoverflow.com, please. My goal is to avoid of purple borders around red rectangle. I get this vertical rectangles by rotating same-sized strongly red horizontal rectangles through its geometrical center. Best explanation of appearing of purple pixels is: this is a transform artifact. It happens if you rotate around a point that is not exactly on a full pixel (not so precise definition), so your transformed element ends up occupying half pixels on screen which the transform tries to mitigate with subpixel blending. So, my question is - which ratio should satisfy the width/height parameters of rectangle for better avoiding of this?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
closed as off topic by Steven Stadnicki, LVK, Michael Greinecker♦, William, J. M. Aug 31 '12 at 10:01
Questions on Mathematics Stack Exchange are expected to relate to math within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.
To expand my comment into a proper answer, based on my impression of what's going on: I'm going to presume that you're rotating by $90^\circ$ and want the edges of your rectangle to remain on pixel boundaries as opposed to half-pixel boundaries. In that case, as I said in the comment, the key is that your rectangle's width and height should both be of the same parity (i.e. either both odd or both even).
Here's the rough explanation: suppose that your rectangle covers the area from $(0,0)$ to $(w,h)$. Then its center will be at $(w/2, h/2)$ with the horizontal edges at $w/2\pm w/2$ (i.e., $0$ and $w$) and the vertical edges at $h/2\pm h/2$. after rotating by $90^\circ$, the center stays the same but now the width and height are interchanged; the horizontal edges are at $w/2\pm h/2$ and the vertical edges at $h/2\pm w/2$. Note that if any of these is a whole number, then all of them are; and since for instance $w/2+h/2 = (w+h)/2$ the condition that any are whole numbers is precisely the condition that $w+h$ is divisible by two, or that $w$ and $h$ have the same parity.