<?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 setup() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=setup%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:42:13 +0000</pubDate>
         <description>Tagged with setup() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedsetup%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>What is the difference between initializing a variable inside/outside setup() ?</title>
      <link>https://forum.processing.org/two/discussion/28135/what-is-the-difference-between-initializing-a-variable-inside-outside-setup</link>
      <pubDate>Tue, 09 Oct 2018 22:03:27 +0000</pubDate>
      <dc:creator>JoaoBM</dc:creator>
      <guid isPermaLink="false">28135@/two/discussions</guid>
      <description><![CDATA[<p>Hey!</p>

<p>Is there a difference between initializing a variable inside / outside setup?</p>

<p>Such as this:</p>

<pre><code>int x;

setup() {
x = 5;
}
</code></pre>

<p>and this:</p>

<pre><code>int x = 5;

setup() {
}
</code></pre>

<p>Thanks in advance!</p>
]]></description>
   </item>
   <item>
      <title>what are the differences between setup() and settings()?</title>
      <link>https://forum.processing.org/two/discussion/27819/what-are-the-differences-between-setup-and-settings</link>
      <pubDate>Sun, 22 Apr 2018 10:30:32 +0000</pubDate>
      <dc:creator>greenleafvolatile</dc:creator>
      <guid isPermaLink="false">27819@/two/discussions</guid>
      <description><![CDATA[<p>It's in the API, but the explanation there is too vague for me. I don't get it. Can someone elucidate?</p>
]]></description>
   </item>
   <item>
      <title>Why should size() call be the first line in setup()?</title>
      <link>https://forum.processing.org/two/discussion/20587/why-should-size-call-be-the-first-line-in-setup</link>
      <pubDate>Wed, 01 Feb 2017 08:49:31 +0000</pubDate>
      <dc:creator>Lord_of_the_Galaxy</dc:creator>
      <guid isPermaLink="false">20587@/two/discussions</guid>
      <description><![CDATA[<p>The title says it all.<br />
Most of us here know that <code>size()</code> must be the first call in <code>setup()</code>. <a href="/two/profile/PhiLho">@PhiLho</a> also says</p>

<blockquote class="Quote">
  <p>... the rule saying that the size() call must be the first one in setup(). For some reason, code before it tends to be run twice, which is annoying when loading a possibly large file.</p>
</blockquote>

<p>But why does that occur? Is it because <code>size()</code> internally calls <code>setup()</code> again after setting the size of the sketch, and subsequent calls to <code>size()</code> just skip right through to end?</p>
]]></description>
   </item>
   <item>
      <title>What is the purpose of void setup() ?</title>
      <link>https://forum.processing.org/two/discussion/25835/what-is-the-purpose-of-void-setup</link>
      <pubDate>Fri, 05 Jan 2018 16:10:10 +0000</pubDate>
      <dc:creator>pythagorian</dc:creator>
      <guid isPermaLink="false">25835@/two/discussions</guid>
      <description><![CDATA[<p>I am watching the Codetrain videos in order to learn how to program using Processing. In video 6.3</p>

<p><a rel="nofollow" href="https://www.youtube.com/watch?v=h4ApLHe8tbk&amp;index=3&amp;list=PLRqwX-V7Uu6bm-3M4Wntd4yYZGKwiKfrQ">https://youtube.com/watch?v=h4ApLHe8tbk&amp;index=3&amp;list=PLRqwX-V7Uu6bm-3M4Wntd4yYZGKwiKfrQ</a></p>

<p>while discussing loops, Daniel creates a sketch that uses the functions <strong>size</strong>, <strong>stroke</strong>, <strong>background</strong> and <strong>strokeWeight</strong>. In all previous videos these functions were inside of <strong>setup</strong> but in this video they stand alone at the beginning of the code.</p>

<p>Is there any difference in the way these functions act when inside or outside of <strong>setup</strong>? If not, what is the purpose of the <strong>setup</strong> function?</p>
]]></description>
   </item>
   <item>
      <title>How can I get a list of fonts using Python in processing?</title>
      <link>https://forum.processing.org/two/discussion/23669/how-can-i-get-a-list-of-fonts-using-python-in-processing</link>
      <pubDate>Tue, 01 Aug 2017 19:57:14 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">23669@/two/discussions</guid>
      <description><![CDATA[<p>I saw the java method :</p>

<p>String[] fontList = PFont.list();
printArray(fontList);</p>

<p>But what is the method in python for discovering the font names?</p>
]]></description>
   </item>
   <item>
      <title>Could you please help me to make this processing.js code in html page work?</title>
      <link>https://forum.processing.org/two/discussion/23188/could-you-please-help-me-to-make-this-processing-js-code-in-html-page-work</link>
      <pubDate>Sat, 24 Jun 2017 01:28:09 +0000</pubDate>
      <dc:creator>LeonardoSaponara</dc:creator>
      <guid isPermaLink="false">23188@/two/discussions</guid>
      <description><![CDATA[<p>Hi to all,
I'm new to programming and I'm learning it mostly from Khan Academy.  Doing so I did some projects that I wanted to run off line, therefore I used a template to move it into an html page.  First to test the template I tried to move a simple visualization to the html page and it worked perfectly. Then I tried to move my little game inside the html page but it didn't work. I think that maybe the problem is in the way I tried to load image but I'm not perfectly sure. Here a github link with all the files, under testtest folder there is the visualization that work. 
Thank you very much for your help,  I tried everything but I'm still not able to figure what to do. 
Github link: <a href="https://github.com/LeonardoSaponara/Jump" target="_blank" rel="nofollow">https://github.com/LeonardoSaponara/Jump</a> //I resolved the problem migrating to p5.js therefore I've updated the project on Github, see old commit to view the code at time of my question.</p>
]]></description>
   </item>
   <item>
      <title>Simple "for" loop question</title>
      <link>https://forum.processing.org/two/discussion/13982/simple-for-loop-question</link>
      <pubDate>Tue, 15 Dec 2015 01:28:03 +0000</pubDate>
      <dc:creator>PHGNYC</dc:creator>
      <guid isPermaLink="false">13982@/two/discussions</guid>
      <description><![CDATA[<p>Relatively new to Processing.  Can't figure out why the code below doesn't work.  It DOES work if I remove the "void setup();" command before and after size.  I gather it messes with the "for" loop, but don't understand why.  Thanks.</p>

<p>void setup(); {
size(200,200);
}
// With a for loops
for (int x = 0; x &lt; width; x+=10) {
  for (int y = 0; y &lt; height; y+=10) {
    noStroke();
    fill(random(255));
    rect(x,y,10,10);
  }
}</p>
]]></description>
   </item>
   <item>
      <title>unexpected token: void on setup(){}</title>
      <link>https://forum.processing.org/two/discussion/13662/unexpected-token-void-on-setup</link>
      <pubDate>Thu, 26 Nov 2015 03:05:33 +0000</pubDate>
      <dc:creator>destrosjowl</dc:creator>
      <guid isPermaLink="false">13662@/two/discussions</guid>
      <description><![CDATA[<p>hello,</p>

<p>i have exactly the same code and the frame example for controlp5, but i keep getting flagged for this error and i don't see what is wrong. the example works just fine. i am using processing 2.X. i would appreciate and extra pair of eyes.</p>

<pre><code>import java.awt.Frame;
import java.awt.BorderLayout;

import controlP5.*;

private ControlP5 cp5;

ControlFrame interfaceControl;


void setup()  //unexpected token: void
{
    size(1280, 720, OPENGL);

    cp5 = new ControlP5(this);
    interfaceControl = addControlFrame("interfaceControl", 1024, 768);
}

void draw()
{
    background(0);
}

ControlFrame addControlFrame(String theName, int theWidth, int theHeight) {
    Frame f = new Frame(theName);
    ControlFrame p = new ControlFrame(this, theWidth, theHeight);
    f.add(p);
    p.init();
    f.setTitle(theName);
    f.setSize(p.w, p.h);
    f.setLocation(width/2, height/2);
    f.setResizable(false);
    f.setVisible(true);
    return p;
}

public class ControlFrame extends PApplet {
    int w, h;

    int thumbX = 11;
    int thumbY = 5;

    PImage [] hThumbsFiles;
    PImage [] vThumbsFiles;

    File horizontalThumbsFolder;
    File verticalThumbsFolder;

    String [] horizontalThumbsFilenames;
    String [] verticalThumbsFilenames;

    public void setup() {
        size(w, h);
        frameRate(30);

        cp5 = new ControlP5(this);

        hThumbsFiles = new PImage[horizontalImageFiles.length];
        vThumbsFiles = new PImage[verticalImageFiles.length];

        horizontalThumbsFolder = new File(sketchPath("data/images/hThumbnails/"));
        verticalThumbsFolder = new File(sketchPath("data/images/vThumbnails/"));

        char seperator = '.';

        horizontalThumbsFilenames = horizontalThumbsFolder.list();
        verticalThumbsFilenames = verticalThumbsFolder.list();
        //println("files: " + (horizontalThumbsFilenames.length) + ", " + (verticalThumbsFilenames.length) );

        for(int i = 0; i &lt; horizontalThumbsFilenames.length; i ++)
        {
            horizontalThumbsFilenames[i] = horizontalThumbsFilenames[i].substring(0, horizontalThumbsFilenames[i].indexOf(seperator));
            hThumbsFiles[i] = requestImage("data/images/hThumbnails/" + horizontalThumbsFilenames[i] + ".jpg");

            verticalThumbsFilenames[i] = verticalThumbsFilenames[i].substring(0, verticalThumbsFilenames[i].indexOf(seperator));
            vThumbsFiles[i] = requestImage("data/images/vThumbnails/v" + verticalThumbsFilenames[i] + ".jpg");
            // println(i + ": " + horizontalThumbsFilenames[i] + ", " + verticalThumbsFilenames[i]);
            // println();   
        }

        cp5.printPublicMethodsFor(Matrix.class);

        cp5.addMatrix("matrixH")
        .setPosition(142, 100)
        .setSize(320, 140) //275, 125, 5, 5
        .setGrid(thumbX, thumbY)
        .setGap(5, 5)
        .setMode(ControlP5.MULTIPLES)
        for(int i = index; index &lt; thumbX * thumbY; index ++) {
            .setImage(hThumbsFiles[i])
        }
        .setBackground(color(0))
        ;

        cp5.addMatrix("matrixV")
        .setPosition(562, 100)
        .setSize(320, 140) //275, 125, 5, 5
        .setGrid(thumbX, thumbY)
        .setGap(5, 5)
        .setMode(ControlP5.MULTIPLES)
        for(int i = index; index &lt; thumbX * thumbY; index ++) {
            .setImage(vThumbsFiles[i])
        }
        .setBackground(color(0))
        ;

        cp5.getController("matrixH").getCaptionLabel().alignX(CENTER);
        cp5.getController("matrixV").getCaptionLabel().alignX(CENTER);
    }

    public void draw() {
        background(0);
    }

    private ControlFrame() {

    }

    public ControlFrame(Object theParent, int theWidth, int theHeight) {
        parent = theParent;
        w = theWidth;
        h = theHeight;
    }

    public ControlP5 control() {
        return cp5;
    }

    ControlP5 cp5;
    Object parent;
}
</code></pre>

<p>thanks in advance,</p>

<p>destro</p>
]]></description>
   </item>
   <item>
      <title>setup vs. draw</title>
      <link>https://forum.processing.org/two/discussion/12676/setup-vs-draw</link>
      <pubDate>Thu, 24 Sep 2015 20:07:12 +0000</pubDate>
      <dc:creator>davidjameson</dc:creator>
      <guid isPermaLink="false">12676@/two/discussions</guid>
      <description><![CDATA[<p>I'm a new user to processing (but an experienced developer). For various reasons related to teaching programming concepts to new students, I'm actually just using the processing libraries inside IntelliJ and have everything working just fine, or so I thought :-)</p>

<p>One of my colleagues who had just been using the Processing IDE had a simple example where they were loading an image inside the setup() method as follows:</p>

<pre><code>        size(400, 400);
        img = loadImage("cat.jpg");//load image
        image(img, 0,0);
</code></pre>

<p>and indeed the image would be drawn.</p>

<p>However, the same thing does not work if we run this directly as a Java program and in particular, the call "image(img, 0, 0)" has to be inside the draw() method rather than the setup() method.</p>

<p>Now, that actually wasn't a surprise to me and indeed in the online documentation for PImage it's quite clear that the call SHOULD be inside the draw() method. My recommendation to my colleague is to do it right and put the call in draw()!</p>

<p>However, I'm still curious as to why  it works in the setup() in processing but not in Java. I noted that if I don't include an <a href="/two/profile/Override">@Override</a> version of draw() but put a call to draw() at the end of the setup() method, the image does draw, although very pixelated.</p>

<p>There must be some extra behind-the-scenes stuff going on. I looked for some calls for explicitly redrawing/repainting (found redraw() which didn't seem to do anything).</p>

<p>I realize there's an ANTLR preprocessor involved and perhaps some extra code is being injected into the end of the setup() method.</p>

<p>Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>problem on Explay Hit Android 4.2.2</title>
      <link>https://forum.processing.org/two/discussion/6552/problem-on-explay-hit-android-4-2-2</link>
      <pubDate>Thu, 31 Jul 2014 05:34:23 +0000</pubDate>
      <dc:creator>kenromka</dc:creator>
      <guid isPermaLink="false">6552@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm a beginner at Processing. Today I tried to make an easy application on Android (just to display some text and add a picture). But I got an error</p>

<p>So, here's my code:</p>

<pre><code>PFont f;
PImage img;

void setup() {
  size(displayWidth, displayHeight);

  img = loadImage("korona42.png");
}

void draw() {
  background(255);
  f = loadFont("Kristen-ITC.ttf");
  textFont(f, displayWidth/18);
  fill(0);
  text("KÖNIG  DEUTSCH", displayWidth/2-displayWidth/18/1.5*7, displayHeight/2);
  image(img, width/4.2, height*8.7/24, displayWidth/18, displayWidth/18/1.5);
}
</code></pre>

<p>Application doesn't work and that was written:</p>

<pre><code>_debug:
java.lang.NullPointerException: in == null
    at libcore.io.Streams.readFully(Streams.java:74)
    at java.io.DataInputStream.readInt(DataInputStream.java:124)
    at processing.core.PFont.&lt;init&gt;(Unknown Source)
    at processing.core.PApplet.loadFont(Unknown Source)
    at processing.test.logo.LOGO.draw(LOGO.java:30)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:838)
java.lang.RuntimeException: Could not load font Kristen-ITC.ttf. Make sure that the font has been copied to the data folder of your sketch.
    at processing.core.PApplet.die(Unknown Source)
    at processing.core.PApplet.die(Unknown Source)
    at processing.core.PApplet.loadFont(Unknown Source)
    at processing.test.logo.LOGO.draw(LOGO.java:30)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:838)
FATAL EXCEPTION: Animation Thread
java.lang.RuntimeException: Could not load font Kristen-ITC.ttf. Make sure that the font has been copied to the data folder of your sketch.
    at processing.core.PApplet.die(Unknown Source)
    at processing.core.PApplet.die(Unknown Source)
    at processing.core.PApplet.loadFont(Unknown Source)
    at processing.test.logo.LOGO.draw(LOGO.java:30)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:838)_
</code></pre>

<p>Where's my mistake?? Help please! I don't understand! [-O&lt;  :-S</p>
]]></description>
   </item>
   </channel>
</rss>