Py5Graphics.pixel_width

Contents

Py5Graphics.pixel_width#

Width of the Py5Graphics drawing surface in pixels.

Description#

Width of the Py5Graphics drawing surface in pixels. When pixel_density(2) was used in settings() to make use of a high resolution display (called a Retina display on macOS or high-dpi on Windows and Linux), the width and height of the Py5Graphics drawing surface does not change, but the number of pixels is doubled. As a result, all operations that use pixels (like Py5Graphics.load_pixels(), Py5Graphics.get_pixels(), etc.) happen in this doubled space. As a convenience, the variables pixel_width and Py5Graphics.pixel_height hold the actual width and height of the drawing surface in pixels. This is useful for any Py5Graphics objects that use the Py5Graphics.pixels[] or Py5Graphics.np_pixels[] arrays, for instance, because the number of elements in each array will be pixel_width*pixel_height, not width*height.

This field is the same as pixel_width but linked to a Py5Graphics object. To see example code for how it can be used, see pixel_width.

Underlying Processing field: PGraphics.pixelWidth

Updated on December 27, 2023 13:47:02pm UTC