pgraphics

Using Processing PGraphics in Python Mode?

試著忘記壹切 提交于 2021-02-05 11:42:35
问题 In Processing's Java Mode, you use PGraphics objects by declaring them globally, setting them up with createGraphics() in setup() and then referring to them in draw(). In the Python mode, what to do is not so clear and doesn't seem to be explained by the documentation. You can't declare variables in Python and variables are not automatically global, i.e. if I just say in setup() c = createGraphics(400,400) and then in draw() say c.beginDraw() I get a NameError: global name 'c' is not defined

PGraphics + noSmooth() + alpha = drawing artifacts

|▌冷眼眸甩不掉的悲伤 提交于 2020-02-02 10:59:47
问题 Note: I also asked this question on the Processing forum here. I have this sample code: PGraphics pg; void setup() { size(400, 500); pg = createGraphics(width, height); pg.noSmooth(); pg.beginDraw(); pg.background(0, 0, 255); pg.endDraw(); } void draw() { if (mousePressed) { pg.beginDraw(); pg.stroke(255, 254); pg.point(mouseX, mouseY); pg.endDraw(); } image(pg, 0, 0, width, height); } I would expect this code to show a point wherever the user presses the mouse. Instead, I am only able to see

PGraphics + noSmooth() + alpha = drawing artifacts

五迷三道 提交于 2020-02-02 10:59:32
问题 Note: I also asked this question on the Processing forum here. I have this sample code: PGraphics pg; void setup() { size(400, 500); pg = createGraphics(width, height); pg.noSmooth(); pg.beginDraw(); pg.background(0, 0, 255); pg.endDraw(); } void draw() { if (mousePressed) { pg.beginDraw(); pg.stroke(255, 254); pg.point(mouseX, mouseY); pg.endDraw(); } image(pg, 0, 0, width, height); } I would expect this code to show a point wherever the user presses the mouse. Instead, I am only able to see

PGraphics + noSmooth() + alpha = drawing artifacts

拟墨画扇 提交于 2020-02-02 10:59:11
问题 Note: I also asked this question on the Processing forum here. I have this sample code: PGraphics pg; void setup() { size(400, 500); pg = createGraphics(width, height); pg.noSmooth(); pg.beginDraw(); pg.background(0, 0, 255); pg.endDraw(); } void draw() { if (mousePressed) { pg.beginDraw(); pg.stroke(255, 254); pg.point(mouseX, mouseY); pg.endDraw(); } image(pg, 0, 0, width, height); } I would expect this code to show a point wherever the user presses the mouse. Instead, I am only able to see

PGraphics + noSmooth() + alpha = drawing artifacts

回眸只為那壹抹淺笑 提交于 2020-02-02 10:59:06
问题 Note: I also asked this question on the Processing forum here. I have this sample code: PGraphics pg; void setup() { size(400, 500); pg = createGraphics(width, height); pg.noSmooth(); pg.beginDraw(); pg.background(0, 0, 255); pg.endDraw(); } void draw() { if (mousePressed) { pg.beginDraw(); pg.stroke(255, 254); pg.point(mouseX, mouseY); pg.endDraw(); } image(pg, 0, 0, width, height); } I would expect this code to show a point wherever the user presses the mouse. Instead, I am only able to see

Make PGraphic Object the cursor

我的梦境 提交于 2019-12-24 10:18:16
问题 This is a follow-up of my question: Make the cursor a self-drawn image. I have a paint a picture application. The latest working version can be found here: https://knowledgeablekangaroo.github.io/paint-a-picture-backup/, where the code can be found in F12 > Sources > paint-a-picture.js . The user can choose a color, set the background, set the thickness, shape, and opacity. There is also an eraser functionality. I want there to be a better user experience, so I am trying to draw the eraser