<?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 #javascriptmode - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23javascriptmode</link>
      <pubDate>Sun, 08 Aug 2021 21:17:14 +0000</pubDate>
         <description>Tagged with #javascriptmode - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23javascriptmode/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>The book of making games with processing</title>
      <link>https://forum.processing.org/two/discussion/15761/the-book-of-making-games-with-processing</link>
      <pubDate>Wed, 30 Mar 2016 10:05:10 +0000</pubDate>
      <dc:creator>n_ryota</dc:creator>
      <guid isPermaLink="false">15761@/two/discussions</guid>
      <description><![CDATA[<p>Hello.
I wrote the book of making games with processing. 
(Japanese version only)</p>

<h2>Book (biginner)</h2>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-ZXN9XD9o_4E"><span class="VideoPreview"><a href="http://youtube.com/watch?v=ZXN9XD9o_4E"><img src="http://img.youtube.com/vi/ZXN9XD9o_4E/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>
Details: <a href="http://dev.eyln.com/book2.html" target="_blank" rel="nofollow">http://dev.eyln.com/book2.html</a></p>

<h2>Book (intermediate)</h2>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-XHoAr1-ZwNg"><span class="VideoPreview"><a href="http://youtube.com/watch?v=XHoAr1-ZwNg"><img src="http://img.youtube.com/vi/XHoAr1-ZwNg/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>
Details: <a href="http://dev.eyln.com/book.html" target="_blank" rel="nofollow">http://dev.eyln.com/book.html</a></p>

<p>I am a game developer.
Macross VO, Naval Ops: Warship Gunner, Super Smash Bros. Brawl X. ...etc.</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>A Few Questions About Processing 3</title>
      <link>https://forum.processing.org/two/discussion/13023/a-few-questions-about-processing-3</link>
      <pubDate>Wed, 14 Oct 2015 22:33:27 +0000</pubDate>
      <dc:creator>BleuBox</dc:creator>
      <guid isPermaLink="false">13023@/two/discussions</guid>
      <description><![CDATA[<p>I would like to download Processing 3, but I don't want to lose my work. I have two questions about the newest version.
1: Has Processing.js come out with an updated version yet that is compatible with Processing 3 sketches, or does it not need to?
2: Will all of my Processing 2 files be deleted when I download Processing 3?</p>
]]></description>
   </item>
   <item>
      <title>Unable to install the JavaScript module</title>
      <link>https://forum.processing.org/two/discussion/12028/unable-to-install-the-javascript-module</link>
      <pubDate>Mon, 10 Aug 2015 18:28:31 +0000</pubDate>
      <dc:creator>Glitchman</dc:creator>
      <guid isPermaLink="false">12028@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, I recently installed Processing v2.2.1.
I'm running it on a Windows 8.1, Alienware laptop with a default resolution of 3200 x 1800.</p>

<p>I have two issues I would like to get assistance with:</p>

<p>1) When I go to install JavaScript in the Mode Manager I get this error message: 
Could not delete C:\Users&#91;myFolder]\Documents\Processing\modes\mode6040194572416500742tmp\JavaScriptMode\mode\JavaScriptMode.jar
Could not delete C:\Users&#91;myFolder]\Documents\Processing\modes\mode6040194572416500742tmp\JavaScriptMode\mode
Could not delete C:\Users&#91;myFolder]\Documents\Processing\modes\mode6040194572416500742tmp\JavaScriptMode
Could not delete C:\Users&#91;myFolder]\Documents\Processing\modes\mode6040194572416500742tmp</p>

<p>Can anyone help me install the JavaScript module ?</p>

<p>2) Some, but not all, texts are tiny! Almost unreadable. I've been following some google search leads but not found anything that helps. Tried to lower resolution but the tiny text stays just as tiny in the Processing program. What to do ?</p>

<p>Sincere thanks!
Glitchman</p>
]]></description>
   </item>
   <item>
      <title>Button Actions not Working on Export</title>
      <link>https://forum.processing.org/two/discussion/10217/button-actions-not-working-on-export</link>
      <pubDate>Tue, 07 Apr 2015 03:50:53 +0000</pubDate>
      <dc:creator>GhostRavenstorm</dc:creator>
      <guid isPermaLink="false">10217@/two/discussions</guid>
      <description><![CDATA[<p>I made a custom button here that should play an audio file when you press it. It should also change the cursor type on mouse hover too but none of it work when I run this in JavaScript.</p>

<p><a href="http://www.openprocessing.org/sketch/192964" target="_blank" rel="nofollow">http://www.openprocessing.org/sketch/192964</a></p>

<p>The version on OpenProcessing does nothing and running it in JavaScript locally does nothing. It otherwise works perfectly fine in Java.</p>
]]></description>
   </item>
   <item>
      <title>Video in Processing JS?</title>
      <link>https://forum.processing.org/two/discussion/9821/video-in-processing-js</link>
      <pubDate>Wed, 11 Mar 2015 18:15:29 +0000</pubDate>
      <dc:creator>Laurazaylea</dc:creator>
      <guid isPermaLink="false">9821@/two/discussions</guid>
      <description><![CDATA[<p>Hi!
I'm new to the forum and would love your help. I have a sketch that plays video. It uses this basic Processing video code: <a href="https://processing.org/reference/libraries/video/Movie.html" target="_blank" rel="nofollow">https://processing.org/reference/libraries/video/Movie.html</a></p>

<p>It works perfectly in "java" but will not work in "javascript" mode. I'd like to put this sketch online, either via OpenProcessing.org or on my own website. I can do this for my other sketches, but not for sketches that include video files.</p>

<p>My questions:</p>

<p>(1) Is there code that works for playing videos in javascript mode? Where can I find this?</p>

<p>(2) If not, is there a preferred method for putting java sketches (with video!) online? Is this possible?</p>

<p>Thank you!!
~LZ</p>
]]></description>
   </item>
   <item>
      <title>Error in JavaScript Mode - Saving Images</title>
      <link>https://forum.processing.org/two/discussion/9516/error-in-javascript-mode-saving-images</link>
      <pubDate>Fri, 20 Feb 2015 23:14:57 +0000</pubDate>
      <dc:creator>atomant</dc:creator>
      <guid isPermaLink="false">9516@/two/discussions</guid>
      <description><![CDATA[<p>I am getting the following error when I try to run my script.  It works fine in Java mode.</p>

<p><code>Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: processing.app.Base.showWarning(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
    at de.bezier.mode.javascript.JavaScriptBuild.build(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptBuild.export(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptMode.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleStartServer(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleSave(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExportCheckModified(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptEditor.handleStartServer(Unknown Source)
    at de.bezier.mode.javascript.JavaScriptToolbar.handlePressed(Unknown Source)
    at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:474)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)</code></p>

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

<pre><code>`PImage img;
PImage screen;
double initialDifference;
double maxDifference;
color[] imgVector;
int imgScale = 4;

void setup() {
  img = loadImage("mona_lisa_small.jpg");
  //size(img.width * imgScale, img.height * imgScale);
  size(100 * imgScale, 148 * imgScale);  
  background(255);
  stroke(255,0);

  // Put image pixels into vector for faster use
  imgVector = new color[img.pixels.length];
  for (int i = 0; i &lt; img.pixels.length; i++) {
    imgVector[i] = img.pixels[i];
  }

  maxDifference = totalDifference();

  // Load saved file
  //PImage bg = loadImage("screen-save-circles.tiff");
  //size(bg.width,bg.height);
  //background(bg);     // To load from save file

}

void draw() {
  int m = millis();
  initialDifference = totalDifference();
  println(initialDifference);
  saveFrame("screen.tiff");
  //addTriangle();
  addCircle();
  double newDifference = totalDifference();
  if (newDifference &gt; initialDifference) {
    screen = loadImage("screen.tiff");
    background(screen);
  }

}


void addTriangle() {
  float[] points = new float[10];

/*   
  // Create random triangle 
  for (int k = 0; k &lt; 6; k++) {
    if (k % 2 == 0) {
     points[k] =  random(0 - (.5 * width), width + (.5 * width));
    }
    else {
     points[k] =  random(0 - (.5 * height), height + (.5 * height));
    }
  }
*/  
  // Create random triangle of limited size
  int limit = constrain((int)(9000 * (initialDifference / maxDifference)), 250, 800);    // Number of max pixels away from first point
  println("limit: " + limit);
  points[0] =  random(0 - (.5 * width), width + (.5 * width));
  points[1] =  random(0 - (.5 * height), height + (.5 * height));
  points[2] = points[0] + random(-limit, limit);
  points[3] = points[1] + random(-limit, limit);
  points[4] = points[0] + random(-limit, limit);
  points[5] = points[1] + random(-limit, limit); 


  // Add random color and alpha to array
  points[6] = random(255);
  points[7] = random(255);
  points[8] = random(255);
  points[9] = random(255);  

  // Add triangle
  fill( points[6], points[7], points[8], points[9]);
  //fill(points[6], points[9]);
  triangle(points[0], points[1], points[2], points[3], points[4], points[5]);
}

void addCircle() {
  float[] points = new float[7];

  // Create random circle of limited size
  int limit = 100;    // Number of max pixels away from first point
  points[0] =  random(0 - (.5 * width), width + (.5 * width));
  points[1] =  random(0 - (.5 * height), height + (.5 * height));
  points[2] = random(0, limit);

  // Add random color and alpha to array
  points[3] = random(255);
  points[4] = random(255);
  points[5] = random(255);
  points[6] = random(255);  

  // Add circle
  fill( points[3], points[4], points[5], points[6]);
  ellipse(points[0], points[1], points[2], points[2]);
}

double totalDifference() {
  loadPixels();
  // Return total difference between image and screen
  double total = 0;
  for (int i = 0; i &lt; imgVector.length; i++) {
    // Changed to use small image with 4x screen size
    int j = (i * imgScale) + ((width * imgScale - width) * (i / img.width));
    total += differenceOfPixels(pixels[j], imgVector[i]);
  }
  return total;  
}

double differenceOfPixels(color c1, color c2) {
  String str1 = hex(c1);
  String r1 = str1.substring(2,4);
  String g1 = str1.substring(4,6);
  String b1 = str1.substring(6,8);

  int red1 = Integer.parseInt(r1, 16);
  int green1 = Integer.parseInt(g1, 16);  
  int blue1 = Integer.parseInt(b1, 16);

  String str2 = hex(c2);
  String r2 = str2.substring(2,4);
  String g2 = str2.substring(4,6);
  String b2 = str2.substring(6,8);

  int red2 = Integer.parseInt(r2, 16);
  int green2 = Integer.parseInt(g2, 16);  
  int blue2 = Integer.parseInt(b2, 16);

  double diff = (Math.pow(red1 - red2,2) + Math.pow(green1 - green2,2) + Math.pow(blue1 - blue2,2));   
  return diff; 
}
</code></pre>

<p>`</p>

<p>The program just randomly adds triangles to the canvas and keeps it if it makes the canvas closer to what the original image looks like.</p>

<p>Is the problem with saving images in JavaScript mode?  Or something else</p>

<p>edit: I changed the size() to a constant value and now the error is gone and the page comes up but the script just shows a white canvas and does nothing. Even adding Background(img) shows a blank canvas</p>
]]></description>
   </item>
   <item>
      <title>I want to put my aplication in my website, but doesn't work in JavaScript Mode</title>
      <link>https://forum.processing.org/two/discussion/8711/i-want-to-put-my-aplication-in-my-website-but-doesn-t-work-in-javascript-mode</link>
      <pubDate>Wed, 17 Dec 2014 21:45:53 +0000</pubDate>
      <dc:creator>sain120</dc:creator>
      <guid isPermaLink="false">8711@/two/discussions</guid>
      <description><![CDATA[<p>Hello everybody!</p>

<p>I'm a beginner in processing, this is my second game I've created. It's about parabolic shoot and my fisic teacher said she wanted to put in her blog to make his students play and at the same time make them interested in the subject.
So I saw the way to do it was to upload to openproccesing.org, then copy the embed code and paste in the blog. 
The problem was that for uploading, it required me to change to JavaScript mode and when I do the game doesn't run.
How I can figure it out? Is there another way to upload at any page without changing to JavaScript?</p>

<p>Thank you all.</p>

<p><a rel="nofollow" href="http://www.openprocessing.org/sketch/178104"><strong>http://www.openprocessing.org/sketch/178104</strong></a></p>

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

<pre><code>PFont dis;
PFont vel;
PFont at;
PFont pnt;
PFont tit;

float fps = 90;
float t;

int pun = 0;
int plus;
int ins = 0;

float linespa;

float dnx;
float dny;

float lindx;
float lindy;

float dns = 60;

float flecx;
float flecy;

float bow = -30;
float cord;

float g;
float speed;
float speedx;
float speedy;
float speedmk = 30;

float ang = -45;
float radbow;
float radflec;

int c = 0;

int sta = 3;

void setup() {
  frameRate(fps);
  size(600, 400);
  dis = loadFont("CharterBT-BoldItalic-48.vlw");
  vel = loadFont("Arial-Black-48.vlw");
  at = loadFont("CenturyGothic-48.vlw");
  pnt = loadFont("CenturyGothic-Bold-48.vlw");
  tit = loadFont("ACaslonPro-Italic-48.vlw");
}

void draw() {

  background(255);

  if (sta == 0) {

    flecx = 60;
    flecy = height - 50;
    radflec = radbow;
    cord = -30;
    lindx = dnx;
    lindy = dny;

    if (keyPressed) {

      if (key == 'w') { 
        ang -= 0.5;
      }
      if (key == 's') { 
        ang += 0.5;
      }

      if (key == 'd') { 
        speedmk += 0.5;
      }
      if (key == 'a') { 
        speedmk -= 0.5;
      }

      if (key == 'k' &amp;&amp; speedmk != 0) { 
        sta = 1;
      }

      speedmk = constrain(speedmk, 0, 40);
      speed = speedmk/fps*5;
      ang = constrain(ang, -90, 0);

      delay(75);
    }

  } else if(sta == 1) {

    t += 1/fps;
    g += 9.81/sq(fps)*5;

    speedx = speed*cos(abs(radbow));
    speedy = -speed*sin(abs(radbow)) + g;

    flecx += speedx;
    flecy += speedy;

    lindx = flecx;
    lindy = flecy;

    cord += speed;

    radflec = atan(speedy/speedx);


    if (flecx &gt; width + 30 || flecy &gt; height + 30) { 
      sta = 3;
      ins++;
    } 

    if (flecx &gt;= dnx - dns/57 &amp;&amp; flecx &lt;= dnx + dns/57 &amp;&amp; flecy &lt;= dny + dns/2 &amp;&amp; flecy &gt;= dny - dns/2) { 
      sta = 2; 
      c = 0; 
    }


  } else if(sta == 2) {

      if (flecy &lt;= dny + dns/16 &amp;&amp; flecy &gt;= dny - dns/16) {
        plus = 45;
        fill(255, c, c);
      } else if (flecy &lt;= dny + dns/4 &amp;&amp; flecy &gt;= dny - dns/4) {
        plus = 15;
        fill(c, 255, c);
      } else {
        plus = 5;
        fill(c, c, 255);
      }

      if(c == 0) { pun = pun + plus; ins++; }

      c += 5;
      c = constrain(c, 0, 255);

      textFont(vel);
      textAlign(CENTER);
      textSize(130);
      text("+" +plus, (width - 40)/2, (height - 50)/2);

    if(c &gt;= 255) { sta = 3; }

  } else if (sta == 3) {

    dnx = round(random(200 + dns/6, width - 40 - dns/6));
    dny = round(random(100 + dns/2, height - 50 - dns/2));
    g = 0;
    t = 0;
    sta = 0;
  }

  cord = constrain(cord, bow - 15, bow);
  bow = map(speedmk, 0, 40, -30, -15);
  radbow = map(ang, 0, 360, 0, 2*PI); 

  strokeWeight(1);

  stroke(200);
  line(lindx, lindy, width - 40, lindy);
  line(lindx, lindy, lindx, height - 50);

  textFont(tit);
  textAlign(RIGHT);
  textSize(15);
  fill(170);
  text("Alejandro Camacho", width, height - 5);

  stroke(100);

  line(60, height - 50, width - 40, height - 50);
  line(width - 40, height - 40, width - 40, 0);

  for (linespa = 60; linespa &lt;= width - 40; linespa += 500/20.0) {
    line(linespa, height - 50, linespa, height - 40);
  }

  for (linespa = 60; linespa &lt;= width - 40; linespa += 500/80.0) {
    line(linespa, height - 50, linespa, height - 45);
  }

  for (linespa = height - 50; linespa &gt;= 0; linespa -= 500/20.0) {
    line(width - 40, linespa, width - 30, linespa);
  }

  for (linespa = height - 50; linespa &gt;= 0; linespa -= 500/80.0) {
    line(width - 40, linespa, width - 35, linespa);
  }

  stroke(0);

  fill(0, 0, 255);
  ellipse(dnx, dny, dns/3, dns);
  fill(0, 255, 0);
  ellipse(dnx, dny, dns/9, dns/2);
  fill(255, 0, 0);
  ellipse(dnx, dny, dns/27, dns/8);


  textFont(vel);
  textSize(15);
  textAlign(SQUARE);
  fill(speedmk*6.375, 0, 255 - speedmk*6.375);
  text(speedmk +"m/s", 100, height - 12);

  textFont(at);
  textSize(15);
  fill(0);
  text(abs(ang) +"º", 62, height - 70);

  pushMatrix();

  translate(60, height - 50);

  rotate(radbow);

  noFill();
  strokeWeight(4);
  stroke(220, 90, 0);
  arc(bow, 0, 30, 75, -PI/2, PI/2);

  strokeWeight(1);
  stroke(130, 95, 75);
  line(cord, 0, bow, 75/2);
  line(cord, 0, bow, -75/2);


  popMatrix();


  pushMatrix();

  translate(flecx, flecy);
  rotate(radflec);

  strokeWeight(2);
  stroke(0, 0, 0);

  line(0, 0, -30, 0);

  popMatrix();

  textFont(pnt);
  textSize(20);
  textAlign(LEFT, TOP);
  fill(0);
  text("PUNTOS = " +pun, 10, 10);
  text("PRECISION = " +String.format("%.1f", pun/float(ins)), 10, 30);

  textSize(40);
  textAlign(RIGHT, TOP);
  fill(200);
  text(String.format("%.1f", t) + "s", width - 60 , 10);

  textFont(dis);
  fill(0);
  textAlign(CENTER);
  textSize(15);

  text(String.format("%.1f", (lindx - 60)/5) +"m", lindx, height - 30);
  text(String.format("%.1f", (height - 50 - lindy)/5) +"m", width - 20, lindy);


}
</code></pre>
]]></description>
   </item>
   <item>
      <title>PGraphics in processing.js</title>
      <link>https://forum.processing.org/two/discussion/7826/pgraphics-in-processing-js</link>
      <pubDate>Mon, 27 Oct 2014 09:38:52 +0000</pubDate>
      <dc:creator>abdullah</dc:creator>
      <guid isPermaLink="false">7826@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I am using processing.js to display my processing code in a web browser. 
So I have a "Sphere_" class that has render() method. This method returns in PGraphics datatype.</p>

<pre><code>PGraphics render()
  {
    if (!lockDiameter)
      sphereDiameter = map( particles.size(), 0, 2*NUM_OF_PARTICLES, 0.75*MEAN_SPHERE_DIAMETER, 1.25*MEAN_SPHERE_DIAMETER );
    else
      sphereDiameter = MEAN_SPHERE_DIAMETER;

    sphereScreen.beginDraw();
    //sphereScreen.clear();
    sphereScreen.pushMatrix();

    sphereScreen.translate(sphereScreen.width/2, sphereScreen.height/2);

    for ( int i=0; i&lt;particles.size (); i++ )
    {
      particles.get(i).update(sphereDiameter);    
      setNeighbors( particles.get(i) ); 
      sphereScreen = particles.get(i).render(sphereScreen);
    }
    sphereScreen.popMatrix();
    sphereScreen.endDraw();

    return sphereScreen;
  }
</code></pre>

<p>There is also another class named "Particle" which also has a "render()" function that takes a PGraphics, and draws an ellipse on it and returns. 
After doing binary search and the println("works till here"); method, I found that in javascript mode execution stops at the sphereScreen.clear() function call. 
1. Are there any <strong>alternatives to PGraphics clear() in processing.js</strong>?</p>

<p>After commenting the clear() call the function seemed to execute fine. But, in another part of the sketch, I am drawing this PGraphics by calling render() in a image() method:</p>

<pre><code>image(s1.render(), 10, 10);
</code></pre>

<p>where s1 is an object of the Sphere_ class. 2. The problem is that the <strong>execution stops at this image() function call</strong>. I know that the render() function works but dont know what I am doing wrong here. Any help would be greatly appreciated.</p>
]]></description>
   </item>
   <item>
      <title>drop downs?</title>
      <link>https://forum.processing.org/two/discussion/6922/drop-downs</link>
      <pubDate>Wed, 27 Aug 2014 17:51:42 +0000</pubDate>
      <dc:creator>brettburton</dc:creator>
      <guid isPermaLink="false">6922@/two/discussions</guid>
      <description><![CDATA[<p>Anyone know how to do drop downs in javascript mode?<br />
I was using the controlP5 library, but it hasn't been ported to javascript.</p>
]]></description>
   </item>
   <item>
      <title>JavaScript - export for web</title>
      <link>https://forum.processing.org/two/discussion/6340/javascript-export-for-web</link>
      <pubDate>Tue, 15 Jul 2014 12:26:52 +0000</pubDate>
      <dc:creator>scen</dc:creator>
      <guid isPermaLink="false">6340@/two/discussions</guid>
      <description><![CDATA[<p>My script runs just fine in Processing under the JavaScript mode.  But when I Export for Web, the index HTML doesn't work.  The web page opens without error and I can see the header and footer stuff that is standard.  But the script is just blank.  I even tried it with processing.js sample code (below) and the same thing.  What am I missing?  Is there a setting in processing or something?</p>

<p>Sample code:</p>

<pre><code>/**
  PROCESSINGJS.COM - BASIC EXAMPLE
  Delayed Mouse Tracking  
  MIT License - Hyper-Metrix.com/F1LT3R
  Native Processing compatible 
*/  

// Global variables
float radius = 50.0;
int X, Y;
int nX, nY;
int delay = 16;

// Setup the Processing Canvas
void setup(){
  size( 200, 200 );
  strokeWeight( 10 );
  frameRate( 15 );
  X = width / 2;
  Y = width / 2;
  nX = X;
  nY = Y;  
}

// Main draw loop
void draw(){

  radius = radius + sin( frameCount / 4 );

  // Track circle to new destination
  X+=(nX-X)/delay;
  Y+=(nY-Y)/delay;

  // Fill canvas grey
  background( 100 );

  // Set fill-color to blue
  fill( 0, 121, 184 );

  // Set stroke-color white
  stroke(255); 

  // Draw circle
  ellipse( X, Y, radius, radius );                  
}


// Set circle's next destination
void mouseMoved(){
  nX = mouseX;
  nY = mouseY;  
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>problem with QUAD_STRIP in Javascript Mode</title>
      <link>https://forum.processing.org/two/discussion/6347/problem-with-quad-strip-in-javascript-mode</link>
      <pubDate>Tue, 15 Jul 2014 20:34:58 +0000</pubDate>
      <dc:creator>tfvbhy</dc:creator>
      <guid isPermaLink="false">6347@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm working on a project involving an interactive torus, which I'm building in processing as a QUAD_STRIP shape—I can't think of how else one might do it.</p>

<p>The code runs pretty well in java mode.  In particular, it's smooth, the frame-rate is as fast as i need it, and the lighting is working (call to lights() function) at the beginning of draw().</p>

<p>but i need the sketch in javascript mode, and that is not working out so nicely.  the frame rate is slow enough that there's a refresh line circling the torus, the call to smooth(x) (i was using maximum 8) does not seem to be effecting the anti-aliasing at all, and the call to lights() is doing nothing but slightly darkening (uniformly) the entire shape.</p>

<p>a bit of googling brought me to these, which seem unfortunately relevant to my current issue: 
-<a href="http://forum.processing.org/one/topic/javascript-mode-beginshape-and-lights.html" target="_blank" rel="nofollow">http://forum.processing.org/one/topic/javascript-mode-beginshape-and-lights.html</a>
-<a href="https://groups.google.com/forum/#!topic/processingjs/VU8CGCsiqQE" target="_blank" rel="nofollow">https://groups.google.com/forum/#!topic/processingjs/VU8CGCsiqQE</a></p>

<p>but these are old links, so i was hoping that if this is all caused by a known bug then it would have been fixed by now... perhaps overly optimistic.</p>

<p>code for the torus follows, thanks in advance for any help!</p>

<hr />

<pre><code>float x,y,z,e;
int pts = 50; 
float angle = 0;
float radius = 50;

// lathe segments
int segments = 60;
float latheAngle = 0;
float latheRadius = 100.0;

//vertices
PVector vertices[], vertices2[];

void setup() {
  frameRate(80);

  size(500,500,P3D);
  x = width/2;
  y = height/2;
  z = 0;
  e=width;

}

void draw() {
  angle = 0;
  latheAngle = 0;
  lights();
  background(0);
  smooth(8);


//Color parameters
  //noFill();
  fill(50,10,250);
  noStroke();

  //println(e);
  camera(e*cos((2*PI/width)*mouseX), e*cos((PI/height)*mouseY), e*sin((2*PI/width)*mouseX), 0, 0, 0, 0, 1, 0);
  rectMode(CENTER);


// initialize point arrays 
  vertices = new PVector[pts+1]; 
  vertices2 = new PVector[pts+1];

  // fill arrays &lt;br&gt;
  for(int i=0; i&lt;=pts; i++){ 
    vertices[i] = new PVector();
    vertices2[i] = new PVector();
    vertices[i].x = latheRadius + sin(radians(angle))*radius;
    vertices[i].z = cos(radians(angle))*radius; 
    angle+=360.0/pts; 
  } 

  // draw toroid 
  latheAngle = 0; 
  for(int i=0; i&lt;=segments; i++){ 
    beginShape(QUAD_STRIP); 
    for(int j=0; j&lt;=pts; j++){ 
      if (i&gt;0){ &lt;br&gt;
        vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z); 
      } 
      vertices2[j].x = cos(radians(latheAngle))*vertices[j].x; 
      vertices2[j].y = sin(radians(latheAngle))*vertices[j].x; 
      vertices2[j].z = vertices[j].z; 
      vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z); 
    }
  latheAngle+=360.0/segments; 
  endShape(); 
  }
}

//MouseWheel Control assigns value of -12 to 12 to each scroll position, scale by width/50 to get zoom amount
void mouseWheel(MouseEvent event) {
  e += (width+height)/(100)*event.getCount();
  println(e);
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == DOWN) {
      e += (width+height)/(20);
    } else if (keyCode == UP) {
      e -= (width+height)/(20); 
    } 
  } 
} 
</code></pre>
]]></description>
   </item>
   <item>
      <title>Guido in JS broken?</title>
      <link>https://forum.processing.org/two/discussion/5801/guido-in-js-broken</link>
      <pubDate>Sat, 14 Jun 2014 20:02:23 +0000</pubDate>
      <dc:creator>newmiracle</dc:creator>
      <guid isPermaLink="false">5801@/two/discussions</guid>
      <description><![CDATA[<p>I installed the guido library in order to do some GUI work in Javscript mode. The examples won't run in JS mode, however. Though from my understanding, they should be able to.</p>

<p>The sketches fail to run, and the error I get in the console is "Uncaught Processing.js: Unable to execute pjs sketch: ReferenceError: Interactive is not defined". Seems like the library isn't being loaded properly.</p>

<p>Any fixes? Am I doing something wrong? Did a Processing/PJS update break guido? Any advice appreciated. If this should be under the 'library' category, apologies ahead of time.</p>

<p>Any other decent PJS compatible GUI libraries?</p>
]]></description>
   </item>
   <item>
      <title>Javascript mode stopped working. Any suggestions?</title>
      <link>https://forum.processing.org/two/discussion/5247/javascript-mode-stopped-working-any-suggestions</link>
      <pubDate>Sun, 18 May 2014 22:19:14 +0000</pubDate>
      <dc:creator>philbutrin</dc:creator>
      <guid isPermaLink="false">5247@/two/discussions</guid>
      <description><![CDATA[<p>The past few weeks, Processing sketches that used to run fine on my laptop (Mac OSX 10.9.3) in Javascript mode no longer run.  When I try to run them, a browser window opens and it sits there stuck on "Waiting for 127.0.0.1", and the Processing console gives me this:</p>

<p><code>        Exception in thread "Processing.BasicServer" java.lang.NoSuchMethodError: processing.app.Base.showWarning(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Exception;)V
            at de.bezier.mode.javascript.JavaScriptBuild.build(Unknown Source)
            at de.bezier.mode.javascript.JavaScriptBuild.export(Unknown Source)
            at de.bezier.mode.javascript.JavaScriptMode.handleExport(Unknown Source)
            at de.bezier.mode.javascript.JavaScriptEditor.handleExport(Unknown Source)
            at de.bezier.mode.javascript.JavaScriptEditor.serverStarted(Unknown Source)
            at de.bezier.mode.javascript.BasicServer.run(Unknown Source)
            at java.lang.Thread.run(Thread.java:745)</code></p>

<p>Tonight I saw that there was a new Version 2.2, so I upgraded from 2.1.2, hoping that would fix the problem, but it does not.</p>

<p>Any suggestions what might be wrong and how I can fix it?  In addition to not being able to run my sketches in Javascript mode, I can no longer export the project either.</p>
]]></description>
   </item>
   <item>
      <title>[Solved] Why these two codes are not working in js mode ? Difficult debuggin in js mode.</title>
      <link>https://forum.processing.org/two/discussion/5266/solved-why-these-two-codes-are-not-working-in-js-mode-difficult-debuggin-in-js-mode</link>
      <pubDate>Tue, 20 May 2014 02:27:40 +0000</pubDate>
      <dc:creator>blyk</dc:creator>
      <guid isPermaLink="false">5266@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I am trying to run these code in js mode but none of them working. Each of them just show grey color blacnk screen, nothing else.</p>

<p>I found the same problem in so many blogs but everyone has their own different solution for different issue.</p>

<p>In the chrome console I see this error: "<em>Uncaught Processing.js: Unable to execute pjs sketch: TypeError: undefined is not a function</em> "</p>

<pre><code> //Code 1
PShape MouseShape;
PShape mright;
PShape mleft;
PShape mwheel;
PShape mcursor;
PShape[] Children;
void setup() {
  size(400, 300);
  MouseShape = loadShape("C:/Users/FB-Abhniv/Documents/Processing/SVGtesting/data/bot.svg");
  Children = MouseShape.getChildren();
  mleft    = MouseShape.getChild(Children[0].getName());
  mright   = MouseShape.getChild(Children[1].getName());
  mwheel   = MouseShape.getChild(Children[2].getName());
  mcursor  = MouseShape.getChild(Children[3].getName());
}

void draw() {
  scale(0.5);
  translate(width/4, 0);
  background(-1);
  noStroke();
  fill(0);
  MouseShape.disableStyle();
  shape(MouseShape, 0, 0);

  if (Rflag) {
    mright.disableStyle();
    fill(#FF0000);
    shape(mright, 0, 0);
  }
  if (Lflag) {
    mleft.disableStyle();
    fill(#FF0000);
    shape(mleft, 0, 0);
  }
  //-----------------------------
  mwheel.disableStyle();
  if (mW&gt;0)fill(#5000FF);
  else if (mW&lt;0)fill(#00FF28);
  else fill(0);
  shape(mwheel, 0, 0);
  //-----------------------------
  mcursor.disableStyle();
  fill(-1);
  shape(mcursor, 0, mW*20);
}
//---------------
boolean Lflag, Rflag;
void mousePressed() {
  if (mouseButton==LEFT) Lflag = true;
  else Lflag = false;
  if (mouseButton==RIGHT) Rflag = true;
  else Rflag = false;
}

void mouseReleased() {
  Rflag = false;
  Lflag = false;
}
//----------------
float mW;
void mouseWheel(MouseEvent event) {
  mW = event.getCount();
  println(mW);
}



//Code 2
import ddf.minim.analysis.*;
import ddf.minim.*;

Minim       minim;
FFT         fft;
ArrayList&lt;Float&gt; poop = new ArrayList();
int bufferSize=512;
int highest=0;
float[] sample;
void setup()
{
  size(800, 300, P3D);
  minim = new Minim(this);
  fft = new FFT( bufferSize,50000); //  FFT(int timeSize,float sampleRate)
}

void draw()
{
  background(0);
  stroke(#FF0000);
  sample = new float[poop.size()];
  for (int i=0;i&lt;poop.size();i++) {
    Float f = (float) poop.get(i);
    sample[i] = f;
  }
  if (poop.size()&lt; bufferSize) {
    float t = map(mouseX, 0, width, 0, bufferSize);
    poop.add(t);
  }
  else poop.remove(0);

  stroke(#009BFF);
  line(width/2, 20, mouseX, 20);
  if (sample.length==bufferSize) {
    fft.window(FFT.HAMMING);
    fft.forward(sample);
    for (int i = 0; i &lt; fft.specSize(); i++)
    {
      stroke(0, 255, 0);
      float x = map(i, 0, fft.specSize(), 0, width);
      line( x, height, x, height - fft.getBand(i)/50.0);
      //-----------------For getting the highest frequency ----
//      if (fft.getFreq(i) &gt;= fft.getFreq(highest)) {
//        highest=i;
//        float freq = fft.getFreq(highest);
//        println( " Band" + fft.getBand(i) +  " freq" + freq );
//      }
      //-----------------For getting the highest frequency ----
    }
  }
  else   println(poop.size());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Socket handling in Processing code?</title>
      <link>https://forum.processing.org/two/discussion/5053/socket-handling-in-processing-code</link>
      <pubDate>Sun, 11 May 2014 11:34:29 +0000</pubDate>
      <dc:creator>javiergodas</dc:creator>
      <guid isPermaLink="false">5053@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys, I have a processing code and I want to use sockets to go with it. Do you know how to handle that i processing? I didn't see anything on the reference. The fact is, I want to have an online server using the javascript port (Javascript supports sockets), and two clients, one in java and other in android. Any idea of how I can connect the three with a socket relationship?</p>
]]></description>
   </item>
   <item>
      <title>TypeError: p.draw is not a function</title>
      <link>https://forum.processing.org/two/discussion/4383/typeerror-p-draw-is-not-a-function</link>
      <pubDate>Mon, 14 Apr 2014 16:02:57 +0000</pubDate>
      <dc:creator>Matthewdk54</dc:creator>
      <guid isPermaLink="false">4383@/two/discussions</guid>
      <description><![CDATA[<p>So I am trying to render with javascript mode, a .pde that is essential and "drag and drop" media object, in the browser and I keep getting a blank screen when it loadsup. 
When I go to troubleshoot it (thinking its the preload as the image frames are loaded remotely) I get an error in the JS console of Firefox saying I have a TypeError: p.draw is not a function.</p>

<p>I have no idea what this is or how its connected to p.draw() call in processing.js ... My guess is it has something to do with my float placements.</p>

<p>Any help combing my code?</p>

<p>Thanks,</p>

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

<pre><code>/* <a href="/two/profile/pjs">@pjs</a> preload="<a href="https://sociallantern.weebly.com/files/theme/video1.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video1.png</a>"; */
/* <a href="/two/profile/pjs">@pjs</a> preload="<a href="https://sociallantern.weebly.com/files/theme/video2.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video2.png</a>"; */
/* <a href="/two/profile/pjs">@pjs</a> preload="<a href="https://sociallantern.weebly.com/files/theme/video3.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video3.png</a>"; */
/* <a href="/two/profile/pjs">@pjs</a> preload="<a href="https://sociallantern.weebly.com/files/theme/TV.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/TV.png</a>"; */

float a; 

PImage TVscreen;

PImage video1; 
PImage video2; 
PImage video3;

float bx;
float by;

float ix;
float iy;

float zx;
float zy;

//icon width/height dim
int bs = 40;

//select
boolean bover = false;
boolean bover1 = false;
boolean bover2 = false;

//pick up
boolean locked = false;
boolean locked1 = false;
boolean locked2 = false; 

//load
boolean draw = true;
boolean draw1 = true; 
boolean draw2 = true; 

//play
boolean drag1 = false;
boolean drag2 = false;
boolean drag3 = false;

//position change
float bdifx = 0.0; 
float bdify = 0.0; 

float bdifx1 = 0.0;
float bdify1 = 0.0;

float bdifx2 = 0.0;
float bdify2 = 0.0;

// drop in 
Boolean mouseOverRect0(int x, int y, int w, int h) {
  return (mouseX &gt;= x &amp;&amp; mouseX &lt;= x+ w &amp;&amp; mouseY &gt;= y &amp;&amp; mouseY &lt;= y+h);
}

Boolean mouseOverRect1(int x, int y, int w, int h) {
  return (mouseX &gt;= x &amp;&amp; mouseX &lt;= x+ w &amp;&amp; mouseY &gt;= y &amp;&amp; mouseY &lt;= y+h);
}

Boolean mouseOverRect2(int x, int y, int w, int h) {
  return (mouseX &gt;= x &amp;&amp; mouseX &lt;= x+ w &amp;&amp; mouseY &gt;= y &amp;&amp; mouseY &lt;= y+h);
}

void setup() 
{
  size(640, 480);

  video1 = loadImage ("<a href="https://sociallantern.weebly.com/files/theme/video1.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video1.png</a>");
  video2 = loadImage ("<a href="https://sociallantern.weebly.com/files/theme/video2.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video2.png</a>");
  video3 = loadImage ("<a href="https://sociallantern.weebly.com/files/theme/video3.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/video3.png</a>");

  TVscreen = loadImage ("<a href="https://sociallantern.weebly.com/files/theme/TV.png" target="_blank" rel="nofollow">https://sociallantern.weebly.com/files/theme/TV.png</a>");
}

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

  // video player window
  fill(5, 5, 5);
  rect(75, 198, 405, 206);
  image(TVscreen, 40, 160); 
  fill(203, 252, 8);
  text("Drag and Drop Video Files into TV", 60, 180);
  image(video1, bx, by, bs, bs);
  image(video2, ix, iy, bs, bs);
  image(video3, zx, zy, bs, bs);

  // video 1 selector

  if (mouseX &gt; bx-bs &amp;&amp; mouseX &lt; bx+bs &amp;&amp; 
    mouseY &gt; by-bs &amp;&amp; mouseY &lt; by+bs) {

    bover = true;  
    if (!locked) { 
      stroke(255); 
      fill(153);
      bover1 =false;
      bover2 =false;
      locked1=false;
      locked2=false;
    }
  } 
  else {
    stroke(153);
    fill(153);
    bover = false;
    bx = 570;
    by = 220;
  }

  //video 2 selector
  if (mouseX &gt; ix-bs &amp;&amp; mouseX &lt; ix+bs &amp;&amp; 

    mouseY &gt; iy-bs &amp;&amp; mouseY &lt; iy+bs) {

    bover1 = true;  
    if (!locked1) { 
      stroke(255); 
      fill(153);
      bover =false;
      bover2 =false;
      locked=false;
      locked2=false;
    }
  } 
  else {
    stroke(153);
    fill(153);
    bover1 = false;

    ix = 570;
    iy = 280;
  }

  //video 3 selector
  if (mouseX &gt; zx-bs &amp;&amp; mouseX &lt; zx+bs &amp;&amp; 

    mouseY &gt; zy-bs &amp;&amp; mouseY &lt; zy+bs) {

    bover2 = true;  
    if (!locked2) { 
      stroke(255); 
      fill(153);
      bover1 =false;
      bover =false;
      locked=false;
      locked1=false;
    }
  } 
  else {
    stroke(153);
    fill(153);
    bover2 = false;

    zx = 570;
    zy = 340;
  }

  // video 1 

  int qx = 75;
  int qy = 198;
  int qw = 405;
  int qh = 206;

  if (mouseOverRect0 (qx, qy, qw, qh) &amp;&amp; bover == true &amp;&amp; locked==false) {
    draw = false;
    draw1 = true;
    draw2 = true;
    drag1 = true;

    bx = 570;
    by =220;
  } 

  if (bx == 570 &amp;&amp; by == 220 &amp;&amp; draw == false) {
    image(video1, 75, 198, 405, 206);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }

  if (draw == false) {

    image(TVscreen, 40, 160);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }

  //video 2 

  int fx = 75;
  int fy = 198;
  int fw = 405;
  int fh = 206;

  if (mouseOverRect1 (fx, fy, fw, fh) &amp;&amp; bover1 == true &amp;&amp; locked1==false) {
    draw1 = false;
    draw = true;
    draw2 = true;
    drag2 = true;

    ix = 570;
    iy =280;
  } 
  if (ix == 570 &amp;&amp; iy == 280 &amp;&amp; draw1 == false) {
    image(video2, 75, 198, 405, 206);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }
  if (draw1 == false) {

    image(TVscreen, 40, 160);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }

  int cx = 75;
  int cy = 198;
  int cw = 405;
  int ch = 206;

  if (mouseOverRect2 (cx, cy, cw, ch) &amp;&amp; bover2 == true &amp;&amp; locked2==false) {
    draw2 = false;
    draw = true;
    draw1 = true;
    drag3 = true; 

    zx = 570;
    zy = 340;
  } 
  if (zx == 570 &amp;&amp; zy == 340 &amp;&amp; draw2 == false) {
    image(video3, 75, 198, 405, 206);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }

  if (draw2 == false) {

    image(TVscreen, 40, 160);
    fill(203, 252, 8);
    text("Drag and Drop Video Files into TV", 60, 180);
  }

}

void mousePressed() {

  // video 1 pick up
  if (bover) { 
    locked = true; 
    fill(255, 255, 255);
  } 
  else {
    locked = false;
  }

  bdifx = mouseX-bx; 
  bdify = mouseY-by; 

  //video 2 pick up
  if (bover1) { 
    locked1 = true; 
    fill(255, 255, 255);
  } 
  else {
    locked1 = false;
  }

  bdifx1 = mouseX-ix; 
  bdify1 = mouseY-iy; 

  //video 3 pick up
  if (bover2) { 
    locked2 = true; 
    fill(255, 255, 255);
  } 
  else {
    locked2 = false;
  }

  bdifx2 = mouseX-zx; 
  bdify2 = mouseY-zy;
}
void mouseDragged() {
  //video 1 move
  if (locked) {

    bx = mouseX-bdifx; 
    by = mouseY-bdify;
  }
  //video 2 move
  if (locked1) {

    ix = mouseX-bdifx1; 
    iy = mouseY-bdify1;
  }
  //video 3 move  
  if (locked2) {

    zx = mouseX-bdifx2; 
    zy = mouseY-bdify2;
  }
}

void mouseReleased() {

  locked = false;
  locked1 = false;
  locked2 = false;
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>