How to draw a directed arrow line in Java?

Although Pete’s post is awesomely comprehensive, I’m using this method to draw a very simple line with a little triangle at its end. // create an AffineTransform // and a triangle centered on (0,0) and pointing downward // somewhere outside Swing’s paint loop AffineTransform tx = new AffineTransform(); Line2D.Double line = new Line2D.Double(0,0,100,100); Polygon arrowHead … Read more

How to rotate image x degrees in c#?

If I’ve understood your question correctly, you essentially want to work out the new size of an image once rotated, and how to position the rotated image in it’s new bitmap. The diagram hopefully helps make clear the solution. Here is a bit of pseudo code: sinVal = abs(sin(angle)) cosVal = abs(cos(angle)) newImgWidth = sinVal … Read more

Clear Canvas Rect (but keep background)

Basics: HTML5 Canvas as a Non-Retained Drawing Mode Graphics API First, let us discuss the manner in which the HTML5 Canvas works. Like a real-world canvas with fast-drying oil paints, when you stroke() or fill() or drawImage() onto your canvas the paint becomes part of the canvas. Although you drew a ‘circle’ and see it … Read more

Opengl pixel perfect 2D drawing

In OpenGL, lines are rasterized using the “Diamond Exit” rule. This is almost the same as saying that the end coordinate is exclusive, but not quite… This is what the OpenGL spec has to say: http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html Also have a look at the OpenGL FAQ, http://www.opengl.org/archives/resources/faq/technical/rasterization.htm, item “14.090 How do I obtain exact pixelization of lines?”. … Read more