<?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 beginshape() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=beginshape%28%29</link>
      <pubDate>Sun, 08 Aug 2021 17:43:13 +0000</pubDate>
         <description>Tagged with beginshape() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedbeginshape%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>can anyone help with pushmatrix?</title>
      <link>https://forum.processing.org/two/discussion/28131/can-anyone-help-with-pushmatrix</link>
      <pubDate>Tue, 02 Oct 2018 21:50:25 +0000</pubDate>
      <dc:creator>laptophead</dc:creator>
      <guid isPermaLink="false">28131@/two/discussions</guid>
      <description><![CDATA[<p>I am modeling this robotic arm and it looks great.</p>

<p>I am also trying to display each angle next to each point of inflexion. 
In the case of the elbow, I am trying to move the text with the elbow position along with the inflexion point. 
That works, but I cant find a method to keep the writing horisontal.
It rotates with the first segment angle...</p>

<p>here is my function</p>

<p>thanks</p>

<p>void ArmDepiction()</p>

<p>{  ///////////////////////////Base orientation</p>

<p>fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
  text( (nf(degrees(BaseAngRad), 0, 1)), 630, 1050);
  //text( "0", 85, 0);</p>

<p>strokeWeight(10);
stroke(238,242, 0);
noFill ();</p>

<p>// Form: arc(x, y, width, height, start, stop, type);
arc(550, 1000, 100, 100, (PI/2), (BaseAngRad+(PI/2)), PIE);
//stroke(#71B28F);
//arc(100, 1000, 175, 175, 0, 2*PI, 0);</p>

<p>//drawArrow(100,160,50,130);</p>

<p>///////////////////////Arm Depiction
  strokeWeight(40);
  stroke(255, 160);
  strokeCap(ROUND);</p>

<p>float x, y;</p>

<p>x = 550;
  y = 800;</p>

<p>pushMatrix();
  strokeWeight(40);
  segment(x, y, PI+ShoAngRad); 
  strokeWeight(30);
  segment1(segLength, 0, PI+ElbowAngRad); // 120 is the starting point
  segment3(segLength, 0, (2*PI)+ElbowAngRad-0.58); // 100 is the segment length
  popMatrix();</p>

<p>translate(x, y);
strokeWeight(10);
strokeJoin(ROUND);
   beginShape();
  vertex(-40, 0);</p>

<p>vertex(-65, segLength);
  vertex(65, segLength);</p>

<p>vertex(40, 0);
  endShape(CLOSE);</p>

<p>DisplayElAngle(x, y);</p>

<p>}</p>

<p>void segment(float x, float y, float a) {
  translate(x, y);
  fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
  text( (nf(degrees(ShoAngRad), 0, 1)), 30, 0);
  //text( "0", 85, 0);
  noFill ();</p>

<p>rotate(a);
  line(0, 0, segLength, 0); // 100 is the segment length</p>

<p>}</p>

<p>void DisplayElAngle(float x, float y) {
  translate(x, y);
  rotate(2<em>PI);
    fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown</em>3 ); 
 text( (nf(degrees(ElbowAngRad), 0, 1)), 20, -10);
  noFill ();
 //</p>

<p>}
void segment1(float x, float y, float a) {
  translate(x, y);
    fill(201, 0, 211); // magenta
  //text("Y:", LS, spaceDown*3 ); 
 text( (nf(degrees(ElbowAngRad), 0, 1)), 20, -10);
  noFill ();
  rotate(a);
  line(0, 0, segLength, 0); // 100 is the segment length
   // rotate(a);</p>

<p>}</p>

<p>void segment3(float x, float y, float a) {
  translate(x, y);
  rotate(a);
  line(0, 0, (segLength/5), 0); // 100 is the segment length</p>

<p>}</p>
]]></description>
   </item>
   <item>
      <title>Linear algebra question - how to rotate a figure around point</title>
      <link>https://forum.processing.org/two/discussion/26303/linear-algebra-question-how-to-rotate-a-figure-around-point</link>
      <pubDate>Sat, 10 Feb 2018 19:21:10 +0000</pubDate>
      <dc:creator>djevazi</dc:creator>
      <guid isPermaLink="false">26303@/two/discussions</guid>
      <description><![CDATA[<p>Here is a sketch, in this sketch I tried to impement a rotation of a figure in 3 dimensions. The rotation should be around the point of mouse coordintates (please hold left button and move the mouse), but it don't work properly. I used following method - find mouse coordinates, calculate new point coodinates in new axis space, rotate all the points around this new center, return the translation of coordinates in normal coordinate space (hope the explanation makes sence). The question is - why my rotation is stange and not around the point?</p>

<pre><code>Figure figure=new Figure();
PVector mus;
PVector dirx;
PVector diry;
float anglx;
float angly;
float locX=0;
float locY=0;


void setup()
{
  size(500,500,P3D);
  ortho();
  dirx=new PVector(0,0,0);
  diry=new PVector(0,0,0);
}



void draw()
{
  mus=new PVector(mouseX-pmouseX,mouseY-pmouseY,0);
  mus.setMag(0.04);

  dirx = new PVector(1,0,0);
  dirx.add(mus.copy());
  dirx.setMag(1);

  diry = new PVector(0,1,0);
  diry.add(mus.copy());
  diry.setMag(1);


  background(200);
  figure.display();
}



void mousePressed()
{
  locX=mouseX;
  locY=mouseY;
}



void mouseDragged()
{

  ellipse(locX,locY,5,5);

  float ax = figure.A.x-locX;
  float bx = figure.B.x-locX;
  float cx = figure.C.x-locX;

  float ay= figure.A.y-locY;
  float by= figure.B.y-locY;
  float cy= figure.C.y-locY;



  {// rotation by X axis

  float nax=(figure.A.x*1)+(0)+(0);
  float nay=(0)+(ay*dirx.x)+(figure.A.z*dirx.y);
  float naz=(0)+(ay*-dirx.y)+(figure.A.z*dirx.x);

  float nbx=(figure.B.x*1)+(0)+(0);
  float nby=(0)+(by*dirx.x)+(figure.B.z*dirx.y);
  float nbz=(0)+(by*-dirx.y)+(figure.B.z*dirx.x);

  float ncx=(figure.C.x*1)+(0)+(0);
  float ncy=(0)+(cy*dirx.x)+(figure.C.z*dirx.y);
  float ncz=(0)+(cy*-dirx.y)+(figure.C.z*dirx.x);


  figure.A.x=nax;
  figure.A.y=nay+locY;
  figure.A.z=naz;
  figure.B.x=nbx;
  figure.B.y=nby+locY;
  figure.B.z=nbz;
  figure.C.x=ncx;
  figure.C.y=ncy+locY;
  figure.C.z=ncz;
  }


  {// rotation by Y axis


  float nax=(ax*diry.y)+(0)+(figure.A.z*-diry.x);
  float nay=(0)+(figure.A.y*1)+(0);
  float naz=(ax*diry.x)+(0)+(figure.A.z*diry.y);

  float nbx=(bx*diry.y)+(0)+(figure.B.z*-diry.x);
  float nby=(0)+(figure.B.y*1)+(0);
  float nbz=(bx*diry.x)+(0)+(figure.B.z*diry.y);

  float ncx=(cx*diry.y)+(0)+(figure.C.z*-diry.x);
  float ncy=(0)+(figure.C.y*1)+(0);
  float ncz=(cx*diry.x)+(0)+(figure.C.z*diry.y);


  figure.A.x=nax+locX;
  figure.A.y=nay;
  figure.A.z=naz;
  figure.B.x=nbx+locX;
  figure.B.y=nby;
  figure.B.z=nbz;
  figure.C.x=ncx+locX;
  figure.C.y=ncy;
  figure.C.z=ncz;

  }
}




class Figure
{
  PVector A;
  PVector B;
  PVector C;


  Figure()
  {
    A=new PVector(random(width*2, width*4), random(width*2, width*4), random(width*2, width*4));
    B=new PVector(random(width*2, width*4), random(width*2, width*4), random(width*2, width*4));
    C=new PVector(random(width*2, width*4), random(width*2, width*4), random(width*2, width*4));
  }


  void display()
  {

    stroke(255, 150);
    fill(#73C1C1);

    beginShape(TRIANGLES);
    vertex(A.x, A.y, A.z);
    vertex(B.x, B.y, B.z);
    vertex(C.x, C.y, C.z);
    endShape();

    fill(255);
    text("AX="+A.x, 10, 20);
    text("AY="+A.y, 10, 40);
    text("AZ="+A.z, 10, 60);

    text("BX="+B.x, 10, 100);
    text("BY="+B.y, 10, 120);
    text("BZ="+B.z, 10, 140);

    text("CX="+B.x, 10, 180);
    text("CY="+B.y, 10, 200);
    text("CZ="+B.z, 10, 220);

    text(locX, 10, 260);
    text(locY, 10, 280);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>get vertex of svg ( from loadShape)</title>
      <link>https://forum.processing.org/two/discussion/25638/get-vertex-of-svg-from-loadshape</link>
      <pubDate>Tue, 19 Dec 2017 11:10:50 +0000</pubDate>
      <dc:creator>sinanatra</dc:creator>
      <guid isPermaLink="false">25638@/two/discussions</guid>
      <description><![CDATA[<p>Hi, i have a svg file that i import with PShape <code>fama = loadShape("test.svg");</code>, i'm trying to add a dashed stroke on its path and i discovered this <a rel="nofollow" href="https://github.com/garciadelcastillo/-dashed-lines-for-processing-">library</a>  but i need to get the vertex of my shape so that i can use the BeginShape();
How could i do it?</p>
]]></description>
   </item>
   <item>
      <title>A simple shape tool</title>
      <link>https://forum.processing.org/two/discussion/25019/a-simple-shape-tool</link>
      <pubDate>Wed, 15 Nov 2017 06:24:26 +0000</pubDate>
      <dc:creator>KunalAgnihotri</dc:creator>
      <guid isPermaLink="false">25019@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I’m trying to make a simple shape tool for a program. It works by adding a vertex to a shape when the mouse is clicked.</p>

<pre><code>//array to hold points
var mousepoints = [];



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

function draw() {
 print(mousepoints);   
    fill(20,200,66);
    beginShape();
    for(var i=0; i &lt;mousepoints.length; i = i + 2){
    vertex(mousepoints[i], mousepoints[i+1]);
    }


    endShape();
}

function mouseClicked(){

    append(mousepoints, mouseX);
    append(mousepoints, mouseY);    

}


function keyTyped(){

    //start a new shape

    if(key ==='a'){
    mousepoints.splice(0, mousepoints.length);
    }  
}
</code></pre>

<p><img src="" alt="" /><img src="https://forum.processing.org/two/uploads/imageupload/484/GPWQD0WT41RH.png" alt="Screen Shot 2017-11-15 at 11.49.30 AM" title="Screen Shot 2017-11-15 at 11.49.30 AM" /></p>

<p>The issue i’m facing is that when I make my shape with extrusions such as in the image, there is a fill outside the shape thats appearing(I have marked it in the red circles). Any way to resolve this?</p>
]]></description>
   </item>
   <item>
      <title>Trouble In getting My shape to Bounce or change color appropriately while method is being used</title>
      <link>https://forum.processing.org/two/discussion/24843/trouble-in-getting-my-shape-to-bounce-or-change-color-appropriately-while-method-is-being-used</link>
      <pubDate>Thu, 02 Nov 2017 13:21:03 +0000</pubDate>
      <dc:creator>ainderp</dc:creator>
      <guid isPermaLink="false">24843@/two/discussions</guid>
      <description><![CDATA[<pre><code>PShape star;                                                        
float red   = random(255);
float green = random(255);
float blue  = random(255);

int rad = 60;   //width of the shape
float xpos, ypos;

float xspeed = 5;
float yspeed = 5;

int xdirection = 1;
int ydirection = 1;

void setup() {
  size(1000, 1000, P2D);
  colorMode(RGB, 255);
  background(0);
  xpos = width/2;
  ypos = height/2;
  star = createShape();  // creating the star shape
  star.beginShape();
  star.fill(255, 255, 0);  // setting the default color of the star
  star.stroke(255);
  star.strokeWeight(2);
  star.vertex(0, -50);   // creating the  star shape 
  star.vertex(14, -20);
  star.vertex(47, -15);
  star.vertex(23, 7);
  star.vertex(29, 40);
  star.vertex(0, 25);
  star.vertex(-29, 40);
  star.vertex(-23, 7);
  star.vertex(-47, -15);
  star.vertex(-14, -20);
  star.endShape(CLOSE);
  shape(star, xpos, ypos);
  //shapeMode(RADIUS)             if this line of code is enabled the star is stuck in the corner and only changes color
}

void draw() {
}


void mousePressed() {                         // while mousepressed the star should change color and bounce around the screen


  xpos = xpos + (xspeed * xdirection);
  ypos = ypos + (yspeed * ydirection);


  if (xpos &gt; width-rad || xpos &lt; rad) {

    xdirection *= -1;
  }

  if (ypos &gt; height-rad || ypos &lt;rad) {

    ydirection *= -1;
  }

  background(0);
  shape(star, xpos, ypos);

  star.disableStyle();                           
  fill(red, green, blue);

  if (red&lt;255)
    red = red+random(255);
  else
    red = 0;

  if (green &lt; 255) 
    green = green+random(255);
  else
    green = 0;

  if (blue&lt;255)
    blue = blue+random(255);
  else 
  blue = 0;
}

/*void mouseReleased() {           //when mouse is released repostion star in middle 
 star.enableStyle();                    // to original color
 background(0);
 shape(star, width/2, height/2);
 }
 */
</code></pre>

<p>I want the program to start with the yellow star in the middle and then when you press and hold down the mouse button it should begin bouncing around the screen while constantly changing colors? upon mouseReleased the star resets back to the middle. I'm pretty new to processing so I can't see where I'm going wrong.</p>

<p>When I take the bounce code out of the mousePressed method and place it in draw, the star just goes from the top left corner to the botom right and changes color upon each mouseclick  any advice would be highly appreciated!</p>
]]></description>
   </item>
   <item>
      <title>Problem with beginShape(QUADS)</title>
      <link>https://forum.processing.org/two/discussion/24312/problem-with-beginshape-quads</link>
      <pubDate>Fri, 29 Sep 2017 18:47:26 +0000</pubDate>
      <dc:creator>randomdude</dc:creator>
      <guid isPermaLink="false">24312@/two/discussions</guid>
      <description><![CDATA[<p>In one of my previous question it was suggested that I use beginShape(QUADS) to display an image. I was unsure what the third and fourth arguments in the vertex(); were after that, so I decided to experiment. This is my code, but it does not display an image at all.</p>

<pre><code>PImage blob;
void setup() {
  size(800,800,P2D);
  blob = loadImage("ASD.jpg");
}
void draw() {
  background(255);
  beginShape(QUADS);
  texture(blob);
  noStroke();
  vertex(100,100,0,0);
  vertex(100,200,0,1);
  vertex(200,200,1,1);
  vertex(200,100,1,0);
  endShape();
}
</code></pre>

<p>If someone can explain to me what the 0s and 1s mean as the 3rd and 4th arguments in the vertexes of a beginShape(QUADS) function, that would be awesome!</p>
]]></description>
   </item>
   <item>
      <title>set specific color on face of cube</title>
      <link>https://forum.processing.org/two/discussion/23919/set-specific-color-on-face-of-cube</link>
      <pubDate>Fri, 25 Aug 2017 00:50:56 +0000</pubDate>
      <dc:creator>glenn007</dc:creator>
      <guid isPermaLink="false">23919@/two/discussions</guid>
      <description><![CDATA[<p>hi need to find a way to load all points from the back face of the cube into array so i can change the colors and set the 
 modified colors back on the face again. just like in C# where you get modifi single pixel on the screen.</p>

<p>can anyone tell me if it is posibel or do i need to create an image and then use beginShape with image as texture.  it just seems power consuming like that.</p>
]]></description>
   </item>
   <item>
      <title>Embedding sketch in webpage(html)</title>
      <link>https://forum.processing.org/two/discussion/23452/embedding-sketch-in-webpage-html</link>
      <pubDate>Sat, 15 Jul 2017 09:33:47 +0000</pubDate>
      <dc:creator>tatertot</dc:creator>
      <guid isPermaLink="false">23452@/two/discussions</guid>
      <description><![CDATA[<p>Hello.   I am working on a sketch based on the "Solar system generator" (video link below).</p>

<p><strong></strong>
<span class="VideoWrap"><span class="Video YouTube" id="youtube-FGAwi7wpU8c"><span class="VideoPreview"><a href="http://youtube.com/watch?v=FGAwi7wpU8c"><img src="http://img.youtube.com/vi/FGAwi7wpU8c/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>I modified the code such that it retrieves the number of moons and the appropriate image file from a .csv, and managed to get it working.</p>

<p>However, I have trouble embedding it to a html file. 
Below are the contents of the html and processing code.
I also attached an image of the working directory.</p>

<p>Any pointers on what's going wrong is greatly appreciated.
(I have a feeling it has something to do with the *@pjs preload command of the .pde ..., but not sure)</p>

<p>Many thanks in advance.</p>

<p>-----<strong>html code</strong>--------</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
&lt;title&gt; My first webpage&lt;/title&gt;
&lt;script src="Processing.js"&gt;&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
Hello World!
&lt;marquee&gt; this is a test!&lt;/marquee&gt;
&lt;canvas data-processing-sources="solargenerator_sunrotate_ver6.pde planet.pde"&gt;&lt;/canvas&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<hr />

<p>-----<strong>sketch code  solargenerator_sunrotate_ver6</strong>--------</p>

<pre><code>import peasy.*;
Planet[] sun;


PeasyCam cam;

PImage sunTexture;
PImage[] textures = new PImage[3];
Table holidaytable;
int nrows;

void setup() {
  size(900, 700, P3D);

  Table holidaytable=loadTable("test.csv", "header");

  textures[0] = loadImage("earth.jpg");
  textures[1] = loadImage("cmb.jpg");
  textures[2] = loadImage("sky.jpg");

  cam = new PeasyCam(this, 1000);

  int nrows =holidaytable.getRowCount(); 

  sun = new Planet[nrows];


  for (int i = 0; i &lt; nrows; i++) {
    TableRow row = holidaytable.getRow(i);

    int ID = row.getInt("no");
    int holiday = row.getInt("holidays");
    String picture = row.getString("image");

    sunTexture= loadImage(picture);

    sun[i]= new Planet(50, 450, 0, true, ID, sunTexture);
    sun[i].spawnMoons(holiday,1); 
  }  
}

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

  for (Planet sun2 : sun) {
    sun2.show();
    sun2.orbit();
  }
}
</code></pre>

<hr />

<p><strong></strong>
OS: windows 10
Processing version: 3.3.4</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/330/MACC2YASK632.PNG" alt="workingdirectory" title="workingdirectory" /></p>
]]></description>
   </item>
   <item>
      <title>beginShape(args): tutorial or documentation of 'args'</title>
      <link>https://forum.processing.org/two/discussion/22374/beginshape-args-tutorial-or-documentation-of-args</link>
      <pubDate>Wed, 03 May 2017 22:30:16 +0000</pubDate>
      <dc:creator>bob97086</dc:creator>
      <guid isPermaLink="false">22374@/two/discussions</guid>
      <description><![CDATA[<p>I would like to see at least a brief summary of how to sequence the calls to vertex() to satisfy the different options for <code>beginShape(option)</code>. <code>option</code> can be POINTS, LINES, etc., but I've found only rare examples in forum code postings -- always lacking any discussion.
Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Could some one help me change this p5 code to processing3.3 !!!</title>
      <link>https://forum.processing.org/two/discussion/22260/could-some-one-help-me-change-this-p5-code-to-processing3-3</link>
      <pubDate>Fri, 28 Apr 2017 04:59:06 +0000</pubDate>
      <dc:creator>yucky999</dc:creator>
      <guid isPermaLink="false">22260@/two/discussions</guid>
      <description><![CDATA[<p>var xOffset = 0;       // Perlin x-offset
var yOffset = 0;       // Perlin y-offset
var offsetInc = 0.006; // Perlin offset increment
var inc = 1;           // Perin increment
var s = 1;             // Start size of perlin ring
var m = 1.005;         // Size multiplier</p>

<p>function setup() {
  createCanvas(windowWidth, windowHeight);
  background(0);
  blendMode(ADD);
  noFill();
  stroke(255, 64, 8, 128);
}</p>

<p>function draw() {
  translate(width * 0.5, height * 0.5);</p>

<p>if (s &lt; 2000) {
    // Create a series of perlin rings from big to small
    for (var nTimes = 0; nTimes &lt; 10; nTimes++) {</p>

<pre><code>  // Less points for smaller rings
  nPoints = int(2 * PI * s);
  nPoints = min(nPoints, 500);

  // Create ring
  beginShape();
  for (var i = 0; i &lt; nPoints; i++) {
    var a = i / nPoints * TAU;
    var p = p5.Vector.fromAngle(i / nPoints * TAU);
    var n = noise(xOffset + p.x * inc, yOffset + p.y * inc) * s;
    p.mult(n);
    vertex(p.x, p.y);
  }
  endShape(CLOSE);

  // Increment perlin offset for next ring
  xOffset += offsetInc;
  yOffset += offsetInc;

  // Reduce size for next ring
  s *= m;
}
</code></pre>

<p>} else {
    noLoop();
  }
}</p>
]]></description>
   </item>
   <item>
      <title>Web Uploading Issue</title>
      <link>https://forum.processing.org/two/discussion/21069/web-uploading-issue</link>
      <pubDate>Wed, 01 Mar 2017 01:00:55 +0000</pubDate>
      <dc:creator>ltriescode</dc:creator>
      <guid isPermaLink="false">21069@/two/discussions</guid>
      <description><![CDATA[<p>This works perfectly in processing, but only the background shows up when I upload it to an html file. I've tried multiple ways of uploading and the files are properly linked Does anyone know how I can fix this? Thanks!</p>

<p>/* <a href="/two/profile/pjs">@pjs</a> preload="ToxicTots.jpg","spine.jpg","top.jpg", "bottom.jpg"; */</p>

<p>PImage tex1;
PImage tex2;
PImage tex3;
PImage tex4;</p>

<p>float rotx = PI/4;
float roty = PI/4;</p>

<p>void setup() {
  size(800, 900, P3D);
  tex1 = loadImage("ToxicTots.jpg");
  tex2 = loadImage("spine.jpg");<br />
  tex3 = loadImage("top.jpg");<br />
  tex4 = loadImage("bottom.jpg");
  textureMode(NORMAL);
  fill(255);
  stroke(color(44,48,32));
}</p>

<p>void draw() {
  background(176,224,230);
  noStroke();
  translate(width/2.0, height/3.0, -100);
  rotateX(rotx);
  rotateY(roty);
  scale(200);
  TexturedCube(tex1);<br />
  TexturedCube(tex2);<br />
  TexturedCube(tex3);
  TexturedCube(tex4);
}</p>

<p>void TexturedCube(PImage tex) {
  beginShape(QUADS);</p>

<p>// +Z "front" face
  texture(tex1);
  vertex(-.25, -1,  1, 0, 0);
  vertex( 1, -1,  1, 1, 0);
  vertex( 1,  1,  1, 1, 1);
  vertex(-.25,  1,  1, 0, 1);</p>

<p>// -Z "back" face
  texture(tex1);
  vertex( 1, -1, .75, 0, 0);
  vertex(-.25, -1, .75, 1, 0);
  vertex(-.25,  1, .75, 1, 1);
  vertex( 1,  1, .75, 0, 1);
  endShape();</p>

<p>// +Y "bottom" face<br />
  beginShape(QUADS);
  texture(tex3);
  vertex(-.25,  1,  1, 0, 0);
  vertex( 1,  1, 1, 1, 0);
  vertex( 1,  1, .75, 1, 1);
  vertex(-.25,  1, .75, 0, 1);
  endShape();</p>

<p>// -Y "top" face
  beginShape(QUADS);<br />
  texture(tex4);
  vertex(-.25, -1, 1, 0, 0);
  vertex( 1, -1, 1, 1, 0);
  vertex( 1, -1,  .75, 1, 1);
  vertex(-.25, -1,  .75, 0, 1);
  endShape();</p>

<p>// +X "right" face
  beginShape(QUADS);
  texture(tex2);
  vertex( 1, -1,  1, 0, 0);
  vertex( 1, -1, .75, 1, 0);
  vertex( 1,  1, .75, 1, 1);
  vertex( 1,  1,  1, 0, 1);</p>

<p>// -X "left" face
  vertex(-.25, -1, 1, 0, 0);
  vertex(-.25, -1,  .75, 1, 0);
  vertex(-.25,  1,  .75, 1, 1);
  vertex(-.25,  1, 1, 0, 1);
  endShape();
}</p>

<p>void mouseDragged() {
  float rate = 0.01;
  rotx += (pmouseY-mouseY) * rate;
  roty += (mouseX-pmouseX) * rate;
}</p>
]]></description>
   </item>
   <item>
      <title>how to move a vertex design</title>
      <link>https://forum.processing.org/two/discussion/21190/how-to-move-a-vertex-design</link>
      <pubDate>Mon, 06 Mar 2017 01:11:11 +0000</pubDate>
      <dc:creator>tim50</dc:creator>
      <guid isPermaLink="false">21190@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm having trouble moving this design, not by animation but I want to move it to different places on the canvas with hard code. In this case, I'm trying to move it to coordinates (0,0) by using arguments and parameters. Thank you for your help.</p>

<pre><code>function setup() {
    createCanvas(
        window.innerWidth,
        window.innerHeight
    );
}

function draw() {
    background(0);
    ship(0, 0);
 }

function ship(x, y) {
    noFill();
    stroke(0, 255, 0);
    beginShape();
    vertex(200, 10);
    vertex(195, 10);
    vertex(195, 25);
    vertex(180, 25);
    vertex(180, 50);
    vertex(130, 50);
    vertex(130, 60);
    vertex(120, 60);
    vertex(120, 90); 
    vertex(280, 90);
    vertex(280, 60);
    vertex(270, 60);
    vertex(270, 50);
    vertex(220, 50);
    vertex(220, 25);
    vertex(205, 25);
    vertex(205, 10);
    vertex(200, 10)
    endShape();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>beginShape() with fill gradient</title>
      <link>https://forum.processing.org/two/discussion/13381/beginshape-with-fill-gradient</link>
      <pubDate>Tue, 03 Nov 2015 13:28:45 +0000</pubDate>
      <dc:creator>p_bogdan03</dc:creator>
      <guid isPermaLink="false">13381@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I cannot seem to replicate the following in p5js to make a gradient. Can anybody help me with why is this?</p>

<p><code>void setup() {
  size(128, 128, OPENGL);
  background(128);
  noStroke();
  beginShape();
  fill(0);
  vertex(30, 20);
  vertex(85, 20);
  fill(0,255,0);
  vertex(85, 75);
  vertex(30, 75);
  endShape();
}</code></p>
]]></description>
   </item>
   <item>
      <title>Slicing images</title>
      <link>https://forum.processing.org/two/discussion/20658/slicing-images</link>
      <pubDate>Sun, 05 Feb 2017 14:40:39 +0000</pubDate>
      <dc:creator>Hiram</dc:creator>
      <guid isPermaLink="false">20658@/two/discussions</guid>
      <description><![CDATA[<p>Hello</p>

<p>Excuse my very poor English.</p>

<p>I am a very beginner.</p>

<p>I would like to be guided please.</p>

<p>My project :<br />
1. I have a picture for example 1200/1200 pixels.<br />
2. At any point in the picture, I click with the mouse to have a point "c".<br />
3. This point "c" becomes the center of 5 concentric rings.<br />
4. I would like to turn the rings a few degrees clockwise or counter-clockwise.</p>

<p>I have no idea that the pixels of the original photo become the pixels of my rings.</p>

<p>It would be nice of me to orient myself.</p>

<p>Thank you</p>

<p>What i want to do is this but in movement....</p>

<p><img src="" alt="" /><img src="https://forum.processing.org/two/uploads/imageupload/013/8LV1O0S3RIOL.jpg" alt="bury36396_p" title="bury36396_p" /></p>
]]></description>
   </item>
   <item>
      <title>fill behaviour on beginShape()/endShape() vertices in WEBGL mode</title>
      <link>https://forum.processing.org/two/discussion/20065/fill-behaviour-on-beginshape-endshape-vertices-in-webgl-mode</link>
      <pubDate>Wed, 04 Jan 2017 16:36:43 +0000</pubDate>
      <dc:creator>leovanderveen</dc:creator>
      <guid isPermaLink="false">20065@/two/discussions</guid>
      <description><![CDATA[<p>I've got a question about some unusual behaviour with beginShape()/endShape() in WEBGL mode. 
When I draw just a simple square using 4 vertices everything is about right. But when I draw like a 'U' kind of shape it seems that the vertices are not filled correctly. I tried several beginShape() modes but none have got the right behaviour. In the example sketch below this is illustrated, the problem is the diagonal fill appearing in the lower right corner of the filled shape.</p>

<p>Here's an example sketch:
<a href="http://www.nr37.nl/0/p5js" target="_blank" rel="nofollow">http://www.nr37.nl/0/p5js</a></p>

<p>Also when I use noStroke(), fill(255,0,0) and then draw the vertices the shape is red (right shape in example), the left shape in the example is preceded by noFill(), stroke(0) but the shaped is still stroked red...</p>
]]></description>
   </item>
   <item>
      <title>Map delimiters: can't make vertex() to draw them</title>
      <link>https://forum.processing.org/two/discussion/19398/map-delimiters-can-t-make-vertex-to-draw-them</link>
      <pubDate>Tue, 29 Nov 2016 17:01:30 +0000</pubDate>
      <dc:creator>mmammana</dc:creator>
      <guid isPermaLink="false">19398@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,
I am trying to make a map of Buenos Aires neighbourhoods. 
I've created a csv file with some coordinates to delimit some of the neighbourhoods. I want the program to draw and fill the limits, using beginShape/vertex/endShape.
The coordinates are loaded into a table, and then, two loops read each row/column and get the values for each neighbourhood (one row per neighbourhood, with 4 pairs of values, for a 4 sided polygon each).
When all the vertex points are drawn for that polygon, the inner loop ends, and the program runs the endShape(CLOSE) to close the limits, and starts the next row (that's why I put the endShape(CLOSE) outside the inner loop).</p>

<p>I can't figure out why it is not working. I've put a println() to check if the values retrieved in each iteration are ok. The values are ok, but vertex does not draw the polygon. I've also tried leaving the image (svg) out, because perhaps, the loop draws it behind the map, but again, no success. 
Maybe the endShape should not be outside the second loop, meaning that all code between beginShape and endShape must remain together?
Any idea? Thanks so much in advance,
Marcelo</p>

<p>This is the program (Processing 2):</p>

<pre><code>PShape mapaBA;
Table table;

void setup(){
  size(800,800);
  noLoop();
  table = loadTable("barrios.csv"); // coords for some neighborhoods limits
  mapaBA = loadShape("CABA.svg"); // map of Buenos Aires city
}

void draw(){
    shape(mapaBA,0,0,width,height);
    for (int i=0;i&lt;table.getRowCount();i++){ 
      for (int e =0;e&lt;table.getColumnCount()-1;e=e+2){ 
          beginShape();
          int x = table.getInt(i,e);
          int y = table.getInt(i,e+1);
          println(i, e, x,y); // just to test if values are ok
          vertex(x,y); // should draw a polygon that delimites a neighbourhood, based on coords
        }
          endShape(CLOSE);
    }

}
</code></pre>

<p>The csv file contains the following values:</p>

<pre><code>642,320,554,326,564,365,643,355
647,355,563,364,561,401,648,393
559,403,612,400,617,438,567,468
649,394,612,398,618,440,659,431
</code></pre>
]]></description>
   </item>
   <item>
      <title>get actual width of scaled shape??</title>
      <link>https://forum.processing.org/two/discussion/16881/get-actual-width-of-scaled-shape</link>
      <pubDate>Sun, 29 May 2016 20:14:21 +0000</pubDate>
      <dc:creator>FFD8</dc:creator>
      <guid isPermaLink="false">16881@/two/discussions</guid>
      <description><![CDATA[<p>I'm building a small set of functions that mirror primitive shapes (rect, ellipse, line), however normalize their pixel values for sending via OSC to openFrameworks. I've set this up, so that one just puts an 'x' in front of the existing shape. Everything is going great and screenX, screenY are my best friends in making this possible.. but I'm running into strange bugs if using scale() before drawing one of these shapes... the x,y coords get corrected, but not my width/height. 
a sample from basic setup looks like this:</p>

<p><code>pushMatrix(); // only adjusts translate/scale within matrix
  translate(width/2, height/2); // suggestion to draw from center out 
  scale(.65);
  xrect(0,0,250,250);
  popMatrix();</code></p>

<p><code>void xrect(float x1, float y1, float w1, float h1) {
  rect(x1, y1, w1, h1);
  String shape = "rect";
  float x1out = map(screenX(x1, y1), 0, width, 0, 1);
  float y1out = map(screenY(x1, y1), 0, height, 0, 1);
  float w1out = map(w1, 0, width, 0, 1);
  float h1out = map(h1, 0, height, 0, 1);
  // .. OSC message w/ these values sent after this
}</code></p>

<p>perhaps i should just be grabbing the screenX of (x1+w1) to know where that xpoint is then check the distance between those points? Wondering if there's a better way to check for transformations and know if anything's being scaled.</p>
]]></description>
   </item>
   <item>
      <title>need help with 3d text transformation</title>
      <link>https://forum.processing.org/two/discussion/15609/need-help-with-3d-text-transformation</link>
      <pubDate>Mon, 21 Mar 2016 19:51:14 +0000</pubDate>
      <dc:creator>ira_ira</dc:creator>
      <guid isPermaLink="false">15609@/two/discussions</guid>
      <description><![CDATA[<p>Hi all!
I want to do something like this in processing:
<a href="https://mir-s3-cdn-cf.behance.net/project_modules/disp/7d7bf511219015.560f42336f0bd.gif" target="_blank" rel="nofollow">https://mir-s3-cdn-cf.behance.net/project_modules/disp/7d7bf511219015.560f42336f0bd.gif</a>
I have one image which I use as a texture and I'm constructing complicated plane with beginShape(TRIANGLE_STRIP) to reach<br />
a similar effect, but it's quite difficult to render texture with letters on such complicated object.
I thought that it would be much easier to have one rect with this inscription and after that blent this rectangle in different ways.
But I have no idea how to do this?
I will be very thankful for any suggestion!</p>
]]></description>
   </item>
   <item>
      <title>Stroke Outside, Or Inside - Not Both?</title>
      <link>https://forum.processing.org/two/discussion/13401/stroke-outside-or-inside-not-both</link>
      <pubDate>Wed, 04 Nov 2015 09:42:14 +0000</pubDate>
      <dc:creator>Casey_Scalf</dc:creator>
      <guid isPermaLink="false">13401@/two/discussions</guid>
      <description><![CDATA[<p>I have been working with some strokes around shapes I made using a vertex.</p>

<p>Lets use the popular star shape as an example code. Any irregular shape is of interest.</p>

<p>How can I use stroke() so that the stroke is only applied to the inner edge? Or only the outer edge? See picture.</p>

<p>This is a popular tool when using vectors in Illustrator or Photoshop so I thought I might have a chance at communicating this and illustrating the desired outcome.</p>

<p>Thanks for any tips!</p>

<p>// How to make it so stroke is only drawn on one side of edge?</p>

<pre><code>void draw() {
  background(51);
  translate(mouseX, mouseY);
  fill(102);
  stroke(255);
  strokeWeight(2);
  beginShape();
  vertex(0, -50);
  vertex(14, -20);
  vertex(47, -15);
  vertex(23, 7);
  vertex(29, 40);
  vertex(0, 25);
  vertex(-29, 40);
  vertex(-23, 7);
  vertex(-47, -15);
  vertex(-14, -20);
  endShape(CLOSE);
}
</code></pre>

<p><a rel="nofollow" href="http://payload294.cargocollective.com/1/3/103095/8182873/Processing-Stroke-VertexII.jpg">Photo Link</a></p>

<p><img src="http://payload294.cargocollective.com/1/3/103095/8182873/Processing-Stroke-VertexII.jpg" alt="" /></p>
]]></description>
   </item>
   <item>
      <title>How to draw a circular line graph from data (csv)?</title>
      <link>https://forum.processing.org/two/discussion/13687/how-to-draw-a-circular-line-graph-from-data-csv</link>
      <pubDate>Fri, 27 Nov 2015 22:03:36 +0000</pubDate>
      <dc:creator>LaMa</dc:creator>
      <guid isPermaLink="false">13687@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,
I'm trying to draw a weather diagram. What I got so far is the diagram for the temperature, drawn by a dot for maximum temperature and a dot for minimum temperature both connected by a line, in a nice circle. Everything drawn with the help of rotate(). This code works so far. 
But I want to do now is to "connect" the dots to a "circular line chart". One line for the max. Temperatur and one line for the min. temperature. I guess this cannot be done with rotate(). I tried something else (see the code at the bottom), but it doesnt work and I have no idea how to continue.</p>

<p>This is the working code:</p>

<pre>

//Array for Temperature
float[] airTempMax;
float[] airTempMin;

Table table;
int rowCount;

//coordinates for circles
float x = 40;
float y = 40;


void setup() {
  background(230);
  size(1100, 1100);
  smooth();
  noFill();
  strokeWeight(1.2);
  ellipseMode(CENTER);
  colorMode(HSB, 60);
  initializeMaxTemp();
  initializeMinTemp();
  println(airTempMin);

  noLoop();
}

void initializeMaxTemp() {

  //load the csv
  table = loadTable("Wetter_Potsdam.csv", "header");

  //count the rows
  rowCount = table.getRowCount();

  //length of array (-1 because last row is empty)
  airTempMax = new float[rowCount-1];

  // Array airTempMax is filled up here
  for (int i = 0; i &lt; airTempMax.length; i++) {
    airTempMax[i] = table.getFloat(i, 9);
  }
}

void initializeMinTemp() {

  //load the csv
  table = loadTable("Wetter_Potsdam.csv", "header");

  //count the rows
  rowCount = table.getRowCount();

  //length of array (-1 because last row is empty)
  airTempMin = new float[rowCount-1];

  // Array airTempMax is filled up here
  for (int k = 0; k &lt; airTempMin.length; k++) {
    airTempMin[k] = table.getFloat(k, 10);
  }
}


// here the tempurate is drawn and every day got its own color depending on temperature
void temperature() {

  for (int j = 0; j &lt; airTempMax.length; j++) {

    //color of each stroke
    stroke(airTempMin[j]+40, 100, 100);

    // every single line got rotated by one unit, all units equal 360 (deegree)
    rotate(radians(360.0/365));
    strokeWeight(0.2);
    line((airTempMin[j]*4)+150, 0, (airTempMax[j]*4)+150, 0);
    noStroke();
    fill(airTempMin[j]+40, 100, 100);
    ellipse((airTempMax[j]*4)+150,0,3,3);
    ellipse((airTempMin[j]*4)+150,0,3,3);
  }
}

void draw() {

  //we need translate here in order to have a visual anchor to read this diagram
  translate(width/2, height/2);

  // here the whole circle is rotate by 240 deegree
  rotate(radians(240));
  
  strokeWeight(1);
  temperature();
}

</pre>

<p>What I tried so far but stuck is to draw the line with vertex,
but it doesnt work like I want it to.</p>

<pre>

int radius = 200;
float[] airTempMax;

Table table;
int rowCount;

void setup(){
  size(500,500);
  noFill();
  noLoop();
  initializeMaxTemp();
  println(airTempMax);
}

void initializeMaxTemp() {

  //load the csv
  table = loadTable("Wetter_Potsdam.csv", "header");

  //count the rows
  rowCount = table.getRowCount();

  //length of array (-1 because last row is empty)
  airTempMax = new float[rowCount-1];

  // Array airTempMax is filled up here
  for (int i = 0; i &lt; airTempMax.length; i++) {
    airTempMax[i] = table.getFloat(i, 9);
  }
}

void draw(){
  translate(width/2,height/2);
  background(204);
  beginShape();
  for(int deg = 0; deg &lt; 365; deg++){
    float angle = radians(deg);
    float x = airTempMax[deg] + (cos(angle) * radius);
    float y = 5 + (sin(angle) * radius);
    vertex(x,y);
  }
  endShape();
}

</pre>

<p>If you have any ideas to solve this problem please let me know. Thank you!!</p>
]]></description>
   </item>
   <item>
      <title>How to create a faceted box with beginShape()?</title>
      <link>https://forum.processing.org/two/discussion/13709/how-to-create-a-faceted-box-with-beginshape</link>
      <pubDate>Mon, 30 Nov 2015 16:48:57 +0000</pubDate>
      <dc:creator>J_D</dc:creator>
      <guid isPermaLink="false">13709@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm trying to create a box where every face is subdivided into small triangular faces.
I tried to use the beginShape() function to create all the triangles but I cannot find a good way of
organizing the vertices position.</p>

<p>Can anyone give me any suggestion?
thanks,
J_D</p>
]]></description>
   </item>
   <item>
      <title>New Library</title>
      <link>https://forum.processing.org/two/discussion/13621/new-library</link>
      <pubDate>Tue, 24 Nov 2015 02:03:50 +0000</pubDate>
      <dc:creator>Vasco</dc:creator>
      <guid isPermaLink="false">13621@/two/discussions</guid>
      <description><![CDATA[<p>So i'm trying to put this text moving with the music, but i'm not getting it</p>
]]></description>
   </item>
   <item>
      <title>Processing crashes</title>
      <link>https://forum.processing.org/two/discussion/13245/processing-crashes</link>
      <pubDate>Sun, 25 Oct 2015 14:29:53 +0000</pubDate>
      <dc:creator>Tngabor</dc:creator>
      <guid isPermaLink="false">13245@/two/discussions</guid>
      <description><![CDATA[<p>Hey,
I've been working on a relatively simple sketch and after a few cycles of triangles being animated, processing gives me this error:</p>

<pre><code>#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000069277ea6, pid=5844, tid=15192
#
# JRE version: Java(TM) SE Runtime Environment (8.0_51-b16) (build 1.8.0_51-b16)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.51-b03 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [dcpr.dll+0x7ea6]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Program Files (x86)\processing-3.0.1\hs_err_pid5844.log
#
# If you would like to submit a bug report, please visit:
#   <a href="http://bugreport.java.com/bugreport/crash.jsp" target="_blank" rel="nofollow">http://bugreport.java.com/bugreport/crash.jsp</a>
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug
</code></pre>

<p>This is the sketch i'm running:</p>

<pre><code>int TriangleNo = 5;
int gridSize = 3;

Triangle[] newTriangle = new Triangle[TriangleNo];

void setup() {
  size(700, 700);
  smooth();
  noStroke();
  colorMode(HSB, 100);

  for (int n = 0; n &lt; newTriangle.length; n++) {
    newTriangle[n] = new Triangle();

    // get the first set of Triangles
    //newTriangle[n].display();
  }
}

void draw() {
  background(0, 0, 95);

  float grid = floor(width/gridSize);

  for (int i = 0; i &lt; gridSize; i++) {
    for (int j = 0; j &lt; gridSize; j++) {

      pushMatrix();
      translate(i*grid, j*grid);
      for (int n = 0; n &lt; newTriangle.length; n++) {
        newTriangle[n].display();
      }
      popMatrix();

    } // end j
  } // end i
}


//////////////////


class Triangle {
  float x1, y1, x2, y2, x3, y3;
  float xx1, yy1, xx2, yy2, xx3, yy3;
  float upSizeFactor = 100;
  color cF;

  Triangle() {
  }

  void display() {
    if (frameCount % 100 == 0) {
      getFill();
      getNumbers();
    }
    updateTriangle();
    drawTriangle(cF);
  }

  void updateTriangle() {
    x1 = lerp(x1, xx1, 0.15);
    y1 = lerp(y1, yy1, 0.15);
    x2 = lerp(x2, xx2, 0.15);
    y2 = lerp(y2, yy2, 0.15);
    x3 = lerp(x3, xx3, 0.15);
    y3 = lerp(y3, yy3, 0.15);
  }

  void getNumbers() {
    x1 = floor((random(3) - 1)) * upSizeFactor;
    y1 = floor((random(3) - 1)) * upSizeFactor;
    x2 = floor((random(3) - 1)) * upSizeFactor;
    y2 = floor((random(3) - 1)) * upSizeFactor;
    x3 = floor((random(3) - 1)) * upSizeFactor;
    y3 = floor((random(3) - 1)) * upSizeFactor;

    x1 = xx1;
    y1 = yy1;
    x2 = xx2;
    y2 = yy2;
    x3 = xx3;
    y3 = yy3;

    xx1 = floor((random(3) - 1)) * upSizeFactor;
    yy1 = floor((random(3) - 1)) * upSizeFactor;
    xx2 = floor((random(3) - 1)) * upSizeFactor;
    yy2 = floor((random(3) - 1)) * upSizeFactor;
    xx3 = floor((random(3) - 1)) * upSizeFactor;
    yy3 = floor((random(3) - 1)) * upSizeFactor;
  }

  void drawTriangle(color cF_) {
    beginShape();
    fill(cF_);
    vertex(x1, y1);
    vertex(x2, y2);
    vertex(x3, y3);
    endShape();
  }

  color getFill() {
    cF = color(random(100), 100, 95, 90);
    return cF;
  }
}
</code></pre>

<p>Here's the full log:
<a href="http://pastebin.com/JbsYyNwz" target="_blank" rel="nofollow">http://pastebin.com/JbsYyNwz</a></p>

<p>Anyone knows why this is happening?</p>
]]></description>
   </item>
   <item>
      <title>Why is the result upside down</title>
      <link>https://forum.processing.org/two/discussion/13016/why-is-the-result-upside-down</link>
      <pubDate>Wed, 14 Oct 2015 19:04:47 +0000</pubDate>
      <dc:creator>clankill3r</dc:creator>
      <guid isPermaLink="false">13016@/two/discussions</guid>
      <description><![CDATA[<p>It might be due the time since it's getting a bit late...
I know I could remove the 1.0 but it is somewhere else where it goes wrong I guess..</p>

<pre><code>#version 410

uniform mat4 transform;

in vec4 vertex;
in vec2 texCoord;

out vec2 vertTexCoord;

void main() {

    vertTexCoord = vec2(texCoord.x, 1.0 - texCoord.y);
    gl_Position = transform * vertex;
}
</code></pre>

<p>// ----</p>

<pre><code>#version 410


uniform sampler2D texture;

in vec2 vertTexCoord;

out vec4 fragColor;

void main() {
    fragColor = texture(texture, vertTexCoord);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Need help to remove shapes touchings (sort of collision detection)</title>
      <link>https://forum.processing.org/two/discussion/12919/need-help-to-remove-shapes-touchings-sort-of-collision-detection</link>
      <pubDate>Fri, 09 Oct 2015 22:01:28 +0000</pubDate>
      <dc:creator>zhidogolonoga</dc:creator>
      <guid isPermaLink="false">12919@/two/discussions</guid>
      <description><![CDATA[<p>Hello!
I'm quite new to programming and I have a problem with sketch. I've made a class of pyramids and trying to make it not to touch each other, but it doesn't work well... The mistake is 99% in <em>void collision_det()</em> method.
I would be so grateful if anyone helps me.</p>

<pre><code>import processing.opengl.*;
   Pyramid[] piramide;
   float[] n= new float [150];
   float[] m= new float [150];

void setup() {
  piramide = new Pyramid[150];
  size(900, 600, OPENGL);
for (int i=0; i&lt;piramide.length;i++) {
  n[i]=random(width);
  m[i]=random(height);
    piramide[i] = new Pyramid(n[i], m[i], random(20), random(5,15),(random(5,30)*0.001));

}
}

void draw() {
  smooth();
  lights();
  background(30,25,30);
for (int i=0; i&lt;piramide.length;i++) {
    Pyramid thisPyr = piramide[i];
    thisPyr.collision_det();
    thisPyr.rotacion();
  }
}


class Pyramid {
  float x, y, z, t, s;
  float theta=0.0;
  float alph;

  Pyramid(float tempX, float tempY, float tempZ, float tempT, float tempS) {
    x= tempX;
    y= tempY;
    z= tempZ;
    t= tempT;
    s= tempS;
  }

  void drawPiramide() {
    pushMatrix();

    translate(x, y);

    beginShape(TRIANGLES);
    noStroke();


   fill(220,220,220);
   vertex(0, t*2, 0); 
   vertex(0, 0, -t);
   vertex(-t, 0, 0);

   fill(250,250,250);
   vertex(0, t*2, 0);
   vertex(0, 0, -t);
   vertex(t, 0, 0);

   fill(220,220,220);
   vertex(0, t*2, 0);
   vertex(t, 0, 0);
   vertex(0, 0, t);

   fill(250,250,250);
   vertex(0, t*2, 0);
   vertex(0, 0, t);
   vertex(-t, 0, 0);

   fill(250,250,250);
   vertex(0, -t*2, 0);
   vertex(0, 0, -t);
   vertex(-t, 0, 0);

   fill(220,220,220);
   vertex(0, -t*2, 0);
   vertex(0, 0, -t);
   vertex(t, 0, 0);


   fill(250,250,250);
   vertex(0, -t*2, 0);
   vertex(t, 0, 0);
   vertex(0, 0, t);

   fill(220,220,220);
   vertex(0, -t*2, 0);
   vertex(0, 0, t);
   vertex(-t, 0, 0);

    rotateY(theta); 

    endShape();

    popMatrix();
  }

  void rotacion() { 
    theta+=0.002+s;
  }


  void collision_det() {
     boolean touching = false;


for (int i=0; i&lt;piramide.length;i++) {
Pyramid thisPyr = piramide[i];
for (int k=1; k&lt;piramide.length; k++)
{
Pyramid otherPyr = piramide[k];
float dis = dist(thisPyr.x, thisPyr.y, otherPyr.x, otherPyr.y);
if ((dis - 0.1) &lt; t*4) {
touching = true;
break;
}

if (touching == false) {
piramide[i].drawPiramide();
 }
 }
  }
}

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How I can rotate the cylinders from the same angle?</title>
      <link>https://forum.processing.org/two/discussion/12533/how-i-can-rotate-the-cylinders-from-the-same-angle</link>
      <pubDate>Wed, 16 Sep 2015 00:14:03 +0000</pubDate>
      <dc:creator>edwins04</dc:creator>
      <guid isPermaLink="false">12533@/two/discussions</guid>
      <description><![CDATA[<p>/* to convert degrees to radians not start me all from the angle 0. How I can I can put them to begin with the same angle?</p>

<p>I tried with the map function, but I feel the same.  */</p>

<p>float p=0;  // angle 1
float d=180; // ange 2
float w=180; // angle 3
float topRadius=10;
float bottomRadius=10;
float tall=100;
float sides=100;
float cpx, cpy,angle = 0,angle1,angle2;
int e;
float rx = 0;
float ry =0;
int gridSize=40;
float angulo=0;
void setup() {
  size(1080, 660, P3D);
}
void draw() {
  background(0);
  fill(255, 255, 255);</p>

<p>lights();
   translate(width / 2, height / 2,0);</p>

<p>fill(255,0,0);
   sphere(15);</p>

<pre><code> noStroke();
</code></pre>

<p>fill(255, 255, 255);
  translate(0, 0, 0);
   angle = radians(p) ;
 beginShape(QUAD_STRIP);
  for (int i = 0; i &lt; sides + 1; ++i) { 
    vertex(topRadius<em>cos(angle), 0, topRadius</em>sin(angle));
    vertex(bottomRadius<em>cos(angle), tall</em>0.8,bottomRadius<em>sin(angle));
    angle += TWO_PI / sides;
    rotateX(angle);
 }
endShape(); 
translate(0,tall</em>0.8,0);
fill(255,0,0);
sphere(15);
fill(255, 255, 255);
  angle1 = radians(d); 
  beginShape(QUAD_STRIP);
  for (int i = 0; i &lt; sides + 1; ++i) {<br />
    vertex(topRadius<em>cos(angle1), 0, topRadius</em>sin(angle1));
    vertex(bottomRadius<em>cos(angle1), tall</em>0.6,bottomRadius*sin(angle1));
    angle1 += TWO_PI / sides;
    rotateX(angle1);
  }
  endShape();</p>

<p>translate(0,tall<em>0.6,0);
  fill(255,0,0);
sphere(13);
fill(255, 255, 255);
  angle2 = radians(w); 
  beginShape(QUAD_STRIP);
  for (int i = 0; i &lt; sides + 1; ++i) {<br />
    vertex(topRadius</em>cos(angle2), 0, topRadius<em>sin(angle2));
    vertex(bottomRadius</em>cos(angle2), tall<em>0.5,bottomRadius</em>sin(angle2));
    angle2 += TWO_PI / sides;
    rotateX(angle2);
  }
  endShape();
  translate(0,tall*0.5,0);
  fill(255,0,0);
sphere(10);
println(angle, angle1, angle2);
}</p>
]]></description>
   </item>
   <item>
      <title>Why doesn't the shape rotate 45 degrees?</title>
      <link>https://forum.processing.org/two/discussion/12018/why-doesn-t-the-shape-rotate-45-degrees</link>
      <pubDate>Sun, 09 Aug 2015 19:11:00 +0000</pubDate>
      <dc:creator>applepie</dc:creator>
      <guid isPermaLink="false">12018@/two/discussions</guid>
      <description><![CDATA[<p>Why doesn't the wood paneled square rotate by 45 degrees instead of nothing showing up when the sketch is run?
I understand that objects need to be translated to the origin in order to be rotated about their centers.  Is that correct?</p>

<pre><code>void setup()
{
  size(400,400,P2D);
  stroke(0);
  line(width/2,0,width/2,height);
  line(0,height/2,width,height/2);

  noStroke();
  drawSquare(width/2,height/2,100,"wood1.jpg",1000);
}

void drawSquare(float centerX, 
                float centerY,  
                float squareSize, 
                String textureName, 
                float textureSize) {
  PImage img = loadImage(textureName);
  PShape s = createShape();
  s.beginShape();
  s.texture(img);

  s.vertex(centerX-squareSize/2, centerY-squareSize/2, 0, 0);
  s.vertex(centerX+squareSize/2, centerY-squareSize/2, textureSize, 0);
  s.vertex(centerX+squareSize/2, centerY+squareSize/2, textureSize, textureSize);
  s.vertex(centerX-squareSize/2, centerY+squareSize/2, 0, textureSize);
  s.endShape();
  s.translate(-centerX,-centerY);
  s.rotate(radians(45));
  s.translate(centerX,centerY);
  shape(s);
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to render Point Cloud efficiently?</title>
      <link>https://forum.processing.org/two/discussion/11949/how-to-render-point-cloud-efficiently</link>
      <pubDate>Mon, 03 Aug 2015 13:01:57 +0000</pubDate>
      <dc:creator>Jikid</dc:creator>
      <guid isPermaLink="false">11949@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>For random point cloud generated in realtime, what data structure in Processing is appropriate for its rendering?
I tried with PShape, but only got 10~15 FPS for 20,000 points.</p>

<pre>
PShape boxCloud;

void setup() {
  size(400, 400, P3D);
  smooth();
}

void draw() {
  background(0);
  translate(width/2, height/2);
  gen();
  shape(boxCloud);
}

void gen()
{
  boxCloud = createShape();
  boxCloud.beginShape(POINTS);
  boxCloud.stroke(255);
  for (int i = 0; i &lt; 20000; i++) {
    boxCloud.vertex(random(-50, 50), random(-50, 50), random(-50, 50));
  }
  boxCloud.endShape();
}
</pre>

<p>I've test ofMesh in openFrameworks, it can run at almost 60 FPS rendering 200,000 points.
Is it possible to do that in Processing?</p>
]]></description>
   </item>
   <item>
      <title>texture on curveVertex - problem</title>
      <link>https://forum.processing.org/two/discussion/11504/texture-on-curvevertex-problem</link>
      <pubDate>Mon, 29 Jun 2015 20:57:02 +0000</pubDate>
      <dc:creator>kmarkusk</dc:creator>
      <guid isPermaLink="false">11504@/two/discussions</guid>
      <description><![CDATA[<p>Hi Processing Forum,</p>

<p>I am working on a graphic and tried to add a structure, what is not working.
Does anybody has an advice for me?
Thanks a lot.</p>

<p>Markus</p>

<p>import ddf.minim.*;
import processing.pdf.*;
PImage img;</p>

<p>boolean record;</p>

<p>Minim minim;
AudioInput input;</p>

<p>void setup() {</p>

<p>size(displayWidth, displayHeight,  P3D);
minim = new Minim (this);
input = minim.getLineIn (Minim.STEREO, 512);
noCursor(); 
img = loadImage("bild.jpg");
}</p>

<p>void draw() {</p>

<p>if(record){
    beginRaw(PDF, "output.pdf");
  }</p>

<p>float dim = input.mix.level () * width;
translate(width/2, height/2, 0);</p>

<p>pushMatrix();
scale(0.9);</p>

<p>rotateX(PI/2);
rotateZ(-PI/10);</p>

<p>beginShape();
texture(img);
background(19,19,19);</p>

<p>smooth();</p>

<p>//stroke(255,175,0);
stroke(255);
strokeWeight(1.8);</p>

<p>scale(0.9);
smooth();</p>

<p>rotateX(frameCount/700.0);
  rotateY(frameCount/600.0);
  rotateZ(frameCount/200.0);</p>

<p>curveVertex( mouseX, 320, -120);
curveVertex(-250, -dim, -mouseX);
curveVertex(   -mouseY,   -190,  mouseX);</p>

<p>curveVertex(-260, -dim, mouseX);
curveVertex(-dim, -190, -210);
curveVertex(   mouseX,    -mouseY,  dim);</p>

<p>curveVertex(-160, -mouseX, -290);
curveVertex(-dim, dim, -210);
curveVertex(   100,    140,  dim);</p>

<p>curveVertex(-mouseY, mouseX, -390);
curveVertex(-dim, dim, -210);
curveVertex(  mouseY,    240,  dim);</p>

<p>curveVertex( 120, -220, mouseX);
curveVertex( 290,  dim, dim);
curveVertex(  dim,    dim,  mouseY);</p>

<p>fill(255);</p>

<p>curveVertex(mouseX, 220, -150);
curveVertex(-dim, 110, dim);
curveVertex(   -mouseY,   -150,  mouseY);</p>

<p>curveVertex( mouseX, 220, -dim);
curveVertex(-350, -dim, -220);
curveVertex(   mouseX,   210,  -mouseX);</p>

<p>curveVertex(mouseX,  dim, -200);
curveVertex(-110, dim, mouseY);
curveVertex(   230,    dim,  -mouseY);</p>

<p>curveVertex(340,  dim, -325);
curveVertex(mouseY, dim, -135);
curveVertex(   -dim,    -mouseY,  mouseY);
endShape();
popMatrix();</p>

<p>pushMatrix();
fill(19,19,19);
noStroke();
rectMode(CENTER);
//rect(0,0,500,500);
popMatrix();</p>

<p>if (record) {
    endRaw();
    record = false;
  }</p>

<p>endShape(CLOSE);</p>

<p>}</p>

<p>//boolean sketchFullScreen() {
//return true;
//}</p>

<p>void keyPressed() {
  if (key == 'r') {
    record = true;
  }
}</p>
]]></description>
   </item>
   <item>
      <title>Circle not closing properly</title>
      <link>https://forum.processing.org/two/discussion/10930/circle-not-closing-properly</link>
      <pubDate>Thu, 21 May 2015 10:04:35 +0000</pubDate>
      <dc:creator>Biophonism</dc:creator>
      <guid isPermaLink="false">10930@/two/discussions</guid>
      <description><![CDATA[<p>Hello all. I'm trying to draw a circle with trigonometry, calling curveVertex() every 30 degrees in a for loop. The thing is, even though I include 360 in the for statement, the stroke doesn't close properly with endShape(). I don't want to use endShape(CLOSE), because it closes with a line instead of a curve, and the 30 degree step makes it look terrible. What am I doing wrong?</p>

<pre lang="processing">
beginShape();
for(int i = 0; i &#60;= 360; i += 30) {
   curveVertex(pos.x + sin(radians(i))*r, pos.y + cos(radians(i))*r);
}
endShape();
</pre>
]]></description>
   </item>
   </channel>
</rss>