<?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 rectmode() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=rectmode%28%29</link>
      <pubDate>Sun, 08 Aug 2021 19:01:35 +0000</pubDate>
         <description>Tagged with rectmode() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedrectmode%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>car game</title>
      <link>https://forum.processing.org/two/discussion/27923/car-game</link>
      <pubDate>Sun, 06 May 2018 10:19:22 +0000</pubDate>
      <dc:creator>michyg</dc:creator>
      <guid isPermaLink="false">27923@/two/discussions</guid>
      <description><![CDATA[<p>Hi im trying to make a car game where the car needs to do a zig zag course through other cars. I cant moove the image for some reason.</p>

<pre><code>`Ship ship;
PImage img;
void setup() {
  size(800, 800);
  img = loadImage("Ecar.jpg");
  ship = new Ship();
  }

void draw() {
  background(51);
  ship.show();
  ship.move();
}
void keyPressed() {


  if (keyCode == RIGHT) {
    ship.setDir(1);
  } else if (keyCode == LEFT) {
    ship.setDir(-1);
  }
}`


`class Ship {
  float x, xdir;
  PShape car;

  Ship() {
    this.x = width/2-40;
    this.xdir = 0;
    noStroke();
    fill(255,0,0);
    car = createShape(RECT, this.x, height-300, 100, 200);
    car.setTexture(img);
  }

  void show() {
    fill(255);
    rectMode(CENTER);
    shape(car);
    //rect(this.x, height-50, 20, 60);
  }

  void setDir(float dir) {
    this.xdir = dir;
  }

  void move() {
    this.x += this.xdir*5;
  }
}`
</code></pre>
]]></description>
   </item>
   <item>
      <title>Converting Processing sketch to P5.js - 2D Arrays</title>
      <link>https://forum.processing.org/two/discussion/27728/converting-processing-sketch-to-p5-js-2d-arrays</link>
      <pubDate>Mon, 09 Apr 2018 19:25:37 +0000</pubDate>
      <dc:creator>borgejor</dc:creator>
      <guid isPermaLink="false">27728@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I am new to P5.js and I need some help reformating my 2D array. Can anyone tell me how it is done in P5.js? This is my sketch for simple application I am making and I want it on my demo site. The 2D Array below is for calling the different pattens.</p>

<p>`   PShape[][] shapes = new PShape[4][4];</p>

<pre><code>var boxCount = 3;
var[] positions = new var [boxCount] ;

var boxSize = 50;
var draggingBox = false;
var boxBeingDragged = 0;
var dragOffset = createVector(0, 0); 

var logo;
var index = 0;
function setup() 
{
   logo = loadImage("thesis_logo.png");
  createCanvas(1920, 1080, P2D); 
  rectMode(CENTER);

  for (var j=0; j &lt; boxCount; j++) {
    var x = random(100, 600);
    var y = random(400, 680);
    positions[j]=  createVector(x, y);
  }
  noStroke();
  fill(#5BC0EB);

  shapes[0][0] = createShape(RECT,1440,450,boxSize,boxSize);
  fill(#000000);
  shapes[0][1] = createShape(RECT,1440,510,boxSize,boxSize);
  shapes[0][2] = createShape(RECT,1440,570,boxSize,boxSize);
  shapes[0][3] = createShape(RECT,1440,630,boxSize,boxSize);

   fill(#5BC0EB);
  shapes[1][0] = createShape(RECT,1350,540,boxSize,boxSize);
  fill(#000000);
  shapes[1][1] = createShape(RECT,1410,540,boxSize,boxSize);
  shapes[1][2] = createShape(RECT,1470,540,boxSize,boxSize);
  shapes[1][3] = createShape(RECT,1530,540,boxSize,boxSize);


  fill(#5BC0EB);
  shapes[2][0] = createShape(RECT,1410,510,boxSize,boxSize);
  fill(#000000);
  shapes[2][1] = createShape(RECT,1470,510,boxSize,boxSize);
  shapes[2][2] = createShape(RECT,1410,570,boxSize,boxSize);
  shapes[2][3] = createShape(RECT,1470,570,boxSize,boxSize);

  fill(#5BC0EB);
   shapes[3][0] = createShape(RECT,1410,480,boxSize,boxSize);
   fill(#000000);
  shapes[3][1] = createShape(RECT,1470,480,boxSize,boxSize);
  shapes[3][2] = createShape(RECT,1410,540,boxSize,boxSize);
  shapes[3][3] = createShape(RECT,1410,600,boxSize,boxSize);
  patternChange();

}

function draw() 
{ 
  background(255);
  fill(#5BC0EB);
  noStroke();
  rect(480,540,50,50);
  for(var j =0; j &lt; 4;j++){
    fill(0);
   shape(shapes[index][j],50,50,boxSize,boxSize);
  }


    stroke(0);
  strokeWeight(2);
  line(width/2,0,width/2,height);
   for (var j=0; j &lt; boxCount; j++) {
    if (draggingBox &amp;&amp; j == boxBeingDragged) {
      stroke(255);  // white
    } else {
      noStroke();
    }
    rect( positions[j].x, positions[j].y, boxSize, boxSize) ;
  }

  patternChange();

image(logo, 50, 50, width/8, height/8);

}

function mousePressed() {
  grabBox();
}

function mouseReleased() {
  draggingBox = false;
}

function mouseDragged() {
  if (draggingBox) {
    positions[boxBeingDragged].x = mouseX + dragOffset.x;
    positions[boxBeingDragged].y = mouseY + dragOffset.y;
  }
}
//
function grabBox() {
  for (var i=0; i &lt; boxCount; i++) {
    // Test if the cursor is over the box
    var left = mouseX &gt; positions[i].x - boxSize/2;
    var right = mouseX &lt; positions[i].x + boxSize/2;
    var top = mouseY &gt; positions[i].y - boxSize/2;
    var bottom = mouseY &lt; positions[i].y + boxSize/2;
    if ( left  &amp;&amp; right &amp;&amp; top &amp;&amp; bottom) {
      prvarln ("mouseover box: "+i);
      boxBeingDragged=i;
      draggingBox = true;
      dragOffset.x = positions[i].x - mouseX;
      dragOffset.y = positions[i].y - mouseY;
      break;
    } else {
      draggingBox = false;
    }
  }
}


function patternChange(){

 if (keyPressed) { //switch statement for changing grid createCanvas
    switch(key){
    case '1':
index = 0;
scramble();
    break;
    case '2':
index = 1;
scramble();
    break;
       case '3':
index = 2;
scramble();
    break;

           case '4':
index = 3;
scramble();
    break;
    }
    }
}

function scramble(){
 for (var j=0; j &lt; boxCount; j++) {
    var x = random(100, 600);
    var y = random(400, 680);
    positions[j]=  createVector(x, y);
  }
}`
</code></pre>
]]></description>
   </item>
   <item>
      <title>GLSL and video Texture</title>
      <link>https://forum.processing.org/two/discussion/26054/glsl-and-video-texture</link>
      <pubDate>Sat, 20 Jan 2018 23:12:54 +0000</pubDate>
      <dc:creator>vjjv</dc:creator>
      <guid isPermaLink="false">26054@/two/discussions</guid>
      <description><![CDATA[<p>hello everyone. Im trying to pass a video as a texture into a fragment shader. but the sketch crash when i run it.</p>

<p>here is the code:</p>

<pre><code>  import processing.video.*;
import peasy.*;
import peasy.org.apache.commons.math.*;
import peasy.org.apache.commons.math.*;

PeasyCam cam;
PShader sh;
float count;
Movie mov;
PGraphics p;

void setup (){

size(1440, 900, P3D );
mov = new Movie(this, "osc_noc.mov");
mov.play();
p = createGraphics(width,height);
cam = new PeasyCam(this, 500);
sh = loadShader("basicShaderFrag.glsl", "basicShader.glsl");
}

void movieEvent(Movie m) {
  m.read();
}

void draw(){
background(0);
shader(sh);
count +=0.09;
sh.set("u_time", count);

sphere(100);
p.beginDraw();
p.background(0);
p.image(mov, 0, 0, 200, 200);
p.endDraw();
sh.set("tex",p);
// image(p, 5, 260 ,200, 200);
}

#version 150

uniform mat4 transform;
uniform sampler2D tex;

in vec4 position;
in vec2 texCoord;
in vec3 normal;

out vec2 TexCoord;

void main(){

  TexCoord = texCoord;
  gl_Position = transform * position;
}


#ifdef GL_ES
precision mediump float;
#endif

#define PI 3.14

in vec2 TexCoord;
uniform float u_time;
uniform sampler2D tex;

void main(){
  vec2 uv = TexCoord;

  gl_FragColor = vec4(texture(tex, TexCoord));
}
</code></pre>

<p>a white screen appears, and next it close. the console just say: "Finished". 
it may be a bug? i could pass a PImage as a texture. but when i link the fragment and shader program into the sketch folder then crash. ..</p>
]]></description>
   </item>
   <item>
      <title>Changing color wheel settings - controlP5</title>
      <link>https://forum.processing.org/two/discussion/24720/changing-color-wheel-settings-controlp5</link>
      <pubDate>Tue, 24 Oct 2017 16:39:25 +0000</pubDate>
      <dc:creator>Bigfoot</dc:creator>
      <guid isPermaLink="false">24720@/two/discussions</guid>
      <description><![CDATA[<p>Hey! 
I would like to be able to control the settings for this color wheel. I would like to remove the grey background behind the color wheel, so its just the wheel and a white background all over + remove the rectangle displaying the color underneath the color wheel so that its only displayed in the rectangle to the right. 
Anyone know how to do this?</p>

<pre><code>import controlP5.*;

ControlP5 cp5;

void setup() {
  size(500, 400);
  cp5 = new ControlP5( this );
  //"c", x position, yposition, størrelse
  cp5.addColorWheel("c", 50, 50, 240)
  .setRGB(color(128, 0, 255));
}

int c = color(100);

void draw() {  
  background(255);
  fill( c );
  stroke(0);
  rectMode(CENTER); 
  rect(400, height/2, 50, 50);
  println(cp5.get(ColorWheel.class, "c").getRGB());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to draw with color tracking?</title>
      <link>https://forum.processing.org/two/discussion/25866/how-to-draw-with-color-tracking</link>
      <pubDate>Mon, 08 Jan 2018 05:31:41 +0000</pubDate>
      <dc:creator>sph_831</dc:creator>
      <guid isPermaLink="false">25866@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I watched a lot of Daniel Shiffman tutorials and wanted to write a piece of code that draws out the path in which a certain color moves across the screen in my video. Lets say if my video were a skateboard, and I did a trick with color wheels on, I'd like to have the program draw the movement by following the colored wheels throughout it's movement.</p>

<p>What I have so far:</p>

<pre><code>// Most of this code I learned how to write thanks to Daniel Shiffman

import processing.video.*;

Movie video;

color trackColor; 
float threshold = 20;
float distThreshold = 75;

ArrayList&lt;Blob&gt; blobs = new ArrayList&lt;Blob&gt;();

void setup() {
  size(1080, 720);
  video = new Movie(this, "sk8.mov");
  video.loop();
  trackColor = color(206, 74, 129);
}

void movieEvent(Movie video) {
  video.read();
}

void keyPressed() {
  if (key == 'a') {
    distThreshold++;
  } else if (key == 'z') {
    distThreshold--;
  }
  println(distThreshold);
}

void draw() {
  video.loadPixels();
  image(video, 0, 0);

  blobs.clear();

  threshold = 62;

  for (int x = 0; x &lt; video.width; x++ ) {
    for (int y = 0; y &lt; video.height; y++ ) {
      int loc = x + y * video.width;
      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) {

        boolean found = false;
        for (Blob b : blobs) {
          if (b.isNear(x, y)) {
            b.add(x, y);
            found = true;
            break;
          }
        }

        if (!found) {
          Blob b = new Blob(x, y);
          blobs.add(b);
        }
      }
    }
  }

  for (Blob b : blobs) {
    if (b.size() &gt; 500) {
      b.show();
    }
  }
}


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

void mousePressed() {
  // Save color where the mouse is clicked in trackColor variable
  int loc = mouseX + mouseY*video.width;
  trackColor = video.pixels[loc];
}
class Blob {
  float minx;
  float miny;
  float maxx;
  float maxy;

  Blob(float x, float y) {
    minx = x;
    miny = y;
    maxx = x;
    maxy = y;
  }

  void show() {
    stroke(0);
    fill(255);
    strokeWeight(2);
    rectMode(CORNERS);
    rect(minx, miny, maxx, maxy);
  }

  void add(float x, float y) {
    minx = min(minx, x);
    miny = min(miny, y);
    maxx = max(maxx, x);
    maxy = max(maxy, y);
  }

  float size() {
    return (maxx-minx)*(maxy-miny); 
  }

  boolean isNear(float x, float y) {
    float cx = (minx + maxx) / 2;
    float cy = (miny + maxy) / 2;

    float d = distSq(cx, cy, x, y);
    if (d &lt; distThreshold*distThreshold) {
      return true;
    } else {
      return false;
    }
  }
}
</code></pre>

<p>What this code successfully does is track the color of the wheels on my skateboard, and follows the wheels throughout the clip. However, I am trying to figure out how to make it not just follow the wheels, but draw a line in the path where the wheels were before.</p>

<p>Any help would be greatly appreciated.</p>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>Animating a rotation, but it isn't working</title>
      <link>https://forum.processing.org/two/discussion/25822/animating-a-rotation-but-it-isn-t-working</link>
      <pubDate>Thu, 04 Jan 2018 23:12:22 +0000</pubDate>
      <dc:creator>jojo</dc:creator>
      <guid isPermaLink="false">25822@/two/discussions</guid>
      <description><![CDATA[<p>Hello! I am making a project that involves a lots of shapes and then animating some of them. Awhile i was trying to make this one square with a circle inside rotate, I ran into multiple problems.
This are the objects that I am trying to rotate (that are, of course, in void draw() ):</p>

<pre><code>  fill(237, 26, 55);
  rect(336, 605, 112, 121);

  fill(255);
  ellipse(392, 662, 63, 63);
</code></pre>

<p>So, firstly I tried using only rotate(PI/2) before that, but it just disappeared.
Then I tried translate, in case that was what was missing, but once again nothing. I thought that maybe rectMode(CENTER) would finally make everything work, but it actually made everything move out of place! I tried putting everything between  push and pop matrix but it didn't work. I don't understand what is happening or what I am doing wrong. And the thing is that I moved these objects to the end of the code so it wouldn't interfere with the rest. I searched everywhere but I cannot find anything to help me.
Thank you for your time.</p>
]]></description>
   </item>
   <item>
      <title>How to work with rectMode(CENTER)?</title>
      <link>https://forum.processing.org/two/discussion/25760/how-to-work-with-rectmode-center</link>
      <pubDate>Sat, 30 Dec 2017 14:49:45 +0000</pubDate>
      <dc:creator>Mimmi_97</dc:creator>
      <guid isPermaLink="false">25760@/two/discussions</guid>
      <description><![CDATA[<p>have to design this rose and already started with constructing...but i dont know how to continue. <img src="" alt="" />![Idee2](<a href="https://forum.processing.org/two/uploads/imageupload/324/VWDLQMDUCF1K.PNG" target="_blank" rel="nofollow">https://forum.processing.org/two/uploads/imageupload/324/VWDLQMDUCF1K.PNG</a> "Idee</p>

<p>what i have already done with processing: <img src="https://forum.processing.org/two/uploads/imageupload/706/WY3MMTNWVJM1.JPG" alt="javascrpt" title="javascrpt" /></p>

<p>and this is my code:<img src="https://forum.processing.org/two/uploads/imageupload/587/U8D68ZLRUC33.JPG" alt="code" title="code" /></p>
]]></description>
   </item>
   <item>
      <title>Very basic question about pixels</title>
      <link>https://forum.processing.org/two/discussion/25485/very-basic-question-about-pixels</link>
      <pubDate>Sun, 10 Dec 2017 02:58:54 +0000</pubDate>
      <dc:creator>Cap</dc:creator>
      <guid isPermaLink="false">25485@/two/discussions</guid>
      <description><![CDATA[<p>How do you find the center pixel?</p>

<p>Say I have the width set at an even number of pixels, 8.</p>

<p>Pixels going across pizel 0, pixel 1...  to pixel 7.</p>

<p>I would think initially that to get to the centre, you'd  say (8-1)/2 but this would be 3.5, and there's no pixel 3.5, so how would processing resolve this? Round up to pixel 4? And settle for an off-centre pixel?</p>

<p>Or should I say 8/4, instead of minusing 1 for the zero that gets counted?</p>
]]></description>
   </item>
   <item>
      <title>Draw difference between p5js rect and canvas API rect</title>
      <link>https://forum.processing.org/two/discussion/24384/draw-difference-between-p5js-rect-and-canvas-api-rect</link>
      <pubDate>Wed, 04 Oct 2017 20:20:40 +0000</pubDate>
      <dc:creator>julson</dc:creator>
      <guid isPermaLink="false">24384@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys! I've been playing with p5js again lately and I'm trying to wrap my head around why using the canvas APIs rect produces a different rectangle from p5js</p>

<p>This code for example:</p>

<pre lang="javascript">
function setup() {
  createCanvas(300, 300);
  rectMode(CORNERS);
  noLoop();
}

function draw() {
  background(102);
  stroke(0, 0, 0);
  rect(0, 10, 100, 100);

  var c = document.getElementById("defaultCanvas0");
  var ctx = c.getContext('2d');
  ctx.rect(101, 10, 100, 100);
  ctx.stroke();
}
</pre>

<p>has the p5js rect having a slightly reduced height compared to the canvas API version. 
Any idea why?</p>
]]></description>
   </item>
   <item>
      <title>In P3D, the rendered and rotated ellipse at mouse position is hidden by half of another shape</title>
      <link>https://forum.processing.org/two/discussion/23183/in-p3d-the-rendered-and-rotated-ellipse-at-mouse-position-is-hidden-by-half-of-another-shape</link>
      <pubDate>Fri, 23 Jun 2017 17:54:25 +0000</pubDate>
      <dc:creator>ITISLTW</dc:creator>
      <guid isPermaLink="false">23183@/two/discussions</guid>
      <description><![CDATA[<p><img src="https://forum.processing.org/two/uploads/imageupload/928/GUHOD50S0KYV.png" alt="111" title="111" />
<img src="https://forum.processing.org/two/uploads/imageupload/634/4Y4GR0FOQSVR.png" alt="222" title="222" />
<img src="https://forum.processing.org/two/uploads/imageupload/209/MM2XC7534TFF.png" alt="333" title="333" /></p>

<p>Both ellipse and rectangle plane have same rotation, and ellipse's z index is 1 higher than rectangle's.
The wired thing is when the mouse position is below the rectangle's y position, the ellipse will be hidden behind the rectangle.</p>

<p>This trobules me a lot, anyone has a good idea?</p>

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

<pre><code>void setup() {
  frameRate(60);
  size(1000, 1000, P3D);
  smooth(6);
}

void draw() {
  background(120);

  pushMatrix();
  pushStyle();
  noStroke();
  translate(width/2, height/2, 0);
  rotateX(1);
  rectMode(CENTER);
  rect(0, 0, 800, 800);
  fill(0);
  textAlign(CENTER, CENTER);
  textSize(120);
  text("TEST", 0, 0, 1);
  popStyle();
  popMatrix();

  pushMatrix();
  pushStyle();
  translate(mouseX, mouseY, 1);
  rotateX(1);
  fill(0);
  ellipse(0, 0, 50, 50);
  popStyle();
  popMatrix();

}
</code></pre>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>How do i centre a rotating object in P5JS</title>
      <link>https://forum.processing.org/two/discussion/23012/how-do-i-centre-a-rotating-object-in-p5js</link>
      <pubDate>Sat, 10 Jun 2017 15:07:46 +0000</pubDate>
      <dc:creator>crashpotato</dc:creator>
      <guid isPermaLink="false">23012@/two/discussions</guid>
      <description><![CDATA[<pre><code>**This is my code.** 
It can rotate but it is moving at the same time. I want it to stay centred. Thank you.


var cY
var cX
var cX1
var cY1var cY
var cX
var cX1
var cY1
var cX2
var cY2
var rX
var rY
var r
var t

function setup() {
  r = 1
  translate(width / 2, height / 2);
  createCanvas(400, 400);
  background('black');

  cX = 80
  cY = 100
  cX1 = 250
  cY1 = 440
  cX2 = 167
  cY2 = 250
  fill('red')
  rect(70, 60, 150, 72)
  fill('red')
  noStroke()
  translate(width / 2, height / 2);
  rotate(45.09);
  rect(-104, 27, 150, 72);
  rotate(-45.09);
  translate(-width / 2, -height / 2);
  translate(width / 2, height / 2);
  rotate(90.18);
  rect(-100, -32, 160, 72);
  rotate(-90.18);
  translate(-width / 2, -height / 2);
  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX, cY, 100, 100)
  fill('grey')
  ellipse(cX, cY, 100, 100)
  fill('black')
  ellipse(cX, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX1, cY, 100, 100)
  fill('grey')
  ellipse(cX1, cY, 100, 100)
  fill('black')
  ellipse(cX1, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX2, cY2, 100, 100)
  fill('grey')
  ellipse(cX2, cY2, 100, 100)
  fill('black')
  ellipse(cX2, cY2, 70, 70)

  function setup() {
    createCanvas(400, 400);
  }


}
rX = 100
rY = 150

function draw() {
  background('black')
  r = r + 0.1
  translate(width / 2 - 40, height / 2 - 12);
  rotate(r)
  translate(-width / 2 + 40, -height / 2 + 12);
  fill('red')
  rect(70, 60, 150, 72)
  fill('red')
  noStroke()
  translate(width / 2, height / 2);
  rotate(45.09);
  rect(-104, 27, 150, 72);
  rotate(-45.09);
  translate(-width / 2, -height / 2);
  translate(width / 2, height / 2);
  rotate(90.18);
  rect(-100, -32, 160, 72);
  rotate(-90.18);
  translate(-width / 2, -height / 2);
  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX, cY, 100, 100)
  fill('grey')
  ellipse(cX, cY, 100, 100)
  fill('black')
  ellipse(cX, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX1, cY, 100, 100)
  fill('grey')
  ellipse(cX1, cY, 100, 100)
  fill('black')
  ellipse(cX1, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX2, cY2, 100, 100)
  fill('grey')
  ellipse(cX2, cY2, 100, 100)
  fill('black')
  ellipse(cX2, cY2, 70, 70)



}
var cX2
var cY2
var rX
var rY
var r
var t

function setup() {
  r = 1
  translate(width / 2, height / 2);
  createCanvas(400, 400);
  background('black');

  cX = 80
  cY = 100
  cX1 = 250
  cY1 = 440
  cX2 = 167
  cY2 = 250
  fill('red')
  rect(70, 60, 150, 72)
  fill('red')
  noStroke()
  translate(width / 2, height / 2);
  rotate(45.09);
  rect(-104, 27, 150, 72);
  rotate(-45.09);
  translate(-width / 2, -height / 2);
  translate(width / 2, height / 2);
  rotate(90.18);
  rect(-100, -32, 160, 72);
  rotate(-90.18);
  translate(-width / 2, -height / 2);
  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX, cY, 100, 100)
  fill('grey')
  ellipse(cX, cY, 100, 100)
  fill('black')
  ellipse(cX, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX1, cY, 100, 100)
  fill('grey')
  ellipse(cX1, cY, 100, 100)
  fill('black')
  ellipse(cX1, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX2, cY2, 100, 100)
  fill('grey')
  ellipse(cX2, cY2, 100, 100)
  fill('black')
  ellipse(cX2, cY2, 70, 70)

  function setup() {
    createCanvas(400, 400);
  }


}
rX = 100
rY = 150

function draw() {
  background('black')
  r = r + 0.1
  translate(width / 2 - 40, height / 2 - 12);
  rotate(r)
  translate(-width / 2 + 40, -height / 2 + 12);
  fill('red')
  rect(70, 60, 150, 72)
  fill('red')
  noStroke()
  translate(width / 2, height / 2);
  rotate(45.09);
  rect(-104, 27, 150, 72);
  rotate(-45.09);
  translate(-width / 2, -height / 2);
  translate(width / 2, height / 2);
  rotate(90.18);
  rect(-100, -32, 160, 72);
  rotate(-90.18);
  translate(-width / 2, -height / 2);
  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX, cY, 100, 100)
  fill('grey')
  ellipse(cX, cY, 100, 100)
  fill('black')
  ellipse(cX, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX1, cY, 100, 100)
  fill('grey')
  ellipse(cX1, cY, 100, 100)
  fill('black')
  ellipse(cX1, cY, 70, 70)

  fill('black')
  stroke('red')
  strokeWeight(7);
  ellipse(cX2, cY2, 100, 100)
  fill('grey')
  ellipse(cX2, cY2, 100, 100)
  fill('black')
  ellipse(cX2, cY2, 70, 70)



}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Change the origin of a rectangle, so that it draws from the top-right corner.</title>
      <link>https://forum.processing.org/two/discussion/22870/change-the-origin-of-a-rectangle-so-that-it-draws-from-the-top-right-corner</link>
      <pubDate>Fri, 02 Jun 2017 07:46:45 +0000</pubDate>
      <dc:creator>Gerdon</dc:creator>
      <guid isPermaLink="false">22870@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I need help in drawing a rectangle from its top-right corner, rather than the top-left corner. I've tried using rectMode() but still can't figure out how to get it to its top-right corner. Is there any possible way to do this?</p>
]]></description>
   </item>
   <item>
      <title>Given two points (vectors), plot a 3rd so all three can be bisected by a straight line</title>
      <link>https://forum.processing.org/two/discussion/21445/given-two-points-vectors-plot-a-3rd-so-all-three-can-be-bisected-by-a-straight-line</link>
      <pubDate>Fri, 17 Mar 2017 01:44:40 +0000</pubDate>
      <dc:creator>noponies</dc:creator>
      <guid isPermaLink="false">21445@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have small issue with creating linked beziers in that the link between each bezier is not that smooth. I'm using bezierVertex to draw the connected beziers.</p>

<p>What I'm trying to do is smooth out this join, and from what I understand I need to do the following "In order to make two curves A and B smoothly continuous, the last control point of A, the last point of A, and the first control point of B have to be on a straight line."</p>

<p>So, given two vectors like so;</p>

<pre><code>function setup() {
    createCanvas(windowWidth, windowHeight);
    background(255);
    noLoop();

    rectMode(CENTER);


    var v1 = createVector(random(200, 300), random(200, 300));
    var v2 = createVector(random(100, 400), random(300, 400));

    ellipse(v1.x, v1.y, 20, 20);
    ellipse(v2.x, v2.y, 20, 20);


    var angle = p5.Vector.angleBetween(v1, v2);

    console.log(angle, radians(angle));

    ellipse( 200 * sin(angle) , 200 * cos(angle), 30, 30);
}
</code></pre>

<p>I want to be able to plot the 3rd, so that I can set the control point of the next bezier in my in a straight line, and smooth the bezier connection point.</p>

<p>Thanks in advance.</p>

<p>First time using p5. I'm converting an old Director project as a learning exercise. The Director version looks like this; <a href="https://goo.gl/photos/K6zmabEyPUgTsmYMA" target="_blank" rel="nofollow">https://goo.gl/photos/K6zmabEyPUgTsmYMA</a></p>
]]></description>
   </item>
   <item>
      <title>How can i make each rectangle rotate along the y-axis on their own x positions?</title>
      <link>https://forum.processing.org/two/discussion/21976/how-can-i-make-each-rectangle-rotate-along-the-y-axis-on-their-own-x-positions</link>
      <pubDate>Thu, 13 Apr 2017 15:07:59 +0000</pubDate>
      <dc:creator>preet04</dc:creator>
      <guid isPermaLink="false">21976@/two/discussions</guid>
      <description><![CDATA[<p>function setup(){
    createCanvas(1000, 400);
    rectMode(CENTER);
}
function draw(){
    background(240);</p>

<pre><code>translate(150, 150); 

rotate(radians(mouseY));

fill(0);
rect(0, 0, 100, 100);
rotate(radians(mouseY));
fill(0);
rect(200, 0, 100, 100);
rotate(radians(mouseY));
fill(0);
rect(400, 0, 100, 100);
</code></pre>

<p>}</p>
]]></description>
   </item>
   <item>
      <title>blendMode() doesn't work with text</title>
      <link>https://forum.processing.org/two/discussion/21730/blendmode-doesn-t-work-with-text</link>
      <pubDate>Fri, 31 Mar 2017 13:44:15 +0000</pubDate>
      <dc:creator>Patakk</dc:creator>
      <guid isPermaLink="false">21730@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>In my program I want to use different blend modes when drawing text, but the text is not affected by the <em>blendMode()</em> function call.</p>

<p>Here's a simple program that demonstrates the issue, just move the mouse over the rectangle and see how the ellipse is correctly blended, as opposed to the letter 'K'.</p>

<pre><code>void setup(){
    size(600, 600, P2D);

    rectMode(CENTER);
    textSize(100);
    textAlign(CENTER, CENTER);
}

void draw(){
    blendMode(NORMAL);
    background(50);

    noStroke();
    fill(255);
    rect(300, 300, 100, 100);

    blendMode(EXCLUSION);
    text("K", mouseX+50, mouseY);
    ellipse(mouseX-50, mouseY, 75, 75);
}
</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 keep a moving obj in the center of the screen</title>
      <link>https://forum.processing.org/two/discussion/21047/how-to-keep-a-moving-obj-in-the-center-of-the-screen</link>
      <pubDate>Tue, 28 Feb 2017 07:19:27 +0000</pubDate>
      <dc:creator>ziphead2</dc:creator>
      <guid isPermaLink="false">21047@/two/discussions</guid>
      <description><![CDATA[<p>Hello. I've got two objects here : Red prototype "square" and its child green "zz". What I want is to click on the object and focus the screen on it. Make it stuck to it even when it moves. I can manage the clicking function but need a hint for the centering concept here.</p>

<pre><code>    var angle;


    var Polygon= function(x, y, hi, wei) {
        this.x = x;
        this.y = y;
        this.height = hi;
        this.width = wei;
    }
      Polygon.prototype.display = function() {
          push();
          translate(this.x, this.y);

          rect(0, 0,this.height, this.width);
          pop();
      }

      Polygon.prototype.area = function () {
        return this.calcArea();
      }

      Polygon.prototype.calcArea = function () {
        return this.height * this.width;
      }

    function Protogon(x, y, hi, wei, word) {
      Polygon.call(this, x, y, hi, wei);
      this.word = word;

    };

    Protogon.prototype= Object.create(Polygon.prototype); 
    Protogon.prototype.constructor = Protogon;
    Protogon.prototype.display = function() {
          push();
          translate(this.x, this.y);
          rotate(angle);
          rect(50, 0,this.height, this.width);
          text(this.word, 50, -10);
          pop();
    }

    function setup() {
      createCanvas(720, 400);
      angle = 1.0;
      square = new Polygon(width/2, height/2, 20, 40);
      zz = new Protogon(square.x+20, square.y+20, 60, 40, "Hello");
    }

    function draw() {
      background(50, 89, 100);
      stroke(1);
      fill('red'); 
      square.display();
      fill('green');
      zz.display();
      angle+=0.01 ;
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Reading a variable in processing core</title>
      <link>https://forum.processing.org/two/discussion/20934/reading-a-variable-in-processing-core</link>
      <pubDate>Tue, 21 Feb 2017 20:42:44 +0000</pubDate>
      <dc:creator>prince_polka</dc:creator>
      <guid isPermaLink="false">20934@/two/discussions</guid>
      <description><![CDATA[<p>For example rectMode in PGraphics,
rectMode() is a void function, but there seems to also be an int variable called rectMode and how do I read that variable?</p>

<blockquote class="Quote">
  <p>int   rectMode The current rect mode (read-only)<br />
  <a rel="nofollow" href="http://processing.github.io/processing-javadocs/core/processing/core/PGraphics.html#rectMode">processing.github.io/processing-javadocs/core/processing/core/PGraphics.html#rectMode</a></p>
</blockquote>

<p>Sorry if this is a dumb question</p>
]]></description>
   </item>
   <item>
      <title>2D rendering with positive y-axis going up (solved)</title>
      <link>https://forum.processing.org/two/discussion/20930/2d-rendering-with-positive-y-axis-going-up-solved</link>
      <pubDate>Tue, 21 Feb 2017 17:31:49 +0000</pubDate>
      <dc:creator>bearmountainbranch</dc:creator>
      <guid isPermaLink="false">20930@/two/discussions</guid>
      <description><![CDATA[<p>I want to write <code>somefunction(float xmin, float xmax, float ymin, float ymax)</code> which maps coordinates like:</p>

<pre><code> 0,0 +--------+                              +---------+  xmax, ymax
     |        |                to            |         |
     |        |                              |         |
     +--------+ width,height       xmin,ymin +---------+
</code></pre>

<p>I could do this in processing 2 but changes in 3 invalidates previous method.</p>
]]></description>
   </item>
   <item>
      <title>Scale + noFill not working ?</title>
      <link>https://forum.processing.org/two/discussion/20537/scale-nofill-not-working</link>
      <pubDate>Sun, 29 Jan 2017 16:43:04 +0000</pubDate>
      <dc:creator>marc_nostromo</dc:creator>
      <guid isPermaLink="false">20537@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to use scale and I'm puzzle by the result of the following code:</p>

<pre><code>void setup()
{
  size(1000, 600);
  noLoop();
}

void draw()
{
  scale(width/2, height/4);
  noFill();
  rect(0,0,1,1);
}
</code></pre>

<p>I'm expecting a unfilled rectange taking half the width and quarter the height but I'm seeing a filled rectange with strange boundaries.</p>

<p>Is there any reason or is this a bug ? The same happens with shapes.</p>
]]></description>
   </item>
   <item>
      <title>Absoltelly Strange error</title>
      <link>https://forum.processing.org/two/discussion/19507/absoltelly-strange-error</link>
      <pubDate>Sun, 04 Dec 2016 16:01:51 +0000</pubDate>
      <dc:creator>Meldiron</dc:creator>
      <guid isPermaLink="false">19507@/two/discussions</guid>
      <description><![CDATA[<p>Part of code:
  noStroke();
  fill(#f1c40f);
  stroke(255);
  rect(0,0,width,height);
  stroke(80);
  line(0,0,width,height);</p>

<p>Output:
<img src="http://i.imgur.com/2QuEy7C.png" alt="" /></p>

<p>Important part: Line and rectangle from top left</p>
]]></description>
   </item>
   <item>
      <title>Adding the number of boxes</title>
      <link>https://forum.processing.org/two/discussion/19078/adding-the-number-of-boxes</link>
      <pubDate>Wed, 16 Nov 2016 20:01:16 +0000</pubDate>
      <dc:creator>123nqk456</dc:creator>
      <guid isPermaLink="false">19078@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone, I have a problem with my project. I want to add more boxes into my project by mousePressed function.</p>

<pre><code>Box[] boxes=new Box[5];
 void setup(){
   size(200,200);
   rectMode(CENTER);
   for(int i=0;i&lt;boxes.length;i++){
     boxes[i]= new Box( random(100),random(100), random(5,15)
     );
   }
 }
  void draw(){
    background(192);
    for(int i=0;i&lt;boxes.length;i++){
      boxes[i].draw();
    }
    for(int j=0;j&lt;boxes.length;j++){
      for(int k=0; k&lt; boxes.length; k++){
        if(j !=k){
          boxes[j].attract(boxes[k]);
        }
      }
    }
  }

  void mousePressed(){
    for(int i=0;i&lt;boxes.length;i++){
      boxes[i].mousePressed();
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Text array in p5js</title>
      <link>https://forum.processing.org/two/discussion/18026/text-array-in-p5js</link>
      <pubDate>Wed, 31 Aug 2016 17:36:33 +0000</pubDate>
      <dc:creator>alexdontsurf</dc:creator>
      <guid isPermaLink="false">18026@/two/discussions</guid>
      <description><![CDATA[<p>Hello there,</p>

<p>I am trying to reproduce an old sketch in p5js but I ran into troubles...</p>

<p>Here is the code</p>

<pre><code>var fontRegular, fontBold

var offset = 20
var z = 0.0

function preload(){

    fontRegular = loadFont("assets/Regular.otf")
    fontBold = loadFont("assets/Bold.otf")
}


function setup() {

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

}

function draw() {

    background(5)       

    var chars = "+ — I O"
    var splitString = split(chars, " ");

    textFont(fontRegular);
    fill(0,0,100).strokeWeight(0).textSize(20)
    text(s, 10, 10, 200, 80)

    for ( var x = offset; x &lt; width - offset; x += offset){
        for (var y = offset; y &lt; height - offset; y += offset){


            var nl = map(noise(z, x/450.0, y/450.0), 0, 1, 0, 3)

            text(chars[nl], x, y)
        }
    }

    z = z + .0006

}
</code></pre>

<p>Console is given me an error from the p5.js library:
p5.js:12854 Uncaught TypeError: Cannot read property 'toString' of undefined</p>

<p>This is the original sketch that works perfectly in Processing:</p>

<pre><code>float z = 0.0;
PFont myFont;
int offset = 18;

void setup(){
  size(500,700);
  pixelDensity(displayDensity());
  //colorMode(HSB, 360,300,360);
  noStroke();
  myFont = createFont("MaisonNeue-Bold", 10);
  textFont(myFont);
  textAlign(CENTER, CENTER);

}

void draw() {

  background(255);
  String[] chars = split("+ — I O + C", ' ');

  for ( int x = offset*3; x &lt; width-offset*2; x +=offset){
    for ( int y = offset*3; y &lt; height-offset*2; y += offset){

      int nl = (int) map(noise(z, x / 450.0, y / 450.0), 0, 1, 0, 7);

      fill(0);
      rectMode(CENTER);
      if ((y - 16) % (2) == 0){
        text(chars[nl], x,y );}
        else{
        text(chars[nl], x + 8 ,y);
        }

    }
  }

  z = z + .006;

}
</code></pre>

<p>I'm guessing I am doing something wrong with arrays in p5js...</p>

<p>Any suggestions?</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Get current rectMode() setting</title>
      <link>https://forum.processing.org/two/discussion/17909/get-current-rectmode-setting</link>
      <pubDate>Fri, 19 Aug 2016 16:31:51 +0000</pubDate>
      <dc:creator>jeffthompson</dc:creator>
      <guid isPermaLink="false">17909@/two/discussions</guid>
      <description><![CDATA[<p>Is it possible to get the current <code>rectMode()</code> setting (<code>CENTER</code>, <code>CORNER</code>, etc)? I'd like to build a function that acts differently based on this.</p>
]]></description>
   </item>
   <item>
      <title>How to randomly select an integer from 2 sets of ranges?</title>
      <link>https://forum.processing.org/two/discussion/17583/how-to-randomly-select-an-integer-from-2-sets-of-ranges</link>
      <pubDate>Tue, 19 Jul 2016 12:52:05 +0000</pubDate>
      <dc:creator>RomiNam</dc:creator>
      <guid isPermaLink="false">17583@/two/discussions</guid>
      <description><![CDATA[<p>Hello! 
I'm very new to processing and I want to randomly select an integer out of 2 sets of ranges.
For my example here, I'm working with colorMode(HSB) and I want the program to select Hue from say 0-50 and 200-255.</p>

<p>This is the code I have at the moment and as you can see, it is randomly selecting the hue value from 50-250 but is there any way I can set it so it selects from 0-50 and 200-250? So it doesn't select any number between 51-199 and 251-255.</p>

<p>Any advice or help would be greatly appreciated!
Thank you!</p>

<pre><code>int amt = 10;

int[] x1 = new int[amt];
int[] x2 = new int[amt];
int[] y1 = new int[amt];
int[] y2 = new int[amt];

color[] c = new color[amt];

color bgcolor;

void setup() {
  size(600,600);
  colorMode(HSB);
  rectMode(CORNERS);
  noStroke();
  bgcolor = color(random(50),100,255);
  background(bgcolor);

  for(int i = 0; i &lt; amt; i++){
    x1[i] = int(random(width)); 
    x2[i] = x1[i] + int(random(80,800));
    y1[i] = int(random(height));
    y2[i] = y1[i] + int(random(50,500));
    c[i] = color(random(50,250),90,255);
  }
}

void draw() {
    for(int i = 0; i &lt; amt; i++){
      fill(c[i]);
      rect(x1[i],y1[i], x2[i], y2[i]);
    }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Beginner's question about the FILL command</title>
      <link>https://forum.processing.org/two/discussion/17029/beginner-s-question-about-the-fill-command</link>
      <pubDate>Tue, 07 Jun 2016 19:33:20 +0000</pubDate>
      <dc:creator>Boekenknul</dc:creator>
      <guid isPermaLink="false">17029@/two/discussions</guid>
      <description><![CDATA[<p>This is driving me insane and I cannot seem to find any explanation.</p>

<p>Why are (in the following code) multiple shapes in the fill color (150)  even though the fill command is the last command in the DRAW zone. I thought only subsequent shapes would be filled in that color - but it is also filling in earlier shapes in the same (150) grey.</p>

<pre><code>void setup() {
    size(640,420);
    background(240);
    smooth();
}

void draw() {

  //body of zork
  rectMode(CENTER);
  rect(320,210,80,120);

  //head of zork
  ellipse(320,118,65,65);

  //eyes of zork
  //fill(50);
  ellipse(307,115,10,20);
  ellipse(333,115,10,20);
  fill(150);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Error when using P3D Processing 3</title>
      <link>https://forum.processing.org/two/discussion/16646/error-when-using-p3d-processing-3</link>
      <pubDate>Mon, 16 May 2016 17:26:23 +0000</pubDate>
      <dc:creator>MoMo</dc:creator>
      <guid isPermaLink="false">16646@/two/discussions</guid>
      <description><![CDATA[<p>down vote
favorite
Could you please help me I am trying to start drawing 3D shapes using Processing 3 Whenever the renderer P3D is used, I get the following Error</p>

<p>ERROR: 0:2: '' : Declaration must include a precision qualifier or the default precision must have been previously declared. ERROR: 0:30: '' : Declaration must include a precision qualifier or the default precision must have been previously declared.</p>

<p>The piece of code I am trying to run:</p>

<pre><code>float x,y,z;
void setup() {
  size(200,200,P3D);
  x = width/2;
  y = height/2;
  z = 0;
}

void draw() {
  translate(x,y,z);
  rectMode(CENTER);
  rect(0,0,100,100);

z++; // The rectangle moves forward as z increments.
}
</code></pre>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>something wrong with this sketch ? please need direction .. (p5 oscillator)</title>
      <link>https://forum.processing.org/two/discussion/15914/something-wrong-with-this-sketch-please-need-direction-p5-oscillator</link>
      <pubDate>Fri, 08 Apr 2016 04:00:39 +0000</pubDate>
      <dc:creator>wierdweird</dc:creator>
      <guid isPermaLink="false">15914@/two/discussions</guid>
      <description><![CDATA[<p>I tried to play with audio and tried to form object with a oscillator as one of its property ,did mange get some sounds ,but does stop making noises after a while (same count every time ).I am pretty sure i got something wrong but cant figure out 
here is script ..would be nice if  u cud point me in the rite direction.thanks</p>

<p>var canvas;
var counter=0;
var boby=0 ;
var obj1 = 0;
var obj2 = 1;
var obj3 = 2;
var changesize=0;
var attackLevel = 1.0;
var releaseLevel = 0;
var attackTime = 0.001
var decayTime = 0.1;
var susPercent = 0.2;
var releaseTime = 0.5;
var env, Osc;
var state;
var start;
function setup(){
masterVolume(0.06);
canvas= createCanvas(displayWidth/2,displayHeight/2);
noStroke();
noLoop();
canvas.mousePressed(theplanes);</p>

<p>}</p>

<p>function theplanes(){</p>

<p>ourtimer(300,70,2,800,500);</p>

<p>}</p>

<p>function sound(freq){
env = new p5.Env();
env.setADSR(attackTime, decayTime);
env.setRange(attackLevel, releaseLevel);
Osc = new p5.Oscillator('sawtooth');
Osc.amp(env);
Osc.start();
Osc.freq(freq);
env.play();
}</p>

<p>function ourtimer(xloc,yloc,count,freq,wait){</p>

<p>setInterval(plane1,wait,xloc,yloc,count,freq);</p>

<p>function plane1(xloc,yloc,count,freq){</p>

<p>sound(freq);
var size= (map(sin(changesize),-1,1,0,60));</p>

<p>colorvalues=255/count;
steps=size/count;</p>

<p>for (i = 0; i &lt; count; i++) {
fill(i<em>colorvalues);
stroke(0);
strokeWeight(1);
rectMode(CENTER);
rect(xloc, yloc, size - i</em>steps, size - i*steps);</p>

<p>} 
changesize++;</p>

<p>}</p>

<p>}
function draw(){
background(100);</p>

<p>}﻿</p>
]]></description>
   </item>
   <item>
      <title>Changing numbers in the text through the use of variables.</title>
      <link>https://forum.processing.org/two/discussion/15845/changing-numbers-in-the-text-through-the-use-of-variables</link>
      <pubDate>Tue, 05 Apr 2016 00:26:28 +0000</pubDate>
      <dc:creator>74204916</dc:creator>
      <guid isPermaLink="false">15845@/two/discussions</guid>
      <description><![CDATA[<p>I try to put a variable in the text () to have a changing number for the scores{}, but the program debugger gives me an error.</p>

<p>Please help.</p>

<p>float lX;
float lY;
float lW;
float lH;
float lS;
float rX;
float rY;
float rW;
float rH;
float rS;
boolean up, down;
boolean v1, h1;
boolean started = true;
int mate = 9;
int xPos;
int yPos;
int incDec =4;<br />
int bVal=0;
int gVal=0;
int rVal=250;
int w = 40;
int h = 40;
int speedx = 2;
int speedy = 3;</p>

<p>void setup(){
  //I h8 U Java!!!
  size (600,600); 
  rectMode (CENTER);
  ellipseMode (CENTER);
  lX = 30;
  lY = height/2;
  lW = 40;
  lH=100;
  lS = 5;
  rX=570;
  rY = height/2;
  rW = 40;
  rH=100;
  rS=5;
  xPos = 250;
  yPos = 250;
}</p>

<p>void draw (){
  background(0);
  drawlpad();
  drawrpad();
  movelpad();
  moverpad();
  drawball();
  moveball();
  restrictpaddle();
  contactpad();
  contactr();
}</p>

<p>void drawlpad(){
  fill(0,250,0);
  rect(lX,lY,lW,lH);
}</p>

<p>void drawrpad(){
  fill(0,0,250);
  rect(rX,rY,rW,rH);
}</p>

<p>void movelpad(){
if (up){
  lY=lY-lS;
}
if (down){
  lY=lY+lS;
}
}</p>

<p>void moverpad(){
  if(v1){
    rY=rY-rS;
  }
  if(h1){
    rY=rY+lS;
  }
}</p>

<p>void drawball(){<br />
fill(rVal,gVal,bVal);
ellipse(xPos,yPos,w,h);          //bsize
}</p>

<p>void moveball(){
  xPos = xPos +incDec;</p>

<p>if (xPos &gt;600-w/2){
    incDec=-incDec;
    setup();
}
if (xPos&lt;10+w/2){
      incDec=-incDec;
      setup();
}
    yPos = yPos + mate;
if (yPos&gt;600){
      mate=-mate;</p>

<p>}
if (yPos &lt; 0){
      mate=-mate;</p>

<pre><code>}
</code></pre>

<p>}</p>

<p>void restrictpaddle(){
if (lY - lH/2 &lt; 0) {
    lY = lY + lS;
}
  if (lY + lH/2 &gt; height) {
    lY= lY - lS;
}
  if (rY - rH/2 &lt; 0) {
    rY = rY + rS;
}
  if (rY + rH/2 &gt; height) {
    rY = rY - rS;
}
}</p>

<p>void contactpad() {
  if (xPos-w/2 &lt; lX + lW/2 &amp;&amp; yPos-h/2 &lt; lY +lH/2 &amp;&amp; yPos +lH/2 &gt; lY - lH/2){
    if (incDec&lt;0){
      incDec = -incDec;
}
}
}</p>

<p>void contactr() {
  if(xPos+w/2 &gt;  rX - rW/2 &amp;&amp; yPos-h/2 &lt; rY + rH/2 &amp;&amp; yPos+h/2 &gt; rY -rH/2){
    if (incDec&gt;0){
       incDec = -incDec;
    }
  }
}</p>

<p>void keyPressed(){
if(started = true){
if (key=='w' || key=='W'){
   up=true;
}
if (key=='s'||key=='S'){
    down=true;
}
if (keyCode==UP){
    v1=true;
}
if(keyCode ==DOWN){
    h1=true;
}
}
}</p>

<p>void keyReleased(){
if (key=='w' || key=='W'){
    up=false;
}</p>

<p>if (key=='s'||key=='S'){
  down=false;
}</p>

<p>if (keyCode==UP){
  v1=false;
}</p>

<p>if(keyCode ==DOWN){
  h1=false;
}
}</p>

<p>void mousePressed (){   //for change color
  int temp;
  temp=bVal;
  bVal=gVal;
  gVal=rVal;
  rVal=temp;
}</p>

<p>/*void scores () {
fill(255);
text (scorer1, 100, 50);
text (scorer, width-100,50);
}</p>
]]></description>
   </item>
   </channel>
</rss>