<?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 smooth() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=smooth%28%29</link>
      <pubDate>Sun, 08 Aug 2021 15:59:23 +0000</pubDate>
         <description>Tagged with smooth() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedsmooth%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to rewrite this for faster performance? (image resize)</title>
      <link>https://forum.processing.org/two/discussion/27567/how-to-rewrite-this-for-faster-performance-image-resize</link>
      <pubDate>Sat, 31 Mar 2018 01:47:52 +0000</pubDate>
      <dc:creator>BGADII</dc:creator>
      <guid isPermaLink="false">27567@/two/discussions</guid>
      <description><![CDATA[<p>Is there a faster way to write this?
PGraphics buffer is HD, canvas size is SD. 
If canvas size and PGraphics buffer are the same, the framerate is 60. If they are different, the framerate is 20 meaning there is an insane performance hit to image resize.</p>

<p><code>image(buffer, 0, 0, width, height);</code></p>

<p>Alright, this is a bit weird.</p>

<p>With the standard image resize:</p>

<pre><code>Default renderer  = 20fps. 

P3D = 50fps. 
</code></pre>

<p>I did an image resize manually by copying the pixels to an array with a for loop, then using a simple nearest neighbor solution, then copying the array into a pimage, then displaying the pimage.</p>

<pre><code>default renderer = 50fps

P3D = 50fps. 
</code></pre>

<p>Obviously, my image resize method which is nearest neighbor looks terrible compared to the default one, and it gets the same fps in P3D. The goal however is to export to android, and for some reason P3D is super slow... any advice? Is there any examples resizing a PGraphics canvas with a custom algorithm in a processing sketch?</p>

<p>This is my resize algorithm</p>

<pre><code>  int[] resize(int[] original, int x1, int y1, int x2, int y2) {
    int[] resized = new int[x2*y2];
    double xr = x1/(double)x2;
    double yr = y1/(double)y2;
    double px;
    double py; 
    for (int x = 0; x &lt; x2; x++) {
      px = x * xr;
      for (int y = 0; y &lt; y2; y++) {
        py = y * yr;
        double index = Math.floor((y* x2) + x);
        double index2 = Math.floor((int)((py * x1) + px));
        resized[(int)(index)] = original[(int)index2];
      }
    }
    return resized;
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to smooth ellipse</title>
      <link>https://forum.processing.org/two/discussion/26961/how-to-smooth-ellipse</link>
      <pubDate>Wed, 21 Mar 2018 13:17:42 +0000</pubDate>
      <dc:creator>mxloizix</dc:creator>
      <guid isPermaLink="false">26961@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I have made this little code for trying P5JS</p>

<pre><code>  var bubbleDiam = 40;
  var bubbleNb = 80;
  var xpos = [];
  var ypos = [];
  var hue = []; 

 function setup() {

 createCanvas(windowWidth, windowHeight);
 colorMode(HSB,360,100,100);
 noStroke();

  for( var i = 0 ; i &lt; bubbleNb ; i++){
  xpos[i] = random(bubbleDiam, windowWidth - bubbleDiam);
  ypos[i] = random(bubbleDiam, windowHeight - bubbleDiam);
  hue[i] = random(360);
  }      
}

function draw() {
 var bri = map(mouseY,0,displayHeight, 60,100);
 var vary = map(mouseX,0,displayWidth,-60,60);

  for( var i = 0 ; i &lt; bubbleNb ; i++){
    fill(hue[i] + vary, 80,bri);
    ellipse(xpos[i],ypos[i],bubbleDiam,bubbleDiam, 100);
}

}
</code></pre>

<p>but there is a strong problem of aliasing as you can see <br /></p>

<p><a rel="nofollow" href="https://forum.processing.org/two/uploads/imageupload/373/LUQBD7C0S4YT.PNG" title="temp-bubbles">temp-bubbles</a></p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/373/LUQBD7C0S4YT.PNG" alt="" /></p>

<p>how can I have beautiful circles in P5js ?</p>

<p>thanks</p>
]]></description>
   </item>
   <item>
      <title>Why are text and graphics so ugly and blocky?</title>
      <link>https://forum.processing.org/two/discussion/8075/why-are-text-and-graphics-so-ugly-and-blocky</link>
      <pubDate>Tue, 11 Nov 2014 10:54:48 +0000</pubDate>
      <dc:creator>PhiLho</dc:creator>
      <guid isPermaLink="false">8075@/two/discussions</guid>
      <description><![CDATA[<h1>Why are text and graphics so ugly and blocky?</h1>

<p>Often in the forum we have similar questions:<br />
"<em>Why is the text so blocky?</em>"<br />
"<em>Why these lines are not anti-aliased?</em>"<br />
"<em>Why is this circle almost squarish?</em>"<br /></p>

<p>And when asked, the user shows code looking like:</p>

<pre lang="processing">
void setup()
{
  size(400, 400);
  background(255);
}

void draw()
{
  stroke(#000055);
  fill(#000055);

  ellipse(width / 2, height / 2, width / 10, height / 10);

  textSize(50);
  text("Blocky\nText", 100, 2 * height / 3);
  textSize(10);
  text("Other\nText", 20, height / 3);

  line(100, 50, 300, 150);
  line(150, 150, 350, 100);
}
</pre>

<p>If you are an experienced user, you immediately spot the problem, and advise to move the call to <code>background()</code> at the start of <code>draw()</code>;</p>

<pre lang="processing">
void setup()
{
  size(400, 400);
}

void draw()
{
  background(255);
  stroke(#000055);
  fill(#000055);

  ellipse(width / 2, height / 2, width / 10, height / 10);

  textSize(50);
  text("Blocky\nText", 100, 2 * height / 3);
  textSize(10);
  text("Other\nText", 20, height / 3);

  line(100, 50, 300, 150);
  line(150, 150, 350, 100);
}
</pre>

<p>In versions before 2.0, adding a call to <code>smooth()</code> helped, but it is the default now.</p>

<h3>Why does it makes a difference?</h3>

<p>Processing does its drawings in anti-aliased mode: the borders are smoothed by drawing semi-transparent, toned down pixels on the borders, making a nicer transition with the background.
<code>draw()</code> is called 60 times per second (by default). It doesn't erase the background if not asked explicitly. So it draws over and over the graphics at the same place. The semi-transparent pixels cumulate on the borders, so they progressively become completely opaque. Hence the blocky look with steps.</p>

<p>Nearly all the Processing sketches (except some special effects playing on the accumulation of graphics) start <code>draw()</code> with a call to <code>background()</code>. There can be exceptions, but they are the done by people understanding deeply how Processing works.</p>
]]></description>
   </item>
   <item>
      <title>How do I make a number go from 0 to 255 and back down again without using "if" statements?</title>
      <link>https://forum.processing.org/two/discussion/24774/how-do-i-make-a-number-go-from-0-to-255-and-back-down-again-without-using-if-statements</link>
      <pubDate>Fri, 27 Oct 2017 23:40:26 +0000</pubDate>
      <dc:creator>Gav</dc:creator>
      <guid isPermaLink="false">24774@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I would like to make a variable go up to a max number by a certain increment each time and then make it go back down to 0 by the same increment, and repeat. variable % maxNumber just floors the number at 0. I would like the number to be maxNumber - (variable % maxNumber) after variable &gt; maxNumber until variable &gt; maxNumber * 2, then I just want variable to be floored again to start the process over. I could use a "sin" function, but I don't like the way it curves. I also would rather not use "if" or "while" statements because it feels like cheating. I'm complicating this too much in my head, does anybody know how to do this?</p>

<p>Any help would be appreciated, thanks!</p>

<p>-Gav</p>
]]></description>
   </item>
   <item>
      <title>Artifacts when using mask() and default/P2D</title>
      <link>https://forum.processing.org/two/discussion/23124/artifacts-when-using-mask-and-default-p2d</link>
      <pubDate>Sun, 18 Jun 2017 20:17:11 +0000</pubDate>
      <dc:creator>kfrajer</dc:creator>
      <guid isPermaLink="false">23124@/two/discussions</guid>
      <description><![CDATA[<p>****EDIT</p>

<p>In the code below I have two observations and I am hopping to figure out if there is a way to solve them.</p>

<h2>First  {REN =P2D;  maskImageNow=false;}</h2>

<p>When REN is set to P2D, and maskImageNow=false, a white fill ellipse is drawn on top of a background full of nonFilled mini ellipses (background black and their stroke color is white). What I am observing is that the large main filled ellipse that follows the mouse has an artifact in its fill. You can see the borders of the circles underneath the Pgraphics object. See this image showing the problem:</p>

<p>_<img src="https://forum.processing.org/two/uploads/imageupload/846/QSGA4LZSBT0J.png" alt="Screenshot (8593)" title="Screenshot (8593)" /></p>

<p>***********EDIT: For the first case, it seems it is related to the order of drawing. In P2D, because of line 67, the white ellipse is drawn first and then the mini-bubbles on top. However, if you use JAVA2D you don't get the same effect. The ellipse and bubbles are on the same level/depth/layer. Or in other words, there is some edge blending between the mini-bubbles edge and the background in the gg (PGraphics) object  which is not observed in the JAVA2D renderer version. Consider this part of the question solved and the observation is not an artifact.</p>

<h2>Second  {REN =JAVA2D;  maskImageNow=true;}</h2>

<p>When I set the REN to JAVA2D, when I apply the mask (maskImageNow=true), the edges of the ellipses are not smooth. However, when the mask effect is off, the background ellipses do not display that rough edges effect. Next image shows this observation:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/129/ATSG8I60FPSK.png" alt="Screenshot (8596)" title="Screenshot (8596)" /></p>

<p>Notice that during the screenshot process, the edges of the ellipses do not show that rough edge I was talking about (left image). Hopefully if you run the code you can see it directly on the sketch.</p>

<p>Can you reproduce them and do you know any way to fix them?</p>

<p>Kf</p>

<pre><code>//REFERENCES: <a href="https://forum.processing.org/two/discussion/23093/brightness-pixel-doesnt-work#latest" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/23093/brightness-pixel-doesnt-work#latest</a>

//INSTRUCTIONS:
//         *--   Click to enable or disable the masking effect


//===========================================================================
// FINAL FIELDS:
final int maxTries=9000;
final int nCircles=2000;
final String REN=P2D;


//===========================================================================
// GLOBAL VARIABLES:

ArrayList&lt;CircleStruct&gt; c;
PGraphics pg;
PGraphics gg;
boolean maskImageNow=false;

//===========================================================================
// PROCESSING DEFAULT FUNCTIONS:

void settings() {
  size(400, 600, REN);
  smooth(8);
}

void setup() {

  textAlign(CENTER, CENTER);
  rectMode(CENTER);
  ellipseMode(RADIUS);

  fill(255);
  strokeWeight(2);

  pg = createGraphics(width, height, REN);
  //pg.smooth(4);

  c=new ArrayList&lt;CircleStruct&gt;();
  gg=createGraphics(width, height, REN);  
  //gg.smooth(4);
  fillWithCircles(nCircles);
  gg.beginDraw();  
  gg.noFill();
  gg.stroke(255);
  gg.strokeWeight(2);
  gg.clear();
  for (CircleStruct pc : c) {
    pc.draw(gg);
  }
  gg.endDraw();
}



void draw() {
  background(0);

  pg.beginDraw();
  pg.clear();
  pg.ellipse(mouseX, mouseY, 100, 100);
  pg.endDraw();

  image(pg, 0, 0);

  if (maskImageNow) 
    gg.mask(pg);

  image(gg, 0, 0);
}

void keyReleased() {
}

void mouseReleased() {
  maskImageNow=!maskImageNow;  //Toggle action

  if (maskImageNow==false) {
    gg.beginDraw();
    gg.noFill();
    gg.stroke(255); 
    gg.strokeWeight(2);
    gg.clear();
    for (CircleStruct pc : c) {
      pc.draw(gg);
    }
    gg.endDraw();
  }
}



//===========================================================================
// OTHER FUNCTIONS:

void fillWithCircles(int n) {
  noFill();
  stroke(255);
  c.clear();  

  for (int i=0; i&lt;n; i++) {
    CircleStruct cir=new CircleStruct();
    boolean overlap=true;
    int ntries=0;
    while (overlap &amp;&amp; ntries&lt;maxTries) {
      overlap=false;
      ntries++;
      for (CircleStruct pc : c) {
        if (cir.overlaps(pc)) {
          overlap=true;
          cir.reGenerateCircle();
          break;
        }
      }
    }

    if (ntries&gt;=maxTries) {
      println("Stop trying placing circles at counter " + i + " out of "+n);
      break;
    }

    c.add(cir);
  }
}


class CircleStruct {

  final static int minRad=3;
  final static int maxRad=12;

  float w;
  float h;
  float rad;

  CircleStruct() {
    generateCircle();
  }

  void generateCircle() {
    w=random(width);
    h=random(height);
    rad=random(minRad, maxRad);
  }

  void reGenerateCircle() {
    generateCircle();
  }

  void draw() {
    ellipse(w, h, rad, rad);
  }

  void draw(PGraphics gg) {
    gg.ellipse(w, h, rad, rad);
  }

  boolean overlaps(CircleStruct ptrC) {
    return overlaps(ptrC.w, ptrC.h, ptrC.rad);
  }

  boolean overlaps(float _w, float _h, float _r) {
    return dist(w, h, _w, _h)&lt;rad+_r;
  }
</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>smooth() function not working</title>
      <link>https://forum.processing.org/two/discussion/17402/smooth-function-not-working</link>
      <pubDate>Sun, 03 Jul 2016 16:28:59 +0000</pubDate>
      <dc:creator>dawbakhos</dc:creator>
      <guid isPermaLink="false">17402@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I've been programming on processing for some time, and I've noticed that whenever I watch tutorials online, the smooth() function does make an actual difference, whereas on mine my (mid-2014) MBP Retina (Nvidia GT 750M, 16GB) just doesn't.</p>

<p>Could anyone please help?
Here's a couple of screenshots of an ellipse:</p>

<p>without smooth()
<img src="https://forum.processing.org/two/uploads/imageupload/251/4ZK5SWB1OGAN.png" alt="Screen Shot 2016-07-03 at 18.25.33" title="Screen Shot 2016-07-03 at 18.25.33" /></p>

<p>with smooth()</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/722/WFZZAXJS3D8A.png" alt="Screen Shot 2016-07-03 at 18.26.26" title="Screen Shot 2016-07-03 at 18.26.26" /></p>

<p>Any reason why this could be happening?</p>

<p>Thank you so much!</p>

<p>Regards!</p>
]]></description>
   </item>
   <item>
      <title>p3d + SVG aliassing</title>
      <link>https://forum.processing.org/two/discussion/17225/p3d-svg-aliassing</link>
      <pubDate>Mon, 20 Jun 2016 10:58:53 +0000</pubDate>
      <dc:creator>ispot</dc:creator>
      <guid isPermaLink="false">17225@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>somewhat beginner here, i'm making some scenes with SVG files using geomerative library. 
everything works, i optimized the SVG's to contain only simple linework. but everything looks aliassed when rendered with P3D. i tried higher smooth() values, no difference. when i set noSmooth() it gets more ugly and jagged so the default smooth(2) is working.</p>

<p>is there a way to get higher quality or higher anti-aliassing? or some super high AA quality setting for saveFrame()? or should i look into post processing manipulation?</p>

<p>thanks!</p>
]]></description>
   </item>
   <item>
      <title>How to pass a PApplet in composition? (I am using Intelij as an ide)</title>
      <link>https://forum.processing.org/two/discussion/16420/how-to-pass-a-papplet-in-composition-i-am-using-intelij-as-an-ide</link>
      <pubDate>Wed, 04 May 2016 07:40:47 +0000</pubDate>
      <dc:creator>Magnetic_Garden</dc:creator>
      <guid isPermaLink="false">16420@/two/discussions</guid>
      <description><![CDATA[<p>I am making this in Intelij;</p>

<p>First class;
    import processing.core.PApplet;</p>

<pre><code>    public class Test1 {
        static PApplet parent;
        public Test1(PApplet p) {
            parent = p;}

        Test2 test2 = new Test2(parent);

        public void dosomething(){

            test2.doThing();
        }
    }
</code></pre>

<p>Second class;
    import processing.core.PApplet;<del></del>
    public class Test2 {</p>

<pre><code>    static PApplet parent;
    public Test2(PApplet p) {
        parent = p;}

    public void doThing(){  parent.ellipse( 100,100,50,50);  }
}
</code></pre>

<p>Then in the main class
        public class ExampleApplet extends PApplet {</p>

<pre><code>        int countSVGsUsed = 0;
        String [] SvgsUsed = new String[1000];


        public static void main(String args[]) {
            PApplet.main("ExampleApplet");
        }
    public void draw() {
      Test1 test1 = new Test1(this);
            test1.dosomething();
    }
    }
</code></pre>

<p>this gives me the following errors</p>

<p>smooth() can only be used inside settings()
Exception in thread "Animation Thread" java.lang.NullPointerException
    at Test2.doThing(Test2.java:12)
    at Test1.dosomething(Test1.java:15)
    at ExampleApplet.draw(ExampleApplet.java:101)
    at processing.core.PApplet.handleDraw(PApplet.java:2401)
    at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1499)
    at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:312)</p>

<p>I get a NullPointerException because PApplet does not get passed(?)
is there a workaround or a simple solution for this?</p>

<p>Thx in advance</p>
]]></description>
   </item>
   <item>
      <title>Show scaled image and P2D/P3D</title>
      <link>https://forum.processing.org/two/discussion/15780/show-scaled-image-and-p2d-p3d</link>
      <pubDate>Thu, 31 Mar 2016 10:24:32 +0000</pubDate>
      <dc:creator>cameyo</dc:creator>
      <guid isPermaLink="false">15780@/two/discussions</guid>
      <description><![CDATA[<p>Different result showing scaled image with P2D/P3D or default render:</p>

<pre><code>PImage img;
void setup()
{
  size(220, 300, P2D);
  img = loadImage("data.png");
}

void draw()
{
  image(img,10,10,136,136);
}
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/173/VNXC2JN0IOY7.png" alt="forum" title="forum" /><br />
Can you help me ?<br />
Thanks.</p>
]]></description>
   </item>
   <item>
      <title>offscreen PGraphics is ugly</title>
      <link>https://forum.processing.org/two/discussion/13355/offscreen-pgraphics-is-ugly</link>
      <pubDate>Mon, 02 Nov 2015 07:47:54 +0000</pubDate>
      <dc:creator>janper</dc:creator>
      <guid isPermaLink="false">13355@/two/discussions</guid>
      <description><![CDATA[<p>i'm using Processing 3 (and 2) on both, OSX and Windows. The linear graphics in offscreen PGraphics buffer is significantly uglier than directly drawn lines. It seems like the antialiasing on the edges of the shape doesn't work well.</p>

<p>Can you help me making the offscreen buffer graphics nicer?</p>

<p>exmple image ugly offscreen on the right, on-screen on the left</p>

<p><img src="http://i.stack.imgur.com/t20mF.png" alt="" /></p>

<p>sample code</p>

<pre><code>PGraphics pg;

void setup(){
  size (1024,768, P2D);
  pixelDensity(2);
  smooth();
  pg = createGraphics(width, height, P2D);
  noLoop();
}

void draw(){
  background (0);
  pushMatrix();
  translate (width/2-100, height/2);
  rotate (PI/6);
  stroke(255);
  noFill();
  strokeWeight(0.5);
  rect (0,0,100,100);
  popMatrix();

  pg.beginDraw();
  pg.smooth();
  pg.clear();
  pg.translate (width/2+100, height/2);
  pg.rotate (PI/6);
  pg.stroke(255);
  pg.noFill();
  pg.strokeWeight(0.5);
  pg.rect (0,0,100,100);
  pg.endDraw();

  image(pg,0,0, width, height);

  save("shot.png");
}
</code></pre>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Drawing a straight 2D diagonal line</title>
      <link>https://forum.processing.org/two/discussion/12514/drawing-a-straight-2d-diagonal-line</link>
      <pubDate>Tue, 15 Sep 2015 08:31:11 +0000</pubDate>
      <dc:creator>shubham</dc:creator>
      <guid isPermaLink="false">12514@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am using processing to draw lines on canvas. My code is quite simple -
processing.line(line.origin.x, line.origin.y, line.destination.x, line.destination.y);</p>

<p>But I get pixelated lines. Please see an example here - <a href="https://www.dropbox.com/s/gmu0kqwgdx0ozs8/Screenshot%202015-09-15%2016.28.02.png?dl=0" target="_blank" rel="nofollow">https://www.dropbox.com/s/gmu0kqwgdx0ozs8/Screenshot 2015-09-15 16.28.02.png?dl=0</a></p>

<p>Could you help tell me how to solve this problem?</p>

<p>Thanks.</p>

<p>Warmest Regards,
Shubham.</p>
]]></description>
   </item>
   <item>
      <title>Smooth being disabled, any way to force smooth()</title>
      <link>https://forum.processing.org/two/discussion/5858/smooth-being-disabled-any-way-to-force-smooth</link>
      <pubDate>Tue, 17 Jun 2014 18:20:00 +0000</pubDate>
      <dc:creator>TSH</dc:creator>
      <guid isPermaLink="false">5858@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys I'm running a sketch with masks and I keep getting this error</p>

<p>"The smooth/noSmooth functions are being called too often.
This results in screen flickering, so they will be disabled
for the rest of the sketch's execution."</p>

<p>Anybody else faced this issue? Any way to avoid this or to force smooth() to stay enable?</p>

<p>Also any other way to have any kind of anti-aliasing beside smooth()?</p>

<p>Thanks, did some research first but can't find an answer</p>

<p>PS No GPU, doesn't seem to be an issue when running on a GPU system</p>
]]></description>
   </item>
   <item>
      <title>Billboarding/Look at camera</title>
      <link>https://forum.processing.org/two/discussion/7836/billboarding-look-at-camera</link>
      <pubDate>Mon, 27 Oct 2014 16:20:04 +0000</pubDate>
      <dc:creator>akiersky</dc:creator>
      <guid isPermaLink="false">7836@/two/discussions</guid>
      <description><![CDATA[<p>Hi All,</p>

<p>Looking for a way to make a sphere (or anything really) rotate in 3d to look at the camera or another object. It seems so simple, but it's driving me crazy. I've got a pretty close (I think) solution, but I feel like I'm just inputting the wrong values or using the wrong math method.</p>

<p>here's where I'm at:</p>

<pre><code>PVector eye, pos;

void setup() {
  size(800, 800, P3D);
  smooth(8);

  eye = new PVector(0.0f, 0.0f, -1000.0f);
  pos = new PVector(0, 0, 0);
}

void draw() {
  background(0);
  lights();

//  eye.x=0;
//  eye.y=0;
//  eye.z=-1000;
  camera(eye.x, eye.y, eye.z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

  translate(pos.x, pos.y, pos.z);
  //PVector rMatrix = faceCamera(eye.get(), pos.get());
  PVector rMatrix = faceCamera(new PVector(mouseX+width/2, mouseY+height/2, -1000), pos.get());//simulate camera movement

  rotateX(rMatrix.x);
  rotateY(rMatrix.y);
  rotateZ(rMatrix.z);

  sphere(200);
}

void keyPressed() {
  if(keyCode == 38) {
    eye.y -=5;
  }
  if(keyCode == 40) {
    eye.y +=5;
  }
  if(keyCode == 37) {
    eye.x -=5;
  }
  if(keyCode == 39) {
    eye.x +=5;
  }
  println(eye);
}

PVector faceCamera(PVector c, PVector p) {
  c.normalize();
  p.normalize();
  float dx = p.x - c.x;
  float dy = p.y - c.y;
  float dz = p.z - c.z;

  PVector ang = new PVector();
  ang.x = atan2(dz, dy);
  ang.y = atan2(dx, dz);
  ang.z = atan2(dy, dx);
  return ang;
}
</code></pre>

<p>I'm using the mouse to represent the camera to speed up testing, but in the end, I'll have it always pointed to the camera. I'd like to avoid using a camera library like Proscene just to keep things simple, but I see that there is an example that works for what I'm trying to do.</p>

<p>Any suggestions would be awesome!</p>

<p>thanks!
ak</p>
]]></description>
   </item>
   <item>
      <title>How do I do this using arrays and a for loop?</title>
      <link>https://forum.processing.org/two/discussion/7793/how-do-i-do-this-using-arrays-and-a-for-loop</link>
      <pubDate>Fri, 24 Oct 2014 15:15:23 +0000</pubDate>
      <dc:creator>samuset</dc:creator>
      <guid isPermaLink="false">7793@/two/discussions</guid>
      <description><![CDATA[<pre><code>size(500, 300);

textAlign(LEFT);

textSize(40);
float h1 = textAscent() + textDescent();
text("Hello", 100, h1);
line(0, h1, width, h1);

textSize(20);
float h2 = textAscent() + textDescent();
text("Hello", 101, h2+h1);
line(0, h2+h1, width, h2+h1);

textSize(15);
float h3 = textAscent() + textDescent();
text("Hello", 102, h3+h2+h1);
line(0, h3+h2+h1, width, h3+h2+h1);
</code></pre>

<p>So that the y position of the "current" line is the sum of the heights of the previous lines and the height of its own.
Looks like this at the moment:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/028/Z1SXEFYVJGXR.png" alt="Screen Shot 2014-10-24 at 20.14.23" title="Screen Shot 2014-10-24 at 20.14.23" /></p>
]]></description>
   </item>
   <item>
      <title>Why is my 3D object alignment off?</title>
      <link>https://forum.processing.org/two/discussion/5805/why-is-my-3d-object-alignment-off</link>
      <pubDate>Sun, 15 Jun 2014 07:23:10 +0000</pubDate>
      <dc:creator>des812</dc:creator>
      <guid isPermaLink="false">5805@/two/discussions</guid>
      <description><![CDATA[<p>I can't figure out why these 2 rows of boxes aren't perfectly aligned to one another the way the boxes in the rows are... in other words, why is there a gap between the rows? Any help would be much appreciated. Thanks.</p>

<pre><code>int dim = 50; 

void setup() {
  size(400, 200, P3D);
  background(255);
  smooth(4);
}

void draw() {
  lights();

  fill(255, 128);
  stroke(255, 128);
  ortho(0, width, 0, height); // same as ortho()

  pushMatrix();
  translate(100, 100, 0);
  rotateX(-PI/6);
  rotateY(PI/6);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  popMatrix();

  pushMatrix();
  translate(100, 100+dim, 0);
  rotateX(-PI/6);
  rotateY(PI/6);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  translate(dim, 0, 0);
  box(dim);
  popMatrix();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Image resize anti-aliasing?</title>
      <link>https://forum.processing.org/two/discussion/4040/image-resize-anti-aliasing</link>
      <pubDate>Sun, 30 Mar 2014 18:00:40 +0000</pubDate>
      <dc:creator>DCRaven</dc:creator>
      <guid isPermaLink="false">4040@/two/discussions</guid>
      <description><![CDATA[<p>can I turn anti-aliasing off for resizing an image? Because resizing pixel images makes it look shitty.</p>

<p><code>image(pixelImg, 50, 50, 100, 100);</code></p>

<p>I had a detailed look at the reference and didn't find anything :/</p>
]]></description>
   </item>
   </channel>
</rss>