5

I'm relatively new to programming and have a question about drawing to the display. I'm sure this is not specific to Java, but I am learning Java so I will ask it in that context. Here is some context for the question:

From the Wikipedia entry for "Pixel" (emphasis added): "In digital imaging, a pixel ... is the smallest controllable element of a picture represented on the screen."

From the Java API entry for Class "Graphics" (emphasis added): "Operations that draw the outline of a figure operate by traversing an infinitely thin path between pixels with a pixel-sized pen that hangs down and to the right of the anchor point on the path."

My question is:

How is Java able to represent outlines of figures as the space between pixels when a pixel is the smallest controllable element of a display?

Put another way:

0|0

The "0"s above are two pixels. The "|" above is the "infinitely thin path between pixels." If only the "0"s can change, how does Java make the "|" visible to humans? Does it change the color of the edges of the "0"s? (Is that what "pixel-sized pen" means - it colors half of both pixels?)

7
  • This has more to do with the underlying graphics engine then Java. There are many factors which will effect the size of line between two points and any number of algorithms that might be used, you also have to consider if antialiasing is enabled or not as this can introduce "particular" filled pixels (translucent). On a whole, the question is quite broad and relates more to general graphics then Java Commented May 28, 2015 at 22:05
  • Thanks, but this question isn't about the size of a line between two points. It's a question about how it is possible for a line to appear on the screen in the first place when it centers on space "between" the only medium (pixels) for showing images on the screen.
    – ryanwc
    Commented May 28, 2015 at 22:13
  • As a pixel is "the smallest controllable element of a picture" coloring the edges or a half of a pixel is impossible as then those would be the smallest "controllable element". A pixel must take on a single specific value, usually made up of three 8-bit values -- one each for red, green, and blue. As @MadProgrammer mentioned, antialiasing and font-smoothing may alter the actual on-screen values from what the program sent but in the end that physical pixel has exactly one state. Commented May 28, 2015 at 22:13
  • That "infinitely thin" line is simply used to break the tie when the algorithm needs to choose which pixel to color. It's an imaginary line. Commented May 28, 2015 at 22:14
  • 2
    OK. I think I get it - I was misreading the API. The pixel-size pen hangs down and to the right of that imaginary line - it does not traverse the line. That was my misunderstanding. Thank you.
    – ryanwc
    Commented May 28, 2015 at 22:29

1 Answer 1

6

that hangs down and to the right of the anchor point on the path

The pen will draw the right 0.

1
  • @WilliamPrice: Oops; fixed.
    – SLaks
    Commented May 28, 2015 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.