Main graphics and rendering context, as well as the base API implementation for processing "core". Use this class if you need to draw into an off-screen graphics buffer. A PGraphics object can be constructed with the createGraphics() function. The beginDraw() and endDraw() metho
| 152 | * @see PApplet#createGraphics(int, int, String) |
| 153 | */ |
| 154 | public class PGraphics extends PImage implements PConstants { |
| 155 | |
| 156 | /** width * height (useful for many calculations) */ |
| 157 | @SuppressWarnings("unused") |
| 158 | public int pixelCount; |
| 159 | |
| 160 | /** the anti-aliasing level for renderers that support it */ |
| 161 | public int smooth; |
| 162 | |
| 163 | |
| 164 | // ........................................................ |
| 165 | |
| 166 | /** true if defaults() has been called a first time */ |
| 167 | protected boolean settingsInited; |
| 168 | |
| 169 | /** true if settings should be re-applied on next beginDraw() */ |
| 170 | protected boolean reapplySettings; |
| 171 | |
| 172 | /** set to a PGraphics object being used inside a beginRaw/endRaw() block */ |
| 173 | protected PGraphics raw; |
| 174 | |
| 175 | // ........................................................ |
| 176 | |
| 177 | /** path to the file being saved for this renderer (if any) */ |
| 178 | protected String path; |
| 179 | |
| 180 | /** |
| 181 | * True if this is the main graphics context for a sketch. |
| 182 | * False for offscreen buffers retrieved via createGraphics(). |
| 183 | */ |
| 184 | protected boolean primaryGraphics; |
| 185 | |
| 186 | |
| 187 | // ........................................................ |
| 188 | |
| 189 | /** |
| 190 | * Array of hint[] items. These are hacks to get around various |
| 191 | * temporary workarounds inside the environment. |
| 192 | * <p/> |
| 193 | * Note that this array cannot be static, as a hint() may result in a |
| 194 | * runtime change specific to a renderer. For instance, calling |
| 195 | * hint(DISABLE_DEPTH_TEST) has to call glDisable() right away on an |
| 196 | * instance of PGraphicsOpenGL. |
| 197 | * <p/> |
| 198 | * The hints[] array is allocated early on because it might |
| 199 | * be used inside beginDraw(), allocate(), etc. |
| 200 | */ |
| 201 | protected boolean[] hints = new boolean[HINT_COUNT]; |
| 202 | |
| 203 | // ........................................................ |
| 204 | |
| 205 | /** |
| 206 | * Storage for renderer-specific image data. In 1.x, renderers wrote cache |
| 207 | * data into the image object. In 2.x, the renderer has a weak-referenced |
| 208 | * map that points at any of the images it has worked on already. When the |
| 209 | * images go out of scope, they will be properly garbage collected. |
| 210 | */ |
| 211 | protected WeakHashMap<PImage, Object> cacheMap = |