I have been using processing again after sometime and I don’t understand why images are so pixelated. I am using processing 4.4.4 in Java mode in my pc and all the sketches are really pixelated, it doesn’t matter if a have 2 code lines or 200. How can I get clear images, please?
//Try these one at a time:
//size (250, 250); // This is default and the same as size (500, 500, JAVA2D);
size(250, 250, P2D);
background(255);
strokeWeight(3);
triangle(250/2, 100/2,
100/2, 400/2,
400/2, 400/2);
save("image.png");
import java.awt.*;
// Gets windows scaling and prints it:
float ws = (float) java.awt.GraphicsEnvironment
.getLocalGraphicsEnvironment().
getDefaultScreenDevice().
getDefaultConfiguration().
getDefaultTransform().
getScaleX();
println("Windows scaling:", ws);
// Displays the displayDensity of your monitor:
int pd = displayDensity();
println("Pixel Density:", pd);
I have Windows scaling of 1.25x (I set this!) on my PC and my sketch window is scaled up by 1.25x with JAVA2D which is the default:
size (500, 500);
Scaling up by 1.25x also scales up the jaggies that you are seeing.
P2D/P3D with and without smooth doesn’t solve pixelation and neither does pixelDensity. So, as I feared, processing now produces less sharp images - isn’t there an earlier version of the code that produces less pixelated images? I could have sworn that with earlier versions of processing you got sharp images automatically.
Pixels on most modern day LCD monitors are square.
Angled lines in digital graphics often show pixelation because of the square nature of screen pixels.
Smoothing can help reduce the jagged appearance by blending colors at the edges but it doesn’t fully eliminate pixelation.
Look up anti-aliasing to help better understand this.
I have scaling on my Windows 10 set to 1.25x and it will make my sketches look works in JAVA2D because they are scaled up by Windows.
The P2D sketches are not scaled up.
If you zoom into an image as you have done you will see the pixels and the smoothing!
Keep in mind that Windows (and other OSes) also do smoothing of the image and the final image on the screen is the end result of these.