<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with creategraphics() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=creategraphics%28%29</link>
      <pubDate>Sun, 08 Aug 2021 14:52:42 +0000</pubDate>
         <description>Tagged with creategraphics() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedcreategraphics%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>I may be dumb, but... how come this pgraphics image is cut off?</title>
      <link>https://forum.processing.org/two/discussion/28100/i-may-be-dumb-but-how-come-this-pgraphics-image-is-cut-off</link>
      <pubDate>Sun, 19 Aug 2018 06:53:47 +0000</pubDate>
      <dc:creator>Tsskyx</dc:creator>
      <guid isPermaLink="false">28100@/two/discussions</guid>
      <description><![CDATA[<pre><code>PGraphics p;
void setup() {
  size(600, 600);
  p = createGraphics(600, 600);
  p.beginDraw();
  p.rectMode(CENTER);
  translate(width/2, height/2);
  p.rect(0, 0, 50, 50);
  p.endDraw();
  image(p, 0, 0);
}
</code></pre>

<p>I have just begun and I'm already stuck :/</p>
]]></description>
   </item>
   <item>
      <title>Video Delay : Ed Tannenbaum, Recollections</title>
      <link>https://forum.processing.org/two/discussion/28108/video-delay-ed-tannenbaum-recollections</link>
      <pubDate>Thu, 30 Aug 2018 22:14:13 +0000</pubDate>
      <dc:creator>Adrien</dc:creator>
      <guid isPermaLink="false">28108@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I try to create something like this :<a rel="nofollow" href="https://www.youtube.com/watch?v=YBKkVpRxUfs"> https://www.youtube.com/watch?v=YBKkVpRxUfs</a>, using a kinect.
At the moment I made some test with something like this :</p>

<pre><code>class User {
  PGraphics pgBodyBg; 
  PImage bodyImg; 
  float colorIndexCounter; 
  int id; 
  ArrayList&lt;DelayImg&gt; bodyImageList = new ArrayList&lt;DelayImg&gt;();
  PGraphics pgTotal; 
  DelayImg[] buffer;

  User(int i) {
    colorIndexCounter=random(10); 
    pgTotal=createGraphics(512, 424);  
    pgTotal.beginDraw(); 
    pgTotal.background(0, 0); 
    pgTotal.endDraw(); 
    buffer=new DelayImg[50];
  }


  void delayEffect() {
    fillBuffer(); 
    changeColor(); 
    display();
  }

  void fillBuffer() {
    PImage bi= bodyImg.copy(); 
    DelayImg di=new DelayImg(bi); 
    for (int i = buffer.length-1; i &gt; 0; i--) {
      buffer[i] = buffer[i-1];
    }
    buffer[0]=di;
  }



  void changeColor() {
    pgTotal.beginDraw(); 
    pgTotal.clear(); 
    pgTotal.pushStyle(); 
    for (int j=buffer.length-1; j&gt;=0; j--) { 
      if (buffer[j]!=null) buffer[j].changeColor(pgTotal);
    }
    pgTotal.popStyle();
    pgTotal.endDraw();
  }

  void display() {
    image(pgTotal, 0, 0);
  }
}



class DelayImg {
  PImage img; 
  float alf=255; 
  PShape shape; 
  PGraphics pgBg; 
  int partSize=200; 
  DelayImg(PImage _img) {
    img=_img; 
    img.filter(THRESHOLD); 
    pgBg=createGraphics(512, 424);
  }

  void display(PGraphics pg) {
    pg.tint(255, alf); 
    pg.image(img, 0, 0); 
    if (alf&gt;0)alf-=0.5;
    else alf=0;
  }

  void changeColor(PGraphics pg) {
    pgBg.beginDraw(); 
    pgBg.background(random(255), random(255), random(255));  
     pgBg.mask(img);
    pgBg.endDraw();
    pg.image(pgBg, 0, 0);
  }
}
</code></pre>

<p>bodyImg is update each frame, coming from kinect.</p>

<p>I want to be able to change the color everytime, that why pgTotal is clear every frame and display fresh new images, but the way I do it is very slow (10 fps).
Do you have any suggestion, different kind of algorithm to improve frameRate? I try to use some vertex and textures aswell, but no real improvement...</p>

<p>Thanks for your help!</p>

<p>A.</p>
]]></description>
   </item>
   <item>
      <title>masking PGraphics with PGraphics creates background where it's supposed to be transparent</title>
      <link>https://forum.processing.org/two/discussion/28035/masking-pgraphics-with-pgraphics-creates-background-where-it-s-supposed-to-be-transparent</link>
      <pubDate>Fri, 01 Jun 2018 07:03:40 +0000</pubDate>
      <dc:creator>dehyde</dc:creator>
      <guid isPermaLink="false">28035@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to mask one PGraphics (that has text) with another (shape) and show the masked text over the "regular" canvas that's showing images.</p>

<p>The masked area becomes entirely opaque (the black rect). 
I would have used blending mode but I'm not using 100% white or black text.</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/436/W8WW577PT1Z7.png" alt="Screen Shot 2018-06-01 at 10.01.30" title="Screen Shot 2018-06-01 at 10.01.30" /></p>

<p>I've looked here:
<a href="https://forum.processing.org/two/discussion/23886/masking-a-shape-with-another-shape" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/23886/masking-a-shape-with-another-shape</a></p>

<p>but I see that also that has similar behavior.</p>

<hr />

<p>here's the masked pgraphics:</p>

<pre><code>mask = createGraphics(width, height);
pg = createGraphics(width, height);
for (int x=0; x&lt; labels.length/2; x++){
pg.beginDraw();
pg.fill(0,0,255);
pg.text("#"+labels[x].labelText.toUpperCase(), labels[x].xLoc, labels[x].yLoc);
pg.endDraw();
}
</code></pre>

<p>here's the code for the masking:</p>

<pre><code>  mask.beginDraw();
  mask.clear();
  mask.fill(255);
  mask.noStroke();
  mask.rect(random(0,width/2), random(0,height/2), random(width/2, width), random(height/2, height));
  mask.endDraw();
  pg.mask(mask);
  image(pg, 0, 0);
</code></pre>
]]></description>
   </item>
   <item>
      <title>OpenSansEmoji.ttf not working in P3D?</title>
      <link>https://forum.processing.org/two/discussion/27835/opensansemoji-ttf-not-working-in-p3d</link>
      <pubDate>Mon, 23 Apr 2018 23:36:07 +0000</pubDate>
      <dc:creator>sjespers</dc:creator>
      <guid isPermaLink="false">27835@/two/discussions</guid>
      <description><![CDATA[<p>So this has been driving me nuts all day. I was using OpenSansEmoji.ttf in a project and the emojis weren't showing up. Fast forward 6 hours later... I couldn't figure out why it was working in another test project until I saw that my main project needs the P3D in order to be able to use Syphon. My test project was not using the P3D renderer and it works there.</p>

<p>So now that I figured out why it wouldn't work, does anyone have any ideas on how to use this font AND Syphon? Or why this font won't render the emojis in P3D?</p>
]]></description>
   </item>
   <item>
      <title>Can i create a mask from a shape??</title>
      <link>https://forum.processing.org/two/discussion/27757/can-i-create-a-mask-from-a-shape</link>
      <pubDate>Fri, 13 Apr 2018 17:54:32 +0000</pubDate>
      <dc:creator>RafaelAzevedo</dc:creator>
      <guid isPermaLink="false">27757@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>Can i create a mask from a shape (in this case an ellipse) and change background color but keep the mask untouched?
This ellipse would have its size changed according to the screen and i would have a function windowResized()</p>

<p><img src="https://i.imgur.com/qxNRnXB.jpg" alt="image" /></p>

<p>Thanks! :)</p>
]]></description>
   </item>
   <item>
      <title>using PGraphics</title>
      <link>https://forum.processing.org/two/discussion/27734/using-pgraphics</link>
      <pubDate>Tue, 10 Apr 2018 11:31:13 +0000</pubDate>
      <dc:creator>james0411</dc:creator>
      <guid isPermaLink="false">27734@/two/discussions</guid>
      <description><![CDATA[<p>Hi there, I have problems with my code. what I want to do is tracking color pixel. I want to capture an image with the only traced color(without background video). so I used PGraphics, but It is so slow that the program can't track color well. I think using PGraphics makes the program slow. 
is there any advice to make tracking faster?</p>

<p>Here is my code.</p>

<pre><code>import processing.video.*;

Capture video;

color trackColor= color(145,43,54);
float threshold = 25;
PGraphics topLayer;


float distSq(float x1, float y1, float z1, float x2, float y2, float z2) {
  float d = (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) +(z2-z1)*(z2-z1);
  return d;
}

void setup() {
  frameRate(60);
  size(640, 360);
  String[] cameras = Capture.list();
  printArray(cameras);
  video = new Capture(this, cameras[3]);
  video.start();
  trackColor = color(145,43,54);
  topLayer = createGraphics(width, height, g.getClass().getName());
}

void captureEvent(Capture video) {
  video.read();
}

void draw() {

  video.loadPixels();
  image(video, 0, 0);

  //threshold = map(mouseX, 0, width, 0, 100);
  threshold = 50;

  int avgX = 0;
  int avgY = 0;
  float worldRecord = 0;

  // Begin loop to walk through every pixel
  for (int x = 0; x &lt; video.width; x++ ) {
    for (int y = 0; y &lt; video.height; y++ ) {
      int loc = x + y * video.width;
      // What is current color
      color currentColor = video.pixels[loc];
      float r1 = red(currentColor);
      float g1 = green(currentColor);
      float b1 = blue(currentColor);
      float r2 = red(trackColor);
      float g2 = green(trackColor);
      float b2 = blue(trackColor);
      //
      float d = distSq(r1, g1, b1, r2, g2, b2); 
      if (d &lt; threshold*threshold) {
        worldRecord = d;
        avgX = x;
        avgY = y;
    }
  }
 }
   topLayer.beginDraw();
  topLayer.stroke(trackColor);
  if (worldRecord &lt; threshold*threshold) {
    topLayer.fill(trackColor);
    topLayer.strokeWeight(1);
    topLayer.point(avgX, avgY); ////////////////////////////////////////
  }
  topLayer.endDraw();
    image(topLayer, 0, 0);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>PGraphics clear() method?</title>
      <link>https://forum.processing.org/two/discussion/26993/pgraphics-clear-method</link>
      <pubDate>Thu, 22 Mar 2018 18:04:44 +0000</pubDate>
      <dc:creator>marzinp</dc:creator>
      <guid isPermaLink="false">26993@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I have problems clearing a PGraphics layer. Using Java mode, it works perfect, no more with Android mode. I've tried clear(), background(0,0), none works...
The only way I found is to recreate the layer... Why is that?</p>

<p>My code, trimmed down to this problem, is like:</p>

<pre><code>        PGraphics layer;
        //only debug version works
        boolean debug=true;
        void setup() {
          size(800, 800);
          layer=createGraphics(width, height);
          layer.beginDraw();
          layer.background(0, 0);
          layer.endDraw();
        }
        void draw() {
          background(128);
          layer.beginDraw();
          layer.ellipse(mouseX, mouseY, 50, 50);
          layer.endDraw();
          image(layer, 0, 0);
        }
        void mousePressed() {
          if (debug) {
            layer=createGraphics(width, height);
            layer.beginDraw();
            layer.background(0, 0);
            layer.endDraw();
          } else {
            layer.beginDraw();
            layer.clear();
            layer.endDraw();
          }
        }
</code></pre>

<p>Thanks for your answer.</p>
]]></description>
   </item>
   <item>
      <title>Functions in Graphics Object</title>
      <link>https://forum.processing.org/two/discussion/27465/functions-in-graphics-object</link>
      <pubDate>Wed, 28 Mar 2018 17:53:12 +0000</pubDate>
      <dc:creator>Okaghana</dc:creator>
      <guid isPermaLink="false">27465@/two/discussions</guid>
      <description><![CDATA[<p>Hello Folks:</p>

<p>Have a look at the  following code:
    var element</p>

<pre><code>function drawarectangle(x, y, w, h){
  rect(x, y, w, h);
}

function setup() {
  createCanvas(500, 500);
  background(0);

  element = createGraphics(400,400);
  element.background(100);
  element.fill(255);
  element.drawarectangle(100,100,200,200);
}

function draw() {
  image(element, 50, 50);
}
</code></pre>

<p>ok. so basically i want to call a function inside a Graphics Object. For the sake of the easiness I wrote a completely useless function call "drawarectagle" and I want to call this function inside the graphics object "element". How can I do this, because I cant just say  <code>element.drawarectangle(100,100,200,200);</code>?</p>
]]></description>
   </item>
   <item>
      <title>PGraphics.image() not displayed with noSmooth() and P2D?</title>
      <link>https://forum.processing.org/two/discussion/25676/pgraphics-image-not-displayed-with-nosmooth-and-p2d</link>
      <pubDate>Fri, 22 Dec 2017 05:10:48 +0000</pubDate>
      <dc:creator>brontosplachna</dc:creator>
      <guid isPermaLink="false">25676@/two/discussions</guid>
      <description><![CDATA[<p>When running this sketch, press any key to cause the PGraphics to be displayed.  When P2D and noSmooth() are used, the PGraphics is displayed only momentarily.  Is there a logical reason for this?</p>

<pre><code>PGraphics pg1;

void setup() {
  size(640, 480, P2D); // remove P2D's to allow pg1 to be displayed
  noSmooth(); // or remove this to allow pg1 to be displayed
  background(0);
  fill(0, 255, 0);
  rect(0, 0, 100, 200);

  pg1 = createGraphics(width, height, P2D);
  pg1.noSmooth();
  pg1.beginDraw();
  pg1.background(255);
  pg1.fill(0);
  pg1.rect(100, 100, 100, 50);
  pg1.endDraw();
}

void draw() {
}

void keyPressed() { 
  background(0);
  image(pg1, 0, 0, width, height);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I create a new PGraphics without having access to an existing PGraphics?</title>
      <link>https://forum.processing.org/two/discussion/26471/how-can-i-create-a-new-pgraphics-without-having-access-to-an-existing-pgraphics</link>
      <pubDate>Wed, 21 Feb 2018 21:37:37 +0000</pubDate>
      <dc:creator>MadEmperorYuri</dc:creator>
      <guid isPermaLink="false">26471@/two/discussions</guid>
      <description><![CDATA[<p>According to <a href="https://processing.org/reference/PGraphics.html" target="_blank" rel="nofollow">https://processing.org/reference/PGraphics.html</a>:</p>

<blockquote class="Quote">
  <p>To create a new graphics context, use the <code>createGraphics()</code> function. Do not use the syntax <code>new PGraphics()</code>.</p>
</blockquote>

<p>I have a place in my code where I need to create a <code>PGraphics</code>, but it is not in a place where I have access to an existing <code>PGraphics</code> on which to call <code>createGraphics()</code>. What can I do?</p>
]]></description>
   </item>
   <item>
      <title>Is it possible to do a rotation animation with image masks?</title>
      <link>https://forum.processing.org/two/discussion/26164/is-it-possible-to-do-a-rotation-animation-with-image-masks</link>
      <pubDate>Mon, 29 Jan 2018 16:11:58 +0000</pubDate>
      <dc:creator>jshaw3</dc:creator>
      <guid isPermaLink="false">26164@/two/discussions</guid>
      <description><![CDATA[<p>Hey all,</p>

<p>I was looking at doing some image animation and transitions with image masks. The effect I'm working towards is having an image mask rotate depending on where a user's mouse is positioned around the border of a circle. So as the user moves their mouse around the circle's border the image mask rotates revealing a previously covered part of the bottom image. To do this, the image mask would need to be able to rotate dynamically based on the user's interactions with the sketch. Being able to rotate the image mask would prevent having to create a mask for every possible angle of the circle.</p>

<p>From what I could find, there wasn't a way to rotate or transform an image mask before it is applied to an image in a P5.js sketch. <strong>Is this possible with the current p5.js library?</strong></p>

<p>Referencing the <a rel="nofollow" href="https://p5js.org/reference/#/p5.Image/mask">image mask example from the documentation</a> is there a solution to rotate the preloaded image before you apply it to the image?</p>

<pre lang="javascript">
var photo, maskImage;
function preload() {
    photo = loadImage('assets/rockies.jpg');
    maskImage = loadImage('assets/mask2.png');
}
    
function setup() {
    createCanvas(100, 100);
    photo.mask(maskImage);
    image(photo, 0, 0);
}
</pre>

<p>Would be something like the following sudo code...</p>

<pre lang="javascript">
var photo, maskImage;
function preload() {
    photo = loadImage('assets/rockies.jpg');
    maskImage = loadImage('assets/mask2.png');
}
    
function setup() {
    createCanvas(100, 100);
    // SUDO CODE:
    // =======
    // Rotate the maskImage 90degrees via rotate(PI/2.0);
    // Apply the newly rotated mask to the image
    // END OF SUDO Code
    // =======
    photo.mask(maskImage);
    image(photo, 0, 0);
}
</pre>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>add touch listener to creategraphics</title>
      <link>https://forum.processing.org/two/discussion/26162/add-touch-listener-to-creategraphics</link>
      <pubDate>Mon, 29 Jan 2018 12:53:35 +0000</pubDate>
      <dc:creator>nevahid</dc:creator>
      <guid isPermaLink="false">26162@/two/discussions</guid>
      <description><![CDATA[<p>hi people... i can't add any kind of listeners to a p5.graphics object which is created using creategraphics().... any idea? any solution?</p>
]]></description>
   </item>
   <item>
      <title>p3d renderer and RTL languages</title>
      <link>https://forum.processing.org/two/discussion/18311/p3d-renderer-and-rtl-languages</link>
      <pubDate>Tue, 27 Sep 2016 15:07:18 +0000</pubDate>
      <dc:creator>nevahid</dc:creator>
      <guid isPermaLink="false">18311@/two/discussions</guid>
      <description><![CDATA[<p>hi people all...
i'm using processing 3. i tried to load a font to write persian texts in text() function... if i set the renderer to p2d or default renderer, everything works fine and words are shown correctly. but if i choose p3d renderer, letters are written seperated (because for persian and arabic language, some letters stick together and form new curves).
any idea how to write persian (or arabic) letters with p3d renderers?</p>
]]></description>
   </item>
   <item>
      <title>How to draw a rect() in a Thread</title>
      <link>https://forum.processing.org/two/discussion/25799/how-to-draw-a-rect-in-a-thread</link>
      <pubDate>Wed, 03 Jan 2018 11:41:45 +0000</pubDate>
      <dc:creator>Geist5000</dc:creator>
      <guid isPermaLink="false">25799@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I am trying to draw a rectangle in the window from a Thread.</p>

<p><code>void setup(){
  size(100,100);
  T thread = new T();
  thread.start();
}
class T extends Thread{
  void run(){
    rect(10,10,10,10);
  }
}</code></p>

<p>But this didn't work. I hobe someone can help me?</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>create a shape with an array of vertices</title>
      <link>https://forum.processing.org/two/discussion/25027/create-a-shape-with-an-array-of-vertices</link>
      <pubDate>Wed, 15 Nov 2017 20:18:29 +0000</pubDate>
      <dc:creator>guyshalev</dc:creator>
      <guid isPermaLink="false">25027@/two/discussions</guid>
      <description><![CDATA[<p>hello,
i am trying to create a shape with an array of pre-made vertices. here is the code:</p>

<pre><code>function setup() {
  createCanvas(600, 600);
  background(150);    
}

function createVertices() {
  let vertices = [];
  let angle = TWO_PI / 6;
  for (let a = 0; a &lt; TWO_PI; a += angle) {
    var sx = 50 + cos(a) * 20;
    var sy = 50 + sin(a) * 20;
    vertices.push(vertex(sx, sy));
  }
  return vertices;
}

function draw() {
  var verticesArray = createVertices();
  polygon(50, 50, 20, verticesArray);
}

function polygon(x, y, radius, ver) {
  beginShape();
  let vertices = [];
  for (var i = 0; i &lt; ver.length - 1; i++) {
    vertices.push(vertex(ver[i], ver[i + 1]));
  }
  endShape(CLOSE);
}
</code></pre>

<p>function polygon() doesn't draw a hexagon in this way, but only if i copy the code in createVertices() function.
what is the problem?</p>
]]></description>
   </item>
   <item>
      <title>How to integrate a p5 canvas in an interactive map</title>
      <link>https://forum.processing.org/two/discussion/24594/how-to-integrate-a-p5-canvas-in-an-interactive-map</link>
      <pubDate>Tue, 17 Oct 2017 07:01:55 +0000</pubDate>
      <dc:creator>grab06</dc:creator>
      <guid isPermaLink="false">24594@/two/discussions</guid>
      <description><![CDATA[<p>hello,</p>

<p>I'm developping a personnal project around the "concept of" interactive map.</p>

<p>On this interactive map, I would like to gather as many as possible of information related to one specific thematic.</p>

<p>I mean, I will represent static information (markers, geographical forms ...) and dynamic information (pathes, animations ...). The dynamic information and animations are scheduled according to a global timer (day by day, hour by hour ...). I may have several tens of thousand information per map ...</p>

<p>I've started prototyping the project using <strong>leaflet</strong> and some of its addons. Leaflet uses the concept of layers to manage different level of information or interactions with the user.</p>

<p>One of these addons is <strong>canvasLayer.js</strong> that I use for the dynamic part of the project. I can add a canvas layer to the interactive map and draw on this canvas. Being integrated to the leaflet map, this canvas layer is automatically managed when resizing, moving, spanning and managing the user interaction. But, to me, I suffer from a lack of algorithms for drawing all kinds of dynamic objects and then I have to implement most of them by myself ...</p>

<p>On the other hand , <strong>p5.js</strong> offers a huge amount of animation of all kinds (steering behavior, ...) that I would like to integrate in my interactive map.</p>

<p>Now I'm at the point to ask my questions:</p>

<p><em>Is it feasible to integrate the p5.js library in a leaflet interactive map? if yes ... how to do that?</em></p>

<p>I could replace leaflet by mapbox, as long as I keep the concept of interactive map.</p>

<p>I'm open to any discussion about different approach in order to reach the same goal.</p>

<p>Could you help me please?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>How do I display shapes in P3D like on a HUD?</title>
      <link>https://forum.processing.org/two/discussion/22365/how-do-i-display-shapes-in-p3d-like-on-a-hud</link>
      <pubDate>Wed, 03 May 2017 15:01:20 +0000</pubDate>
      <dc:creator>theliquu69</dc:creator>
      <guid isPermaLink="false">22365@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make an experimental level editor in Processing, and I want to display a level mini-map using points while playing the level. I can't get it to work, because the points appear in 3D space rather than 2D. How do I make them appear in 2D? I tried the old methods but none of them works (can't clear the zbuffer as it doesn't exist as a variable, etc.)</p>
]]></description>
   </item>
   <item>
      <title>Blur filter not working on image in createGraphics image... says: Cannot read property 'getContext'</title>
      <link>https://forum.processing.org/two/discussion/24421/blur-filter-not-working-on-image-in-creategraphics-image-says-cannot-read-property-getcontext</link>
      <pubDate>Fri, 06 Oct 2017 21:38:11 +0000</pubDate>
      <dc:creator>giorgiomartini</dc:creator>
      <guid isPermaLink="false">24421@/two/discussions</guid>
      <description><![CDATA[<p>Hi..</p>

<p>I have a main canvas where i have text..</p>

<p>I want to add a drop shadow to this text... So i created a createGraphics image.. where i paint the same text</p>

<p>In this new createGraphics image i want to add a blur.. and then copy this blured image to my main canvas....</p>

<p>But when i try to apply the blur.. i get this error:</p>

<p>** Cannot read property 'getContext' of undefined**</p>

<p>In this sketch in line 75.. if you uncomment thte line where i add the blur.. it get the error.. : <a href="https://codepen.io/giorgiomartini/pen/LzQeGQ?editors=0010" target="_blank" rel="nofollow">https://codepen.io/giorgiomartini/pen/LzQeGQ?editors=0010</a></p>

<p>Any idea what is the problem?</p>
]]></description>
   </item>
   <item>
      <title>Soooo many problems... (images, masking, apde)</title>
      <link>https://forum.processing.org/two/discussion/24007/soooo-many-problems-images-masking-apde</link>
      <pubDate>Sat, 02 Sep 2017 15:40:08 +0000</pubDate>
      <dc:creator>Mad</dc:creator>
      <guid isPermaLink="false">24007@/two/discussions</guid>
      <description><![CDATA[<p>So. New forum. First post. Frustrated.</p>

<p>I don't claim to write clean code, but I try to make it readable. I started programming somewhere in the 80s, in BASIC, then in C, C++, whatever. I love global variables, I can do Object Oriented. I was looking for a way to program in Java directly on Android, with the result being an APK. So I came to Processing. Hm. I would have made APDE as some kind of dual-mode tool chain, where one mode is the basic "Go and write processing" and the other mode as "programm natively, use P as import, do your own main without overriding", but that's just me and outside the scope of what I'm trying to do here.</p>

<p>First I went ahead and grabbed me android's sensors just to see if I could. I made my own sensor class, grabbed temperature from the battery manager, made another class (batman), registered some callbacks, put them on screen, added a background. Worked.</p>

<p>I started grabbing touch input as mouse input, worked just fine. Wanted to text() on a PGraphics to help debug. Easy-peasy. Make a PGraphics, text in, display it by image(..), clear() it, text in, display, clear, rinse, repeat.
Huh. What's that? the text overwrites and overwrites and overwrites (I was grabbing touch position, fingerdown, fingerup, worked like a charm.) but wasn't clearing. I wanted to re-use the PGraphics with clear() because creating a new one 30x per second is not the way to go, right? But no, clear() does nothing but put a new "backround" on top, full black, fully transparent. On top. Yeah, you read that right. Took me 4 hours of my life and diving into Processing on github. (censored). By the way, whenever someone on github or here found some problem with clear() and pgraphics, the comments are a hoot. Yeah, I can reproduce it. No, I will not loop over 300,000 pixels to reset them 30 times a second, thanks for recommending. Even the clear() example right in the procesing reference (modified to draw on touch, clear on finger-up) does not work on Android. Let me repeat that: IT DOES NOT WORK. Want a (censored) video?</p>

<p>Next, with a lightsensor running, I wanted to build some photographer's helper. Some overlaying rotating discs, aperture, shutter speed, a draggable ISO selector... Let's start with a disc. Made me some nice square metal plate, read some more. Either I take it and mask it with something round to get a disc, or I apply it as a texture onto a circle.
Since my first hour trying to texture(...) resp. setTexture(...) somehow failed to bring results, and I saw that masking was the obviously preferred way to go in the forum, I went down that rabbithole.</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/347/YUNCXAQFPVB1.png" alt="Screenshot_2017-09-02-17-10-38" title="Screenshot_2017-09-02-17-10-38" /></p>

<p>Want some code? You get some code.</p>

<pre>
import android.os.Bundle;
import android.os.Build;
import android.app.Activity;
import android.content.Context;
import android.view.WindowManager;
import android.view.Display;

Activity activity;
Context context;
Display display;

int rotation;
String rotString;
String orientation;
float aspectRatio;

int canvasX;
int canvasY;
int fontSizeNormal = 5;
int colWidth;
int rowHeight;
int rows;
int cols;
int gridUnitX;
int gridUnitY;

float fScale;
int iScale;

int i;
int loopcount = 0;

PGraphics backgroundG;
PGraphics maskG;
PGraphics balouG;
PGraphics balouMaskedG;
PGraphics testG;
PGraphics jerkG;

PImage bgIMG;
PImage testIMG;
PImage balouIMG;
PImage balouorigIMG;
PImage cJerkIMG;

public void setup() {
  //fullScreen();

  //orientation(PORTRAIT);

  size(displayWidth, displayHeight, P2D);
  frameRate(30);
  
  background(0,0,0);
  
  canvasX = displayWidth;
  canvasY = displayHeight;
  activity = this.getActivity();
  context = activity.getApplicationContext();

  display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); 
  
  fontSizeNormal = int(float(canvasX)/18);
  rows = 2; cols = 3;
  gridUnitX = int(float(canvasX) / 11);
  gridUnitY = int(float(canvasY) / 14);

  fScale = canvasX / 1000;
  iScale = int(fScale);
  
  backgroundG = createGraphics(canvasX, canvasY);
  bgIMG = loadImage("background.jpg");
  while (bgIMG.width == 0) { delay(100); }
  backgroundG.beginDraw();
  backgroundG.image(bgIMG,0,0,canvasX, canvasY);  // fit to canvas on-the-fly
  backgroundG.endDraw();

  image(backgroundG,0,0);  // let's get this out of the way


  balouG = createGraphics(300, 300);
  balouorigIMG = loadImage("balou.jpg");
  while (balouorigIMG.width == 0) { delay(100); }
  balouorigIMG.resize(300,300);  // resize it
  balouG.beginDraw();
  balouG.image(balouorigIMG,0,0);  // and put it in the upper left corner of PGraphics balouG
  balouG.endDraw();

  maskG = createGraphics(300,300);
  maskG.beginDraw();
  maskG.ellipse(150, 150, 300, 300);  // nice white circle
  maskG.endDraw();

  balouMaskedG = createGraphics(300, 300);
  balouIMG = loadImage("balou.jpg");
  while (balouIMG.width == 0) { delay(100); }
  balouIMG.resize(300,300);           // if I don't resize here, 
  balouIMG.mask(maskG);               // I get an error that the mask doesn't fit the image
  balouMaskedG.beginDraw();           // so something happens in resize(int, int)
  balouMaskedG.image(balouIMG,0,0);   // but what?!?
  balouMaskedG.endDraw();

  // and just for the heck of it:
  balouMaskedG.clear();       // outside a beginDraw/endDraw
  balouMaskedG.beginDraw();
  balouMaskedG.clear();       // inside a beginDraw/endDraw
  balouMaskedG.endDraw();
  // at least one of those should return balouMaskedG to a completely transparent state.
  // if you check the Processing -&gt; Android port's source, you should immediately see why that fails.

  testG = createGraphics(300, 300);
  testIMG = loadImage("balou.jpg");
  while (testIMG.width == 0) { delay(100); }
  testG.beginDraw();
  testG.image(testIMG,0,0,300,300);  // fit to 300x300 canvas
  testG.endDraw();

  // Afterthought: 
  testIMG.resize(300,300);   // should work just fine, right?

  jerkG = createGraphics(300, 300);
  cJerkIMG = loadImage("balou.jpg");
  while (cJerkIMG.width == 0) { delay(100); }
  cJerkIMG.resize(300,300);  // resize it
  jerkG.beginDraw();
  jerkG.image(cJerkIMG,0,0);  // and put it in the upper left corner of PGraphics
  cJerkIMG.mask(maskG);
  jerkG.image(cJerkIMG,50,50);  // and NOT put it in the upper left corner of PGraphics
  jerkG.clear(); // does nothing
  jerkG.endDraw();
  jerkG.clear(); // still does nothing

  loop();
}


public void draw() {
  textSize(15);
  fill(200,200,200);

  background(0);          // black is beautiful

  image(backgroundG,0,0);  // nicely stretched background
  text("Background fit to canvas on-the-fly",0,20);

  image(maskG,25,25);   // white circle
  text("Mask",25,50);

  image(balouG,350,25); // nicely resized PGraphics
  text("resized and\nput into PGraphics",350,50);

  image(testG,675,25);  // nicely resized PGraphics
  text("on-the-fly-resize while\nput into PGraphics",50,375);

  image(balouMaskedG,1000,25); //gives a black circle?!?
  text("resized, masked and\nput into PGraphics\n(should be cleared)",1000,50);

  image(balouorigIMG,25, 350);
  text("resized image\nWITHOUT PGraphics\nbut put through a PGraphics\nbefore",25,375);

  image(testIMG,350,350);  // 
  text("just a resized image\nwithout PGraphics",350,375);
  
  image(cJerkIMG,675,350); // 
  text("Why is that black\noutside the cirle??",675,375);

  image(jerkG,1000,350); // 
  text("I go destroy something now.",1000,375);

} // last line of draw()
</pre>

<p>Sorry for those seemingly random missing linebreaks, we have some translation error here(LF/CRLF stuff, old but gold).
Also, there are a lot of unused vars, as I yanked that out of the lightmeter sketch and expanded on it.</p>

<p>Anyways. Now, if I resize a loaded image, it'll be black unless I draw it into a PGraphics? Really?
And the mask does nothing unless I put the masked image through a PGraphics, and then the background is black? Why? I feel like Del Shannon crying Why why why why why in"Runaway".</p>

<p>And don't even get me started on lines in the console, like
"The pixel array has a length of 90000, but it should be at least 184041"
So, who made that pixel array too small?</p>

<p>Flame me, boot me, whatever, but this needed out, I already had one heart attack, I don't need another one.
You need one non-300x300px image to test that code yourself.</p>
]]></description>
   </item>
   <item>
      <title>How to use random to get at my color array</title>
      <link>https://forum.processing.org/two/discussion/23896/how-to-use-random-to-get-at-my-color-array</link>
      <pubDate>Wed, 23 Aug 2017 03:18:50 +0000</pubDate>
      <dc:creator>Petros</dc:creator>
      <guid isPermaLink="false">23896@/two/discussions</guid>
      <description><![CDATA[<p>What I'm trying to do: create a bunch of ellipses (in a grid) that each have one of an array of colors and that each mask one or more rectangles that also have a variable color from the same array. I've succeeded at (1) creating a masked shape, (2) duplicating it in a grid, and (3) creating an array of colors. Right now I'm trying to get that array to affect the colors but I'm failing. What am I doing wrong? I'm getting an error "expecting EOF, found 'colorset'." Pretty sure I have my file set up incorrectly. Any tips?</p>

<pre><code>/**
 * Draw rectangles inside of circles
 * 2017-08-22
 **/
PGraphics sourceImage;
PGraphics maskImage;

  int colorset;
  color [] colorsetarray = { 
    color(#3AC459), 
    color(#3D8CFF), 
    color(#8CD6ED), 
    color(#F7CC68), 
    color(#F77068), 
    color(#576984), 
    color(#7A9BB0), 
    color(#D8E8ED), 
    color(#EAF4F7) };
  colorset = colorsetarray[(int)random(0, 8)];

void setup() {
  size(800, 800); //size of canvas
  noLoop();
  smooth();
}

void draw() {

  for (int y = 20; y &lt; height-8; y += 120) {
    for (int x = 20; x &lt; width-80; x += 120) {
      // create source
      sourceImage = createGraphics(100, 100); //size of drawing
      sourceImage.beginDraw();
      sourceImage.background(colorsetarray[(int)random(colorsetarray.length)]); //color the background
      sourceImage.fill(colorsetarray[(int)random(colorsetarray.length)]); //color the rectangle
      sourceImage.translate(width/2, height/2);
      sourceImage.rotate(radians(45));
      sourceImage.noStroke(); //take the stroke off of the rectangle
      sourceImage.rect(-600, -200, 80, 500); //locate the rectangle and draw it
      sourceImage.endDraw();

      // create mask
      maskImage = createGraphics(100, 100); //size of mask
      maskImage.beginDraw();
      maskImage.ellipse(50, 50, 100, 100);
      maskImage.endDraw();

      // apply mask
      sourceImage.mask(maskImage);

      // show masked source
      image(sourceImage, x, y); //move the chip here
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to execute a function when using the createGraphics function ?</title>
      <link>https://forum.processing.org/two/discussion/23914/how-to-execute-a-function-when-using-the-creategraphics-function</link>
      <pubDate>Thu, 24 Aug 2017 11:35:57 +0000</pubDate>
      <dc:creator>giorgiomartini</dc:creator>
      <guid isPermaLink="false">23914@/two/discussions</guid>
      <description><![CDATA[<p>I want to use the createGraphics function to draw something on another screen... and then paste that into my main sketck..</p>

<p>in the docu, the example they give is doing something like:</p>

<pre><code>var vignette;

function setup(){
  createCanvas(710, 400);
  vignette = createGraphics(400, 250);
}

function draw(){

  ellipse(mouseX, mouseY, 60, 60);

  pg.background(51);
  pg.noFill();
  pg.stroke(255);
  pg.ellipse(mouseX-150, mouseY-75, 60, 60);

  //Draw the offscreen buffer to the screen with image()
  image(pg, 150, 75);
}
</code></pre>

<p>But what i want to do is more complex than <strong>pg.background(51)</strong></p>

<p>I want to run this function which creates a radial gradient:</p>

<pre><code>function drawGradient() {
  for (let r = canvasX; r &gt; 0; --r) {
    let lightnes = map(r,0,canvasX,360,0)
    fill(360, 360, lightnes)
    ellipse(0, 0, r, r)
  }
}
</code></pre>

<p>But if i do vignette.drawGradient() i get the error: vignette.drawGradient is not a function...</p>

<p>So how can i then execute things like whats inside the drawgradient function inside the createGraphics function?</p>

<p>Here is the codepen: <a href="https://codepen.io/giorgiomartini/pen/ZJjWbw?editors=0010" target="_blank" rel="nofollow">https://codepen.io/giorgiomartini/pen/ZJjWbw?editors=0010</a></p>
]]></description>
   </item>
   <item>
      <title>Python for processing - keyreleased?</title>
      <link>https://forum.processing.org/two/discussion/23706/python-for-processing-keyreleased</link>
      <pubDate>Fri, 04 Aug 2017 20:06:50 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">23706@/two/discussions</guid>
      <description><![CDATA[<p>I am figuring out some stuff.  I have created a small program that uses : keyPressed and keyReleased in a conditional inside the DRAW function.  The problem is that PFPython doesn't recognize keyReleased by itself, and it wants it as a function.  Why is that?  For example, I can use either keyPressed() or keyPressed:  -- but I cannot use keyReleased() and keyReleased:</p>
]]></description>
   </item>
   <item>
      <title>createGraphics() and image()</title>
      <link>https://forum.processing.org/two/discussion/23337/creategraphics-and-image</link>
      <pubDate>Thu, 06 Jul 2017 19:39:05 +0000</pubDate>
      <dc:creator>omerpekin</dc:creator>
      <guid isPermaLink="false">23337@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am slooooowly transitioning from Processing to p5.js and I am trying to re-write some of the sketches I did in Processing on p5.js</p>

<p>When I try to use createGraphics() method in p5.js and display a preloaded image (with image() method) in that offscreen graphic, somehow I don't get anything other than a blank screen.</p>

<p>When I use background() instead of image() method and display that image in the offscreen graphic I see everything, but then, of course, I cannot scale that image.</p>

<p>What am I doing wrong?</p>

<pre><code>                    `var img, pg;
                    var canvasOfset = 10;




                    function preload() {
                      img = loadImage('<a href="http://cdni.pageflow.codevise.de/main/video_files/posters/000/000/370/v3/medium/poster-0.JPG'" target="_blank" rel="nofollow">http://cdni.pageflow.codevise.de/main/video_files/posters/000/000/370/v3/medium/poster-0.JPG'</a>);
                    }

                    function setup() {
                      createCanvas(windowWidth - canvasOfset, windowHeight - canvasOfset);
                      pg = createGraphics(width, height);
                    }

                    function draw() {
                      pg.background(img);
                      var c = color(255, 0, 0);
                      image(pg, 0, 0, width, height);
                    }
                    `
</code></pre>

<p>this works</p>

<pre><code>                    `var img, pg;
                    var canvasOfset = 10;
                    var fillColor;
                    var drawn = false;



                    function preload() {
                      img = loadImage('<a href="http://cdni.pageflow.codevise.de/main/video_files/posters/000/000/370/v3/medium/poster-0.JPG'" target="_blank" rel="nofollow">http://cdni.pageflow.codevise.de/main/video_files/posters/000/000/370/v3/medium/poster-0.JPG'</a>);
                    }

                    function setup() {
                      createCanvas(windowWidth - canvasOfset, windowHeight - canvasOfset);
                      pg = createGraphics(width, height);
                    }

                    function draw() {
                      pg.image(img,0,0,width,height);
                      var c = color(255, 0, 0);
                      image(pg, 0, 0, width, height);
                    }
`
</code></pre>

<p>this does not...</p>

<p>Any help regarding this issue would be awesome!!</p>

<p>Thanks a lot.</p>

<p>Omer</p>
]]></description>
   </item>
   <item>
      <title>how to delete elements from canvas graphics in p5.js</title>
      <link>https://forum.processing.org/two/discussion/22913/how-to-delete-elements-from-canvas-graphics-in-p5-js</link>
      <pubDate>Sun, 04 Jun 2017 07:29:29 +0000</pubDate>
      <dc:creator>Adeeba</dc:creator>
      <guid isPermaLink="false">22913@/two/discussions</guid>
      <description><![CDATA[<p>how to delete elements from canvas graphics in p5.js</p>

<pre><code>function setup(){   
            canvas=createCanvas(1000,1000);
            canvsGraphics = createGraphics(1000,1000);
        }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Using createGraphics().get() in the draw loop causing memory usage?</title>
      <link>https://forum.processing.org/two/discussion/22039/using-creategraphics-get-in-the-draw-loop-causing-memory-usage</link>
      <pubDate>Mon, 17 Apr 2017 03:03:56 +0000</pubDate>
      <dc:creator>Tsa6</dc:creator>
      <guid isPermaLink="false">22039@/two/discussions</guid>
      <description><![CDATA[<p>Hello, and thank you so much for your time.  I've been working on a project, and found it to be using a ton of memory -- enough that it crashed the program it was being built for.  I spent a couple days poking around to no avail.  I did, however, figure out some of the details of the problem, and was wondering if you kind folks would be able to help me pinpoint a solution.  Anyway, cutting to the chase:</p>

<p>The minimum amount of code I could recreate the problem with was this:</p>

<pre><code>var graphics;

function setup() {
    graphics = createGraphics(1000,1000);
}

function draw() {
    graphics.get();
}
</code></pre>

<p>This produces the expected result, but uses a ton of memory.  Here's the relevant info I could get out of Chrome dev tools:
<img src="http://i.imgur.com/dN3NA9M.png" alt="Task Manager" />
The memory is currently at 1.2 gigs, but I've seen it reach 3 gigs, given enought time.  Either way, that's way too much memory.</p>

<p><img src="https://i.imgur.com/RpD0Iem.png" alt="Timeline" />
The saw tooth pattern continues indefinitely, with the teeth progressively growing slightly larger, but always dropping back down to the same height.
I also checked out the javascript heap snapshot, but it rarely exceeded 10mb, even during peaks.</p>

<p>Based on this, my current theory is that the Graphics.get() method creates excess detached DOM nodes, which build up until garbage collected.  However, I don't know why the spikes get progressively larger, nor do I have any idea as to how to fix it.  If this is a known bug, or common mistake, any further information, solutions, or workarounds would be greatly appreciated.  Thank you again so much for your help!</p>
]]></description>
   </item>
   <item>
      <title>How do I create a class which would contain a PGraphics property</title>
      <link>https://forum.processing.org/two/discussion/21422/how-do-i-create-a-class-which-would-contain-a-pgraphics-property</link>
      <pubDate>Wed, 15 Mar 2017 21:30:59 +0000</pubDate>
      <dc:creator>codeav3</dc:creator>
      <guid isPermaLink="false">21422@/two/discussions</guid>
      <description><![CDATA[<p>I would like every drawn shape to be an object which I can interact with later to change the fill, stroke etc. I would also create an ArrayList so I can sort the layers by sorting the arrayList.</p>

<p>I've been told to <strong>create a class for the drawn objects which would contain a PGraphics property</strong>, and also a draw method. While dragging the mouse, I can clear the latest Shape's PGraphic and draw it again.</p>

<p>I just have no idea how!</p>

<p>PS: I will implement other shapes the user can draw but they too need to be objects so I can manipulate them</p>

<p>Here is my code:</p>

<pre><code>ArrayList&lt;PGraphics&gt; layer = new ArrayList();
float startX, startY;

void setup() {
  size(500, 500);
  cursor(CROSS);
  background(255);
  smooth();
}

void draw() {
  background(255);
  for(PGraphics pg : layer) {
    image(pg, 0, 0);
  }
}
void mousePressed() {
  startX = mouseX;
  startY = mouseY;
  PGraphics pg = createGraphics(width, height);
  layer.add(pg);
}

void mouseDragged() {
  // get most recent layer
  PGraphics pg = layer.get(layer.size() - 1);
  shapeLayer.beginDraw();
  shapeLayer.clear();
  shapeLayer.rectMode(CORNERS);
  shapeLayer.rect(startX, startY, mouseX, mouseY);
  shapeLayer.endDraw();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>For loop drawing PGraphics in an array [Processing]</title>
      <link>https://forum.processing.org/two/discussion/21411/for-loop-drawing-pgraphics-in-an-array-processing</link>
      <pubDate>Wed, 15 Mar 2017 14:21:34 +0000</pubDate>
      <dc:creator>codeav3</dc:creator>
      <guid isPermaLink="false">21411@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to build a Drawing Program using Processing. I am currently stuck on using PGrapchics.</p>

<p>When the user draws a rectangle, it shows the shape being drawn. When the user releases their mouse, it then creates a PGraphic of the final shape. I would then like the user to draw on top of that. Here is my problem:</p>

<p>I had to reset the background of the canvas when drawing a rectangle because otherwise, it shows a trail of rectangles. The result is that while the user draws a new rectangle the old ones disappear and come back once the mouse has been releasd</p>

<p>Some thoughts: I would also like to add features where the user can select on a previously drawn rectangle and change it's colour, stroke, send to back, bring to front etc..</p>

<p>To achieve this, I'm storing all drawn rectangles (PGraphics) into an ArrayList which will be drawn via a for loop. This will allow me to adjust the behaviour by moving the PGraphics elements up and down the ArrayList.</p>

<p>QUESTIONS:
Is this correct or should I be creating an ArrayList of rectangles?
Instead of creating my own class of Shape am I better off using PShape?</p>

<pre><code>int startX;
int startY;
int endX;
int endY;
boolean drawing;
int strokeW = 3;
Shape shape;

PGraphics shapeLayer; 
ArrayList&lt;PGraphics&gt; layersList = new ArrayList();

void setup() {
  size(500, 500);
  cursor(CROSS);
  background(255);
  smooth();
}

void draw() {
  strokeWeight(strokeW);
  if (key &gt;= '0' &amp;&amp; key &lt;= '9') {
    strokeW = key - '0';
  }
  for(int i = 0; i &lt; layersList.size(); i++) {
    image(layersList.get(i), 0, 0);
  }
  if (drawing) {
    shape.createRectangle();
  }
}


void mousePressed() {
  startX = mouseX;
  startY = mouseY;

  shapeLayer = createGraphics(width, height);
  shapeLayer.beginDraw();
}  

void mouseDragged() {
  drawing = true;
  endX = constrain(mouseX, 0, 500);
  endY = constrain(mouseY, 0, 500); 

  shape = new Shape(startX, startY, endX, endY);
  shapeLayer.clear();
}

void mouseReleased() {
  drawing = false;
  shapeLayer.endDraw();
  layersList.add(shapeLayer);
}  
</code></pre>

<p>Here is the Shape Class:</p>

<pre><code>class Shape {
  int startX;
  int startY;
  int endX;
  int endY;

  Shape(int x1, int y1, int x2, int y2) {
    startX = x1;
    startY = y1;
    endX = x2;
    endY = y2;
  }    

  void createRectangle() {
    background(255, 0);
    shapeLayer.strokeWeight(strokeW);
    shapeLayer.rectMode(CORNERS);
    shapeLayer.rect(startX, startY, endX, endY);  
    rectMode(CORNERS);
    rect(startX, startY, endX, endY);

  }

}  
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to save high quality images from processing PGraphics</title>
      <link>https://forum.processing.org/two/discussion/13359/how-to-save-high-quality-images-from-processing-pgraphics</link>
      <pubDate>Mon, 02 Nov 2015 13:30:48 +0000</pubDate>
      <dc:creator>jairo_asecas</dc:creator>
      <guid isPermaLink="false">13359@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm trying to get high quality images from processing but I've got a problem.</p>

<p>this is the code I'm using:</p>

<pre><code>PGraphics big;  
void setup() {  
  big = createGraphics(5000, 5000, JAVA2D); // Create a new PGraphics object 5000x5000px  
  big.beginDraw(); // Start drawing to the PGraphics object  
  size(500, 500, P2D); //size of the on-screen display  
}  

int counter; // counter  
void draw() {  
  counter++; // add 1 to counter  
  if(counter%10 == 0) { // every 10th frame we snap a preview and draws it  
    PImage img = big.get(0, 0, big.width, big.height); //snap an image from the off-screen graphics  
    img.resize(width,height); // resize to fit the on-screen display  
    image(img,0,0); // display the resized image on screen  
  }  

  big.fill(255,0,0);//we fill following with red  
  big.ellipse(random(big.width),random(big.height),10,10);//randomly placed circle  
}  

/** 
* We save on any key 
* this could be done in void close() but safer to have it here. 
*/  
void keyPressed() {  
  big.endDraw(); // finish drawing  
  big.save("highRes.tif"); //save to file - use .tif as format for high-res  
  println("saved"); // nice with some feedback  
}  
</code></pre>

<p>it is from: Alexander Salveson Nossum, link: <a href="http://alexanno.net/2010/06/high-resolution-output-from-processing-processing-in-hd/comment-page-1/#comment-818" target="_blank" rel="nofollow">http://alexanno.net/2010/06/high-resolution-output-from-processing-processing-in-hd/comment-page-1/#comment-818</a></p>

<p>It works with easy sketches but when I try to use a function it fails.</p>

<p>example: <code>big.ellipse(random(width),random(height),40,40);</code></p>

<p>works</p>

<p>but: <code>void example(){ ellipse(random(width),random(height),40,40); }</code></p>

<p>big.example();</p>

<p>doesn’t works. (says: ****the function example() does not exist.****)</p>

<p>why is it? there is another way to get better quality captures?</p>
]]></description>
   </item>
   <item>
      <title>Copy a 3D PGraphics? (Processing.js)</title>
      <link>https://forum.processing.org/two/discussion/21131/copy-a-3d-pgraphics-processing-js</link>
      <pubDate>Fri, 03 Mar 2017 16:17:55 +0000</pubDate>
      <dc:creator>cems</dc:creator>
      <guid isPermaLink="false">21131@/two/discussions</guid>
      <description><![CDATA[<p>Rationale:  The problem I'm trying to solve is I want to rotate a camera around to show different viewpoints on a complex 3D surface that is very time expensive to redraw.  But it's not changing it's shape.  Thus I'd like to draw it once then rotate the camera (or it) and then just generate images to show on the screen.</p>

<pre><code>pattern:
t = createGraphics(size and stuff)
&lt;fill it with a TRIANGLE_STRIP surface&gt;
draw() {
  camera( changing parameters go here )
  image( t,  more_parameters)
}
</code></pre>

<p><strong>What I expected</strong> was the image to show a rotating object as the camera is changed.</p>

<p><strong>What happens:</strong> I just the very first image perpetually, then nothing changes.</p>

<p>If instead I put the creation and triangle_strip drawing into the draw loop so it is redrawn every time then I get what I expect to see but of course I'm having to recreate the 3D object every time.</p>

<p>Regression:  My wild guess here is that calling Image is forcing some delayed lazy rendering of the graphics, and then subsequent calls do not re-render the image even if the graphics was  rotated.  Somehow this would seem like a lousy behaviour so I'm sort of doubting this theory.  But I can't think of another one</p>

<p>I've tried using the following two commands to see based on the guess that I might be able to reset some lazy image creation flag to it wold recreate the image but these did not work-- get errors:</p>

<pre><code>//t.Image.setLoaded(false);
//t.updatePixels() ;
</code></pre>

<p>So Maybe that guess is incorrect.</p>

<p>But if this sticky on-time rendering hypothesis. correct then maybe a solution would be to copy the graphics object before I display it so I can keep an unrendered copy.</p>

<p>if so then the problem becomes:</p>

<p>**Problem: ** how to duplicate a 3D PGraphics Object.</p>

<p>Note: <strong>this is 3D not 2D</strong>, so it's not the same as simply copying the pixels from one image to another.</p>
]]></description>
   </item>
   <item>
      <title>How to reset the background of a Graphic completely (every pixel should be 100% transparent)?</title>
      <link>https://forum.processing.org/two/discussion/20831/how-to-reset-the-background-of-a-graphic-completely-every-pixel-should-be-100-transparent</link>
      <pubDate>Thu, 16 Feb 2017 20:29:11 +0000</pubDate>
      <dc:creator>Last_Hero</dc:creator>
      <guid isPermaLink="false">20831@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone!
I need to clear a graphic (createGraphics) in p5, what should i use?</p>

<p>if i use background(0), the graphic will be cleared, however the pixels will be still black, and thats not good beacuase i am using multiple graphics and their background has to be transparent</p>

<p>i tried using clear() but it looks like its not working on a graphic in p5 only in processing :(</p>

<p>any help would be appreciate!</p>
]]></description>
   </item>
   </channel>
</rss>