If I am given the exact coordinates of three vertices in image-space (as in, the numbers are not integers, but can be rounded to find their location on the screen), how can I determine which pixels are inside the triangle and should be colored?

If you look at the diagram below it might clarify what I'm trying to do
http://oi47.tinypic.com/eaktwi.jpg
As you can see, the pixels which are mostly within the triangle are filled green. How can I do this in code?

yes, thanks.

No need to code that youself. The Shape class has a Polygon subclass that allows you to create a Shape from an arbitrary list of x,y coordinates. The Shape class has methods for contains(Point2D p) etc, and the Graphics2D class knows how to paint/fill Shape objects.

Yeah the only thing was that I had to do per-pixel calculations

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.