Loading...
Logo
Processing Forum

I'm quite new to the PGraphics thingy, so far everything works fine, but when I want to do more complex tasks within the class, such as (sample code) it simply doesnt display anything

PGraphics canvas;

canvas = new createGraphics(width,height,P2D);     //in setup()

canvas.beginDraw();                                               //in draw()
canvas.beginShape();
//do something with canvas.curveVertex() ...
canvas.endShape();
canvas.endDraw();
image(canvas,0,0,width,height);

As long as I keep using "simple" commands like background(0), everything works fine and is displayed, but shapes simply do not display. Anybody got an idea why this behaves like that?

===========
Capable of English, German, French, Russian and Latin, but simple languages like AS3 or Processing are absolutely killing me!

Replies(2)

It should work, so perhaps you can make a little test sketch to illustrate your issue.
ok, I'm very sorry, wrong description of the issue:
without the createGraphics() there is a sort of circle to be displayed. this worked pretty well, but using this, there are only many points, outlining the circle, not a single line.

This is pretty much what it does:

      canvas.strokeWeight(lineWeight); // is 0.075 by default
      canvas.noFill();
      canvas.beginShape();
      canvas.curveVertex(x[formResolution-1]+centerX, y[formResolution-1]+centerY);  // some points, approxomately forming a circle
      for (int i=0; i<formResolution; i++){
        canvas.curveVertex(x[i]+centerX, y[i]+centerY);
      }
      canvas.curveVertex(x[0]+centerX, y[0]+centerY);
      canvas.curveVertex(x[1]+centerX, y[1]+centerY);
      canvas.endShape();

EDIT: just tried strokeWeight(1) and now there's pretty much of a line, but it would look so much better with 0.075 (it's a sort of painting programm)
Maybe that's because the canvas object is "over" the "normal" stage..? Does anybody have an idea how to solve this issue? strokeWeight(1) is also possible, but it kinda sucks :/

===========
Capable of English, German, French, Russian and Latin, but simple languages like AS3 or Processing are absolutely killing me!