<?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 #pimage - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23pimage</link>
      <pubDate>Sun, 08 Aug 2021 20:58:47 +0000</pubDate>
         <description>Tagged with #pimage - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23pimage/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Combine Images</title>
      <link>https://forum.processing.org/two/discussion/18537/combine-images</link>
      <pubDate>Fri, 14 Oct 2016 02:10:28 +0000</pubDate>
      <dc:creator>mcdpdr</dc:creator>
      <guid isPermaLink="false">18537@/two/discussions</guid>
      <description><![CDATA[<p>Hi. I have four binary images with blobs in different locations. I would like to "combine" these images to from one image that has the blobs from the four binary images.</p>

<p>Below are four my binary images
<img src="https://forum.processing.org/two/uploads/imageupload/546/D8NK5KSLF4EB.PNG" alt="1" title="1" />
<img src="https://forum.processing.org/two/uploads/imageupload/585/O1REZ5306GL2.PNG" alt="2" title="2" />
<img src="https://forum.processing.org/two/uploads/imageupload/789/NR3OZ005CX48.PNG" alt="3" title="3" />
<img src="https://forum.processing.org/two/uploads/imageupload/218/LMR3DHBARIEM.PNG" alt="4" title="4" /></p>
]]></description>
   </item>
   <item>
      <title>Do filters behave differently with different rendering engines?</title>
      <link>https://forum.processing.org/two/discussion/17711/do-filters-behave-differently-with-different-rendering-engines</link>
      <pubDate>Mon, 01 Aug 2016 01:00:10 +0000</pubDate>
      <dc:creator>herring</dc:creator>
      <guid isPermaLink="false">17711@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I am revisiting an old project in which I save a bunch of ellipses to a PGraphics object, then draw that, apply the INVERT filter to it, scale it down a bit and draw it again (the goal is to create color interference patterns).</p>

<p>With JAVA2D, which I used previously, drawing, inverting and re-drawing works fine, with FX2D, which gives me ~6 times the fps and therefore would be awesome to use, both instances I draw have the same color instead of complementary colors.
Anything I am missing?</p>

<p>Here's the relevant code excerpt:</p>

<pre><code>layer.colorMode(RGB);

layer.endDraw();
image(layer, (width-rWidth)/2, (height-rHeight)/2, rWidth, rHeight);
rotate(rotation);
layer.filter(INVERT);
image(layer, 0, 0);
</code></pre>

<p>Thank you in advance for any insights! :)</p>

<p>On a side-note, ever since using FX2D I also get this (doesn't seem to impact functionality, though, is this related? - I use Processing in Eclipse BTW)</p>

<pre><code>Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX Application Thread
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:236)
    etc...
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I make a character that walks to wherever the mouse clicks?</title>
      <link>https://forum.processing.org/two/discussion/15159/how-can-i-make-a-character-that-walks-to-wherever-the-mouse-clicks</link>
      <pubDate>Sat, 27 Feb 2016 19:45:18 +0000</pubDate>
      <dc:creator>Clova</dc:creator>
      <guid isPermaLink="false">15159@/two/discussions</guid>
      <description><![CDATA[<p>Our assignment is: Make a character that walks to a point you click. You can draw the character with a pen and scan it, or draw it in illustrator. 
So, I drew a character in illustrator. There are two images, because I drew the character in two positions and used an array so when animated it looks like it's walking. I got the walking character to move across the screen continuously, but I can't figure out how to make it first stand still, then when I click, start "walking" to the place I clicked then stop. As far as I can tell, it seems that the map/mouseX thing only works when you have shapes like ellipses, not Pimages. Also, I can't get the character to just appear in the first position (standing still) until clicking, when it starts "walking". I can't get it to stop switching between the images and just appear standing still in the begging, so the way I have it now, the screen is completely blank until you click, and then the moving character appears. How can I fix this? 
Here is the code i have so far, but you won't be able to actually run it because you can't access the Pimages. (however, the character is a smiling ice cream cone, like in my profile picture...)
I'm new to processing and I barely understand anything; help would be much appreciated!!! :)</p>

<p>int var1 = 200;
int numFrames = 2;
int frame = 0;
PImage[] icecream = new PImage[numFrames]; 
long timer;
float framespeed = 300;
boolean walk;
int icecreamspeed = 3;</p>

<p>void setup ()
{
  size(700,700);
 icecream[0] = loadImage("character1.jpg");
  icecream[1] = loadImage("character2.jpg");</p>

<p>timer = millis();
  imageMode(CENTER);
}</p>

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

<p>background(255);
  var1 ++;
  if(var1 == width) {
    var1 = 0;</p>

<p>}</p>

<p>if (millis() - timer &gt; framespeed) {
  timer = millis();
  frame ++;
}
if (frame == numFrames) {
  frame = 0;
}
if(walk == true) {
image(icecream[frame], var1,400);</p>

<p>}
}</p>

<p>void mouseClicked() {
walk = true;
image(icecream[frame], mouseX, 400);</p>

<p>}</p>

<p>void mouseReleased() {
  walk = false;</p>

<p>}</p>
]]></description>
   </item>
   <item>
      <title>How to sample colors from an image to create new drawings</title>
      <link>https://forum.processing.org/two/discussion/15146/how-to-sample-colors-from-an-image-to-create-new-drawings</link>
      <pubDate>Fri, 26 Feb 2016 18:49:22 +0000</pubDate>
      <dc:creator>mef233</dc:creator>
      <guid isPermaLink="false">15146@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
I am attempting to program Processing 2 to look at an image, sample the image's colors and use those values/data to create new drawings.<br />
Is there a way to do this? I've looked under PImage headings but most of the entries revolve around recreating the image in processing.
Any idea of what I should do/ Where I should look?</p>
]]></description>
   </item>
   <item>
      <title>Loading random images each time the function called</title>
      <link>https://forum.processing.org/two/discussion/15045/loading-random-images-each-time-the-function-called</link>
      <pubDate>Sun, 21 Feb 2016 22:47:43 +0000</pubDate>
      <dc:creator>ekinkes</dc:creator>
      <guid isPermaLink="false">15045@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm trying to load random images each time the function called using an array. That looks logical, but I get an error like "Cannot convert PImage to PImage[]" "Type mismatch, "processing.core.PImage" does not match with processing.core.PImage[]". Does it mean I can't use arrays with PImage,what am I doing wrong?</p>

<p>Simplified code:</p>

<pre><code>PImage[] ImageArray= new PImage[7];

void setup() {
  fullScreen();

  for (int i=0; i&lt;ImageArray.length; i++) {
    ImageArray=loadImage(i + ".png");
  }
}

void draw() {
  background(0);
      if (frameCount % 2 == 0) {
        image(ImageArray[(int)random(7)], 0, 0);
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Making a copy of an image</title>
      <link>https://forum.processing.org/two/discussion/14679/making-a-copy-of-an-image</link>
      <pubDate>Sat, 30 Jan 2016 05:11:46 +0000</pubDate>
      <dc:creator>CantSayIHave</dc:creator>
      <guid isPermaLink="false">14679@/two/discussions</guid>
      <description><![CDATA[<p>Quick question -</p>

<p>I know if I have a PImage "Shape" and I try to make a copy of Shape by saying</p>

<pre><code>PImage copyShape = Shape;
</code></pre>

<p>I'll only create a reference to Shape.</p>

<p>How do I make a separate copy?</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Can processing run out of memory?</title>
      <link>https://forum.processing.org/two/discussion/14214/can-processing-run-out-of-memory</link>
      <pubDate>Fri, 01 Jan 2016 06:38:35 +0000</pubDate>
      <dc:creator>CantSayIHave</dc:creator>
      <guid isPermaLink="false">14214@/two/discussions</guid>
      <description><![CDATA[<p>I'm currently making a program to select certain colors of the same type in a picture, like a <em>magic wand tool</em>.</p>

<p>After running several times I've noticed that smaller pictures are processed just fine, while larger ones, like the size of my monitor, freeze the program indefinitely. I receive no error, just the same screen. Could this be a memory problem?</p>
]]></description>
   </item>
   <item>
      <title>updated: Help texturing in 3D? quad_strip, triangle_fan</title>
      <link>https://forum.processing.org/two/discussion/13720/updated-help-texturing-in-3d-quad-strip-triangle-fan</link>
      <pubDate>Tue, 01 Dec 2015 02:01:43 +0000</pubDate>
      <dc:creator>utdtmort23</dc:creator>
      <guid isPermaLink="false">13720@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I am new to this site, however I am in a Processing course at my university.
I am in the process of creating a scene to present to the class that includes a non-primitive 3D object, with one required aspect that I need to texture the object.</p>

<p>I decided to use drawCylinder, as well as QUAD_STRIP and TRIANGLE_FAN to get my desired shape. 
However, I am completely stuck on how I might texturize it.</p>

<p>I have looked through the book and even asked peers, but no luck. Can't figure out how to map the UV coordinates.
Hoping someone on here can point me in the right direction.
Any help would be GREATLY appreciated!</p>

<p>I was trying different things but it just ended up messing with the overall outcome of my scene so I decided to revert back to the original.
My goal is to import a diamond texture in order to wrap the diamond shaped geometry.
Apologies for the comments/notes.</p>

<p>Thanks so much.
My code is below:</p>

<pre><code>    PImage tex;

    void setup() {
      size(800, 600, P3D);
      tex = loadImage("diamond.png");
    }


    void draw() {
      background(0);
      pointLight(255, 101, 0, width/2, height/2, 200); //point light
    //  lights(); //default lighting
      translate(width/2, height/2);
      rotateY(map(mouseX, 0, width, 0, PI));
      rotateZ(map(mouseY, 0, height, 0, -PI));
    //rotateX(map(mouseX-mouseY, 0, width, 0, PI*2)); //add wacky X rotation
      //stroke color
      stroke(100);
      //stroke weight
      strokeWeight(3);
      fill(255, 255, 255);
      translate(0, -40, 0);

    //mouse triggers object mesh view
    if (mousePressed == true){ 
       background(255);
       stroke(random(0,255), random(0,255), random(0,255)); //stroke strobe
       noFill(); //mesh viewable
     }
     else{
       fill(255);
     }

    drawCylinder(0, 150, 150, 8); // Draw a hexagonal base
    //drawCylinder(10, 180, 200, 16); // Draw a mix between a cylinder and a cone 
    //drawCylinder(70, 70, 120, 64); // Draw a cylinder
    //drawCylinder(0, 180, 200, 4); // Draw a pyramid
    }

    void drawCylinder(float topRadius, float bottomRadius, float tall, int sides) {
      float angle = 0;
      float angleIncrement = TWO_PI / sides;
      beginShape(QUAD_STRIP);

      // texture(tex);

      for (int i = 0; i &lt; sides + 1; ++i) {
        vertex(topRadius*cos(angle), 0, topRadius*sin(angle));
        vertex(bottomRadius*cos(angle), tall, bottomRadius*sin(angle));
        angle += angleIncrement;

      }
      endShape();

      // If it is not a cone, draw the circular top cap
    /*  if (topRadius != 0) {
        angle = 0;
        beginShape(TRIANGLE_FAN);
        // Center point
        vertex(0, 0, 0);
        for (int i = 0; i &lt; sides + 1; i++) {
          vertex(topRadius * cos(angle), 0, topRadius * sin(angle));
          angle += angleIncrement;
        }
        endShape();
      }
      */
      // If it is not a cone, draw the circular bottom cap
      if (bottomRadius != 0) {
        angle = 0;
        beginShape(TRIANGLE_FAN);
        // Center point
        vertex(0, tall, 0);
        for (int i = 0; i &lt; sides+1; i++) {
          vertex(bottomRadius * cos(angle), tall, bottomRadius * sin(angle));
          angle += angleIncrement;
        }
        endShape();
      }

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>pixels[] returning gray</title>
      <link>https://forum.processing.org/two/discussion/13677/pixels-returning-gray</link>
      <pubDate>Thu, 26 Nov 2015 23:46:52 +0000</pubDate>
      <dc:creator>CantSayIHave</dc:creator>
      <guid isPermaLink="false">13677@/two/discussions</guid>
      <description><![CDATA[<p>Does pixels[] actually contain an array of colors? I keep trying to use this:</p>

<pre><code>color currentPX = baseImg.pixels[ xPlace + ( baseImg.width * yPlace ) ];
</code></pre>

<p>but it always returns gray.</p>

<p>The image loads in correctly, and I'm using loadPixels();</p>

<p>What could I be doing wrong?</p>
]]></description>
   </item>
   <item>
      <title>Create a particle explosion of an image</title>
      <link>https://forum.processing.org/two/discussion/13674/create-a-particle-explosion-of-an-image</link>
      <pubDate>Thu, 26 Nov 2015 22:08:56 +0000</pubDate>
      <dc:creator>CantSayIHave</dc:creator>
      <guid isPermaLink="false">13674@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'd like to make an explosion effect for a game I'm making. The image is about 20 pixels w/h so I'm not looking for anything huge.</p>

<p>I'd like to make it radiate outwards and fade from a central point, but I can't think of how to.</p>

<p>Any help is appreciated.</p>

<p>Thanks</p>
]]></description>
   </item>
   <item>
      <title>Can I use selectOutput() to create and write to an image with PImage.save() ?</title>
      <link>https://forum.processing.org/two/discussion/12165/can-i-use-selectoutput-to-create-and-write-to-an-image-with-pimage-save</link>
      <pubDate>Thu, 20 Aug 2015 02:54:47 +0000</pubDate>
      <dc:creator>CantSayIHave</dc:creator>
      <guid isPermaLink="false">12165@/two/discussions</guid>
      <description><![CDATA[<p>So I have this:</p>

<pre><code>PImage img;
void setup(){
  img = loadImage("rock.jpg");
  selectOutput("Select a file to write to:", "fileSelected");
}
void draw(){}
void fileSelected(File selection) {
  if (selection == null) {
    println("Window was closed or the user hit cancel.");
  } else {
    println("User selected " + selection.getAbsolutePath());
    PImage.save(selection.getAbsolutePath());
  }
}
</code></pre>

<p>and I was thinking it should work, however I'm just met with 
"Cannot make a static reference to the non-static method save(String) from the type PImage"</p>

<p>Is there a way to select save destination?</p>
]]></description>
   </item>
   <item>
      <title>Use a function to display images</title>
      <link>https://forum.processing.org/two/discussion/12086/use-a-function-to-display-images</link>
      <pubDate>Fri, 14 Aug 2015 15:04:48 +0000</pubDate>
      <dc:creator>piddj</dc:creator>
      <guid isPermaLink="false">12086@/two/discussions</guid>
      <description><![CDATA[<p>I have 8 images that I want to display via a function. Each implementation of the function needs to show a different image.
What I cant work out is how to pass the image—for that function implementation—what image it needs to show...</p>

<p>ie.</p>

<p>PImage a, b;</p>

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

<p>a = loadImage("a.jpg");</p>

<p>b = loadImage("b.jpg");</p>

<p>}</p>

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

<p>myImage(???????, 40, 40); // to show a</p>

<p>myImage(???????, 80, 80); // to show b</p>

<p>}</p>

<p>void myImage(???????, int x, int y) {</p>

<p>image(???????, x, y);</p>

<p>}</p>

<p>Can anyone help clarify the ??????????'s ?</p>

<p>Thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>add text to PImage</title>
      <link>https://forum.processing.org/two/discussion/11890/add-text-to-pimage</link>
      <pubDate>Wed, 29 Jul 2015 21:29:44 +0000</pubDate>
      <dc:creator>ondsinet_</dc:creator>
      <guid isPermaLink="false">11890@/two/discussions</guid>
      <description><![CDATA[<p>My program saves videos from some webcams connected to the pc.
I used to draw the Capture to the screen,add some information of the video(duration,time ...) and then take a screenshot of the sketch,and tehn repeat for every webcam.
Now to extend the program I directly save the Capture as PImage, but how do I add the text to the image?</p>
]]></description>
   </item>
   <item>
      <title>Loading an Image</title>
      <link>https://forum.processing.org/two/discussion/10293/loading-an-image</link>
      <pubDate>Mon, 13 Apr 2015 18:49:58 +0000</pubDate>
      <dc:creator>RifleGirl</dc:creator>
      <guid isPermaLink="false">10293@/two/discussions</guid>
      <description><![CDATA[<p>I am confused as to why this won't show an image.
map.png is in the folder of the project</p>

<pre><code>void setup()
{
  size(400,400);
  USA = loadImage("map.png");
}

void Draw()
{
  background(0);
  image(USA,400,400);
}

PImage USA;
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to set the alpha value of a copy of a PImage?</title>
      <link>https://forum.processing.org/two/discussion/10133/how-to-set-the-alpha-value-of-a-copy-of-a-pimage</link>
      <pubDate>Wed, 01 Apr 2015 12:28:48 +0000</pubDate>
      <dc:creator>danielle_nl</dc:creator>
      <guid isPermaLink="false">10133@/two/discussions</guid>
      <description><![CDATA[<p>Hi all,</p>

<p>I'm struggling to find a way to make a part of an image created with copy() transparent. 
The images are preloaded into an array in setup(). I don't display the original images.
I loop through the loaded images in draw() and use copy() to create a resized slice of the images.
Is there a way to add transparency to these slices? I could also make the original transparent because it isn't displayed anyway. I tried using tint() in setup before loading but that doesn't work.</p>

<p>Any help is highly appreciated, best, Danielle.</p>
]]></description>
   </item>
   <item>
      <title>Mac OS Mission Control Mockup</title>
      <link>https://forum.processing.org/two/discussion/10100/mac-os-mission-control-mockup</link>
      <pubDate>Sun, 29 Mar 2015 19:04:52 +0000</pubDate>
      <dc:creator>seelysassage</dc:creator>
      <guid isPermaLink="false">10100@/two/discussions</guid>
      <description><![CDATA[<p>I am working on a mockup that works like os x's mission control. The process is the following: The sketch is run and you see several images on the window. Press a key to shrink down the images in the window to where the mouse pointer is located, in this shrunk view, if a window is clicked, the shrunk view is then exited, and the image clicked will be centered at where the mouse was clicked in the shrunk view window. I need help checking if the mouse cursor was within a specific image. I can't hard code in the location of each image since they will dynamically change when they are clicked in the shrunk view. Any guidance will be appreciated</p>
]]></description>
   </item>
   <item>
      <title>Suggestion for a simple Photo Album</title>
      <link>https://forum.processing.org/two/discussion/10020/suggestion-for-a-simple-photo-album</link>
      <pubDate>Wed, 25 Mar 2015 01:47:45 +0000</pubDate>
      <dc:creator>HenrySmith</dc:creator>
      <guid isPermaLink="false">10020@/two/discussions</guid>
      <description><![CDATA[<p>Hi there,</p>

<p>I hope this post isn't too specific.</p>

<p>I am creating a simple application which consists of a Classic car album where the user can flip through various pages. However I am not sure what is the best and easiest way to display pictures of various size neatly on the sketch, one next to each other, similar to for example Google Image search results as shown below:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/000/POMZFQOY8ALH.JPG" alt="ClassicCars" title="ClassicCars" /></p>

<p>Can someone recommend how this may be done or whether there exists any tools that can facilitate this task? I was thinking of splitting the sketch in equal grids and scaling each image to fit exactly in each box. However I am not sure if this is the best way to do it.</p>

<p>Any recommendations will be greatly appreciated!</p>
]]></description>
   </item>
   <item>
      <title>problem with a dynamic mask over a video</title>
      <link>https://forum.processing.org/two/discussion/5255/problem-with-a-dynamic-mask-over-a-video</link>
      <pubDate>Mon, 19 May 2014 11:53:28 +0000</pubDate>
      <dc:creator>elfo11</dc:creator>
      <guid isPermaLink="false">5255@/two/discussions</guid>
      <description><![CDATA[<p>I use this code wich is actually working exept that at random time i see a flash of the full-frame of my video (non masked)
someone can explain me why?</p>

<pre><code>import processing.video.*;
Movie myMovie;

PGraphics gBuffer;
void setup() {
  size(1280, 720);
  myMovie = new Movie(this, "mifo.mov");
  myMovie.loop();
  gBuffer = createGraphics( width, height);
}

void draw() {
    background(0);
  gBuffer.beginDraw();
  gBuffer.background(0);//clear the mask
  gBuffer.fill(255);
  gBuffer.ellipse(mouseX,mouseY,250,250);//draw a new circle
  gBuffer.endDraw();
  myMovie.mask(gBuffer);//apply the mask to the image
  image(myMovie, 0, 0);
}

void movieEvent(Movie m) {
  m.read();  
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to show an image with Pimage during X seconds?</title>
      <link>https://forum.processing.org/two/discussion/9727/how-to-show-an-image-with-pimage-during-x-seconds</link>
      <pubDate>Fri, 06 Mar 2015 18:28:26 +0000</pubDate>
      <dc:creator>Ziph0n</dc:creator>
      <guid isPermaLink="false">9727@/two/discussions</guid>
      <description><![CDATA[<p>Hi!</p>

<p>I'm trying to show an image with Pimage during X seconds.</p>

<p>Here is my actual code (simplified):</p>

<pre><code>PImage Image_Caisse_Claire;
PImage Image_Caisse_Claire_Hot;

void setup()
{
  size(1080, 610);
}

void draw()
{
  Image_Caisse_Claire=loadImage("Caisse_Claire.png");
  Image_Caisse_Claire_Hot=loadImage("Caisse_Claire_Hot.png");
}

void keyPressed()
{
  if (keyPressed == true &amp;&amp; key == 'a' &amp;&amp; menu == 2) 
  {
    image(Image_Caisse_Claire_Hot, 140, 310, 258, 136); // My problem is here
  }
}
</code></pre>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>getting multiple sections of an image in a 2D array</title>
      <link>https://forum.processing.org/two/discussion/9475/getting-multiple-sections-of-an-image-in-a-2d-array</link>
      <pubDate>Wed, 18 Feb 2015 01:32:39 +0000</pubDate>
      <dc:creator>elliot</dc:creator>
      <guid isPermaLink="false">9475@/two/discussions</guid>
      <description><![CDATA[<p>I’m using get() to get a section of an image and then draw the section to the same location it was taken from.</p>

<p>For example:</p>

<pre><code>PImage focal1;

void setup() {

size(900, 600);
focal1 = loadImage(“focal1.jpg");

}

void draw() {

PImage newfocal1;

newfocal1 = focal1.get(0, 0, 300, 200);
  image(newfocal1, 0, 0);

}
</code></pre>

<p>This process is so I can section up the image into a grid.</p>

<p>I’m doing this so I can load in 2 other images and apply the same process to those images so I can click on the section of the first image and have the ability to cycle though to the same section on the second and third image and back to the same section on the first image.</p>

<p>I plan to have quite a lot of cells for each image so declaring multiple versions of :</p>

<pre><code>newfocal1 = focal1.get(0, 0, 300, 200);
  image(newfocal1, 0, 0);
</code></pre>

<p>would take ages. I’m coming round to the idea that I will need to create a 2D array for getting the sections. But I am currently a bit confused with how I would link this 2D array to the 2D array of the image I need to get sections of.</p>

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

<p>Elliot.</p>
]]></description>
   </item>
   <item>
      <title>How to make a random image appear without giving a person a seizure?</title>
      <link>https://forum.processing.org/two/discussion/9393/how-to-make-a-random-image-appear-without-giving-a-person-a-seizure</link>
      <pubDate>Thu, 12 Feb 2015 11:15:53 +0000</pubDate>
      <dc:creator>twinpanda2</dc:creator>
      <guid isPermaLink="false">9393@/two/discussions</guid>
      <description><![CDATA[<p>hI, I'm trying to get it so when you move your mouse to a certain area a picture will show up, and in some areas a different image will show up when you move in and out of that specific area. I've been using the random() to get different images, but when I do, and I hover over that specified area, it flashes through all the pictures really fast, fast enough to give someone an epileptic seizure. reducing the frame rate helps, but gives it a jerky visuals. I've used mouseMoved() as well, but again jerky. I could use mousePressed, but I really wanted to have the mouse sort of "hover" in that area to get an image. Here's my code (ignore the fact that no one else has my images). any thoughts? my assignment is due in ....11 hours....but still, I would appreciate any help.``</p>

<pre><code>PFont f;
PImage metro;
PImage [] myboughArray = new PImage [2];
PImage [] mypetalArray = new PImage [2];
PImage [] myapparitionArray = new PImage [3];

PImage petal0;
PImage apparition1;
PImage bough0;
PImage apparition2;
PImage apparition0;
PImage bough1;
PImage petal1;
PImage wetblack;

void setup() {
  size (1000,600);
  //frameRate(50);
  f = loadFont ("TimesNewRomanPS-BoldMT-48.vlw");
  textFont (f, 34);
  metro = loadImage("metro.jpg");
  image (metro, 0,0, width, height);
  petal1 = loadImage("petal1.jpg");
  image (petal1, 0, 0, width, height);
  petal1.resize (1000, 0);
  petal0 = loadImage ("petal0.jpg");
  image (petal0, 0, 0, width, height);
  petal0.resize (1000, 0);
  apparition1 = loadImage("apparition1.jpg");
  image (apparition1, 0,0, width, height);
  apparition1.resize (1000,0);
  bough1 = loadImage("bough1.jpg");
  image(bough1, 0, 0, width, height);
  bough0 = loadImage("bough0.jpg");
  bough0.resize (1000,0);
  apparition2 = loadImage("apparition2.jpg");
  image (apparition2, 0, 0, width, height);
  apparition2.resize (1000,0);
  apparition0 = loadImage ("apparition0.jpg");
  image (apparition0, 0, 0, width, height);
  apparition0.resize (1000, 0);
  wetblack = loadImage ("wet,black.jpg");
  image (wetblack, 0, 0, width, height);
  wetblack.resize (1000,0);
  background (255);

  for (int i=0; i&lt; myboughArray.length; i++){
    myboughArray [i]= loadImage ("bough" +i+ ".jpg");
  }
  for (int k=0; k&lt;mypetalArray.length; k++){
    mypetalArray [k] = loadImage ("petal" +k+".jpg");
  }
  for (int m=0; m&lt;myapparitionArray.length; m++){
    myapparitionArray [m] = loadImage ("apparition" +m+ ".jpg");
  } 

}

void draw() {
  //println(mouseX+ ","+ mouseY);

  if (mouseX&gt;= 50 &amp;&amp; mouseX &lt;= 500 &amp;&amp; 
      mouseY&gt;= 0 &amp;&amp; mouseY&lt;= 350){
      image (metro, 0, 0);
  } else {
    background(255);
  }
  if (mouseX&gt;= 265 &amp;&amp; mouseX &lt;= 335 &amp;&amp; 
      mouseY&gt;= 340 &amp;&amp; mouseY&lt;= 380) {

        image (mypetalArray[(int)random(2)], 0, 0);
      }

  if (mouseX&gt;= 300 &amp;&amp; mouseX &lt;= 440 &amp;&amp; 
      mouseY&gt;= 290 &amp;&amp; mouseY&lt;= 335) {
       //for (int t =0; t&lt;
        image (myapparitionArray[(int)random(3)], 0, 0);
      }
  if (mouseX&gt;= 500 &amp;&amp; mouseX &lt;= 950 &amp;&amp; 
      mouseY&gt;= 300 &amp;&amp; mouseY&lt;= 550){
       image ( bough0,0, 0);
      }
  if (mouseX&gt;= 500 &amp;&amp; mouseX &lt;= 600 &amp;&amp; 
      mouseY&gt;= 340 &amp;&amp; mouseY&lt;= 380) {
       image (myboughArray[(int)random(2)], 0, 0);
      }
  if (mouseX&gt;= 400 &amp;&amp; mouseX &lt;= 500 &amp;&amp;
      mouseY&gt;= 340 &amp;&amp; mouseY &lt;= 380) {
        image (wetblack, 0, 0);
      }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Using PImage to apply color to segments of a torus</title>
      <link>https://forum.processing.org/two/discussion/9368/using-pimage-to-apply-color-to-segments-of-a-torus</link>
      <pubDate>Tue, 10 Feb 2015 17:51:45 +0000</pubDate>
      <dc:creator>rossdickinson</dc:creator>
      <guid isPermaLink="false">9368@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm struggling with figuring out how to do this. I think if I am able to find out the current x,y position of the lines being drawn to the screen and pull the color from the same position of the background image, this should work? My problem is how i go about turning this thought into code! It would be super appreciated if someone was able to give me a hand or point me in the right direction!</p>

<p>Thanks :)</p>

<p>Processing 2.2.1
Windows 8</p>

<pre><code>PImage img;
float r = 100;
float w = 300;
float h = 1;

void setup(){
  img = loadImage("a.png");
  size(558,741); //matches png size
  smooth();
}

void draw(){

  background(230);
    translate(width/2, height/2);
      int torus = 100;
      float arclength = 0;

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

        arclength += w/2;

        float theta = arclength/r;

        pushMatrix();

        translate(r*cos(theta) , r*sin(theta));
        rotate(theta);

        loadPixels();

        // loc = current x,y pos of torus segments (rect)???

       // float c = img.pixels[loc];
       // fill(c);

        noStroke();
        fill(0);
        rectMode(CENTER);
        rect(0,0,w,h);
        popMatrix();

        arclength += w/2;

   }

       if(mousePressed){
        saveFrame("imagetest2.png");
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>PImage / img.resize() unable to scale image up in setup()</title>
      <link>https://forum.processing.org/two/discussion/8904/pimage-img-resize-unable-to-scale-image-up-in-setup</link>
      <pubDate>Tue, 06 Jan 2015 10:26:02 +0000</pubDate>
      <dc:creator>daremes</dc:creator>
      <guid isPermaLink="false">8904@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>it seems that it's not possible to resize loaded image up in setup(). It works perfectly when I want to make image smaller.
And resizing works fine inside draw() when using image(img, x, y, newWidthX, newHeightY) but it's not as good since it has to be resized each frame.
Is there a reason why it shouldn't work and is there any workaround so I don't have to scale my image up all the time?
It's quite useful for Android apps when I don't know target resolution. For example, I'm trying to make an adventure game test app and I want to resize lo-res background image to width/height of HD device...
I'm new to Processing so I'm sorry if it's just some obvious stuff that I missed.</p>

<p>Have a good day,
Martin</p>
]]></description>
   </item>
   <item>
      <title>Crop/Mask 2 of same PImage to fill 50% of screen</title>
      <link>https://forum.processing.org/two/discussion/8048/crop-mask-2-of-same-pimage-to-fill-50-of-screen</link>
      <pubDate>Mon, 10 Nov 2014 10:51:04 +0000</pubDate>
      <dc:creator>WIL993</dc:creator>
      <guid isPermaLink="false">8048@/two/discussions</guid>
      <description><![CDATA[<p>Hi I have an issue which I am trying to find the best way around. I have an image sequence loaded in which plays depending on user input and the image sequence is duplicated in the sketch and rotated. To illustrate what I mean I have included a diagram below of what I am trying to achieve.</p>

<p>I would like to limit each image from filling the other half of the screen so that when the user "zooms" (enlarges) the image it does not overlap onto the other side of the screen. (I do not simply want to limit the zoom amount to the size of the image because I already have this and I need to be able to zoom in further)</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/787/11NX1E58JH0C.jpg" alt="example" title="example" /></p>

<p>The full opacity images are what I have already, the line down the middle simply depicts where I would like to crop/mask the images and the low opacity depicts the zoomed image and highlights the issue in red overlay.</p>

<p>What is the best way to crop/mask the images?
I need to find a method that is the least memory intensive as possible. The image sequences are already causing me issues and forcing me to have loading times when I switch sequence.</p>

<p>Any help is much appreciated! 
Cheers, Will</p>
]]></description>
   </item>
   <item>
      <title>"GUITAR.jpg"image is in data folder for this sketch. Can anyone explain NullPointerException error?</title>
      <link>https://forum.processing.org/two/discussion/6945/guitar-jpg-image-is-in-data-folder-for-this-sketch-can-anyone-explain-nullpointerexception-error</link>
      <pubDate>Fri, 29 Aug 2014 17:22:25 +0000</pubDate>
      <dc:creator>wowww</dc:creator>
      <guid isPermaLink="false">6945@/two/discussions</guid>
      <description><![CDATA[<pre><code>int y=300;
int vertex = 800;
int j=600;
PImage GUITAR;


void setup() {
  size(2200, 1600);
  background(80, 185, 255, 3);
  drawNeighborhood();
  GUITAR = loadImage("data/GUITAR.jpg");
  imageMode(CENTER);
}

void draw() {
  /*drawHouse(400,600);
   drawBlock(600);*/
}

void drawHouse(float x, int y) {
  strokeWeight(1);
  smooth();

  beginShape();
  fill(random(150, 250));
  vertex (x, y-100);
  vertex (x, y+50);//400,450
  vertex (x-300, y+50);
  vertex (x-300, y-100);
  vertex (x-150, y-250);
  vertex (x-90, y-180);
  vertex (x-90, y-220);
  vertex(x-40, y-220);
  vertex(x-40, y-145);//360,355
  vertex(x, y-100);//400,300
  endShape();
  strokeWeight(4);
  line(x-88, y-200, x-42, y-200);
  image(GUITAR, x, y);
}

void drawBlock(int y) {
  int xSpace=250;
  fill(255);



  if (y==300) {
    xSpace=xSpace;
  } else if (y==500) {
    xSpace+=xSpace;
  } else if (y==900) {
    xSpace+=xSpace/2;
  } else {
    xSpace=xSpace-150;
  }
  for (int x=400; x&lt;=2200; x+=xSpace) {
    drawHouse(random(300, x), y);
  }
  fill(random(50, 100));
  strokeWeight(0);
  rect(0, y+50, width, 30);
}

void drawNeighborhood() {

  for (int y=300; y&lt;=1600; y+=200) {

    drawBlock(y);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Error loading a TIFF with PImage</title>
      <link>https://forum.processing.org/two/discussion/6910/error-loading-a-tiff-with-pimage</link>
      <pubDate>Wed, 27 Aug 2014 06:21:30 +0000</pubDate>
      <dc:creator>coolnodje</dc:creator>
      <guid isPermaLink="false">6910@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I get the TIFF_ERROR</p>

<blockquote class="Quote">
  <p>Error: Processing can only read its own TIFF files.</p>
</blockquote>

<p>when trying to loadImage on .tif files.</p>

<p>Is there anything specific to respect or do to be able to load TIFFs?</p>
]]></description>
   </item>
   <item>
      <title>What is the best method for using image sprites in processing?</title>
      <link>https://forum.processing.org/two/discussion/6375/what-is-the-best-method-for-using-image-sprites-in-processing</link>
      <pubDate>Thu, 17 Jul 2014 10:33:57 +0000</pubDate>
      <dc:creator>eddie</dc:creator>
      <guid isPermaLink="false">6375@/two/discussions</guid>
      <description><![CDATA[<p>Just wondering what is the best solution for drawing multiple images on screen in terms of memory usage and performance. I can think of three methods and it would be great to get some feedback on what is generally the best way to do it.</p>

<p>1) load a large image and then cut it into various PImages.<br />
2) Load a large image and crop each time it is displayed within the draw method<br />
3) Load in many images and use them as they are</p>

<p>Personally, I am interested in a case where there are about 100 png images being drawn at a high framerate but any feedback is appreciated. 
thanks</p>
]]></description>
   </item>
   <item>
      <title>Retrieve image colour from display?</title>
      <link>https://forum.processing.org/two/discussion/6371/retrieve-image-colour-from-display</link>
      <pubDate>Thu, 17 Jul 2014 05:59:48 +0000</pubDate>
      <dc:creator>blackhawk</dc:creator>
      <guid isPermaLink="false">6371@/two/discussions</guid>
      <description><![CDATA[<p>I wish to create a small application to tag along my existing software. I need the most prominent colour of the screen/display.</p>

<p><a href="https://www.processing.org/reference/get_.html" target="_blank" rel="nofollow">https://www.processing.org/reference/get_.html</a></p>

<p>What's the best way to go about this? The idea is that the image changes every 30seconds or at a random interval. Is taking a screenshot every 5 seconds, processing it and getting the colour a bit overkill? is there anway to retrieve the colour from the current display on regular intervals?</p>

<p>Any help is appreciated, i'm not even sure this is the right path i should be approaching :)</p>
]]></description>
   </item>
   <item>
      <title>PImage Error</title>
      <link>https://forum.processing.org/two/discussion/5928/pimage-error</link>
      <pubDate>Sat, 21 Jun 2014 08:22:35 +0000</pubDate>
      <dc:creator>Varun_5</dc:creator>
      <guid isPermaLink="false">5928@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I'm sort of new to Processing. I've recreated flappyBird using the android mode for processing.</p>

<p>It runs when I test the device. However, when the bird falls down, processing returns this error:</p>

<pre><code>FATAL EXCEPTION: Animation Thread
Process: processing.test.flappybird, PID: 20383
java.lang.NullPointerException
    at android.graphics.Bitmap.checkPixelsAccess(Bitmap.java:1383)
    at android.graphics.Bitmap.setPixels(Bitmap.java:1445)
    at processing.core.PGraphicsAndroid2D.imageImpl(Unknown Source)
    at processing.core.PGraphics.image(Unknown Source)
    at processing.core.PApplet.image(Unknown Source)
    at processing.test.flappybird.flappyBird.printNum(flappyBird.java:386)
    at processing.test.flappybird.flappyBird.draw(flappyBird.java:234)
    at processing.core.PApplet.handleDraw(Unknown Source)
    at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
    at processing.core.PApplet.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:841)
</code></pre>

<p>I've also attached the flappyBird.pde for people to look at:</p>

<pre><code>import ketai.sensors.*;
//import ddf.minim.*;
import apwidgets.*;
import android.os.Environment;


APMediaPlayer wingSound, hitSound, scoreSound, dieSound;
//Minim minim;
Table tsv;

ArrayList&lt;Stump&gt; stumps;

float stumpMIN=0,stumpMAX=0,stumpDiffY=150,stumpDiffX=250;
int stumpCount=0;
int birdX,score=0,nextStump=0,i,TopScore;
PImage[] imgNumBig,imgNumSmall;

Boolean hit=false,hitSnd=false,stumpHit=false,gameOver=false;
PVector birdPosition,velocity,gravity,up;
PImage[] bird;
PImage background,base,stump,stumpi;
int brd=0,deg=0,baseInc=0;
float BY,BGY;


int scene=0;
PImage imgTitle,imgGetReady;
PImage imageGameOver,imageScoreCard,imageClick,goldScoreCard;
int gameOverPosY,scoreCardPosY;

char ch;

void setup(){
  size(1000,700);
  //topScoreFileLoader();

  wingSound = new APMediaPlayer(this); //create new APMediaPlayer
  wingSound.setMediaFile("wing.mp3"); //set the file (files are in data folder)
  wingSound.start(); //start play back
  wingSound.setLooping(true); //restart playback end reached
  wingSound.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0

  hitSound = new APMediaPlayer(this); //create new APMediaPlayer
  hitSound.setMediaFile("hit.mp3"); //set the file (files are in data folder)
  hitSound.start(); //start play back
  hitSound.setLooping(true); //restart playback end reached
  hitSound.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0

  scoreSound = new APMediaPlayer(this); //create new APMediaPlayer
  scoreSound.setMediaFile("point.mp3"); //set the file (files are in data folder)
  scoreSound.start(); //start play back
  scoreSound.setLooping(true); //restart playback end reached
  scoreSound.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0

  dieSound = new APMediaPlayer(this); //create new APMediaPlayer
  dieSound.setMediaFile("die.mp3"); //set the file (files are in data folder)
  dieSound.start(); //start play back
  dieSound.setLooping(true); //restart playback end reached
  dieSound.setVolume(1.0, 1.0); //Set left and right volumes. Range is from 0.0 to 1.0

  /**
  wingSound = minim.loadSample("wing.mp3",512);
  hitSound = minim.loadSample("hit.mp3",512);
  scoreSound  = minim.loadSample("point.mp3",512);
  dieSound = minim.loadSample("die.mp3",512);
  */
  imgNumBig = new PImage[10];
  imgNumSmall = new PImage[10];
    for(i=0;i&lt;10;i++){
      imgNumBig[i]=loadImage(i+".png");
      imgNumSmall[i]=loadImage(i+".png");
      imgNumSmall[i].resize(13,18);
    }

  tsv = new Table();
  // make the header columns for the table
  tsv.addColumn("High Score");

  bird = new PImage[3];
  bird[0]=loadImage("bird1.png");
  bird[1]=loadImage("bird2.png");
  bird[2]=loadImage("bird3.png");


  base=loadImage("base.png");
  stump=loadImage("stump.png");
  stumpi=loadImage("stumpi.png");

  stumps = new ArrayList&lt;Stump&gt;();
  stumpCount = (int) (width/(stumpDiffX+stump.width));
  stumpCount++;
  stumps.add(new Stump(random(stumpMIN,stumpMAX),0));
  for(int k=1;k&lt;=stumpCount;k++){
    stumps.add(new Stump(random(stumpMIN,stumpMAX),stumpDiffX*k));
  }  
      imgTitle=loadImage("title.png");
    imgGetReady=loadImage("getReady.png");
    imageGameOver=loadImage("gameOver.png");
    imageScoreCard=loadImage("scoreCard.png");
    imageClick=loadImage("click.png");
    goldScoreCard=loadImage("goldScoreCard.png");

 initORreset();

}
void draw(){

 //if(ch=='L'){ lc=1;}
 //if(ch=='R'){ lc=0;}
 if (keyPressed) {
 if(key =='R'|| key =='L')//if(lc==1)
 {
    switch(scene)
  {
    case 0:    //title screen
      scene=1;
      break;
    case 1:   //get ready
      scene=2;
      break;
    case 2:   //game
      if(!stumpHit)
      {
        velocity.add(up);
        wingSound.start();
      }
      break;
    case 3:   //game over
      initORreset();
      scene=1;
      break;
  }
 }
 }

  TableRow row  = tsv.addRow();
  row.setInt("High Score", TopScore);
  drawBackground();
  textSize(35);
  fill(255,100);
  textAlign(CENTER);  

  switch(scene)
  {
    case 0:
    case 1:
             image(base,baseInc,BY);
             if(scene==0)
             {
               image(imgTitle,width/2 - imgTitle.width/2,height/4);
               image(bird[brd/10],width/2 - bird[0].width/2,height/2 + sin(radians(deg)*10)*5 -50);
             }
             else
             {
               image(imgGetReady,width/2 - imgGetReady.width/2,height/4);
               image(bird[brd/10],width/4,height/2 + sin(radians(deg)*10)*5 -50);
               image(imageClick,width/2 - imageClick.width/2,height/3 +50);
             }

             brd+=1;
              deg+=1;
           if(brd&gt;20) brd=0;
           if(deg&gt;360) deg=0;
            break;

    case 2:
      for(int k=0;k&lt;stumps.size();k++){
        Stump st = stumps.get(k);
        st.checkHit();
        if(!stumpHit &amp;&amp; !hit)
        {
          st.checkPassed();
          checkScored();
          st.update();
        }
        else
        {
          gameOver=true;
        }
        st.display();
      }


      image(base,baseInc,BY);
      flyingBird();
      /**
      stroke(0);
      line(0,stumpMIN,width,stumpMIN);
      stroke(#ffffff);
      line(0,stumpMAX,width,stumpMAX);
      */
      if(hitSnd){hitSound.start(); fill(255); for(int z=0;z&lt;100;z++) rect(0,0,width,height); hitSnd=false; if(stumpHit) dieSound.start();}
      printNum(score,width/2,height/6,'b');
      break;
    case 3:
        for(int k=0;k&lt;stumps.size();k++){
          Stump st1 = stumps.get(k);
          st1.display();
        }
        image(base,baseInc,BY);
        translate(birdPosition.x,birdPosition.y);
        rotate(radians(90));
        image(bird[0],-bird[0].width/2,-bird[0].height/2);
        resetMatrix();
        if(gameOverPosY&lt;height/6) gameOverPosY+=5;
        if(scoreCardPosY&gt;height/6 +100) scoreCardPosY-=10;
        image(imageGameOver,width/2 - imageGameOver.width/2,gameOverPosY);
        if(score&gt;TopScore)
        image(goldScoreCard,width/2 - goldScoreCard.width/2,scoreCardPosY);
        else
        image(imageScoreCard,width/2 - imageScoreCard.width/2,scoreCardPosY);
        //print Topscore
        printNum(score&gt;TopScore?score:TopScore,width/2 + 90,scoreCardPosY+75,'s');

        //print score
        printNum(score,width/2 + 90,scoreCardPosY+35,'s');


        break;
  }
}
void mousePressed(){
    switch(scene)
  {
    case 0:    //title screen
      scene=1;
      break;
    case 1:   //get ready
      scene=2;
      break;
    case 2:   //game
      if(!stumpHit)
      {
        velocity.add(up);
        wingSound.start();
      }
      break;
    case 3:   //game over
      initORreset();
      scene=1;
      break;
  }
}

void initORreset()
{
  if(score&gt;TopScore)
  {
    TopScore=score;
    saveFile("high_score_data", tsv);
    //topScoreFileUpdator();
  }
  hit=false;hitSnd=false;stumpHit=false;gameOver=false;
  score=0;nextStump=0;
  birdX=width/4;
  birdPosition = new PVector(birdX,height/2 -50);
  velocity = new PVector(0,0);
  gravity = new PVector(0,0.4);
  up = new PVector(0,-8);
    if((int)random(2)&lt;1){
    background=loadImage("dayCity.png");
  }
  else{
    background=loadImage("nightCity.png"); 
  }
    BGY=-1*(background.height-height+base.height);
  BY=height-base.height;

  stumpMIN = BY/6;
  stumpMAX = BY-stumpDiffY-stumpMIN;
      gameOverPosY=imageGameOver.height*-1;
    scoreCardPosY=height;

 // print(stumps.size());
  for(int k=0;k&lt;stumps.size();k++){
        Stump st2 = stumps.get(k);
        st2.posY=random(stumpMIN,stumpMAX);
        st2.posX=stumpDiffX*k+width;
  }  
}

void saveFile(String name, Table table){

  String directory;

  try{

    directory = new String(Environment
           .getExternalStorageDirectory()
            .getAbsolutePath());
    table.save(new File(directory+"/"+name+".tsv"), "tsv");

    println("File write successful");

  }catch(IOException iox){
    println("Failed to write file: "+iox.getMessage());
  } 
}
</code></pre>

<p>Help would be greatly appreciated.</p>
]]></description>
   </item>
   <item>
      <title>How do I get two PImages to detect each other when they collide?</title>
      <link>https://forum.processing.org/two/discussion/5761/how-do-i-get-two-pimages-to-detect-each-other-when-they-collide</link>
      <pubDate>Thu, 12 Jun 2014 14:23:03 +0000</pubDate>
      <dc:creator>Dubem</dc:creator>
      <guid isPermaLink="false">5761@/two/discussions</guid>
      <description><![CDATA[<pre><code>Here is my code so far

    Slimy[]slimys = new Slimy[35];

    PImage space;
    int x, y;
    PImage happy;
    int i;
    int sx, sy;
    boolean lost = false;

    void setup()
    {
      size(800,600);
      background(250,250,250);
       space = loadImage("space.png");
       imageMode(CENTER);
       happy = loadImage("happy.png");
      x = 50;
      y = 400;
      sx =700;
      sy = 80;
      for(int i = 0; i &lt; slimys.length;i++)
      {
        slimys[i] = new Slimy();
      }

    }

    void draw()
    {
      image(space, width/2, height/2, 
        width, (float(width)/space.width)*space.height);

      image(happy, x, y, 0.2*happy.width, 0.2*happy.height);


    for(int i = 0; i &lt; slimys.length;i++)
      {
        slimys[i].drawSlimy();
      }
    fill(170,50,120);
     ellipse(sx,sy,60,60);

    if(y&gt;600)
    {
      noLoop();
      textSize(40);
      fill(255);
      text("GAME OVER", 310, 370);
    }
    if(x&gt;800)
    {
      noLoop();
      textSize(40);
      fill(255);
      text("GAME OVER", 310, 370);
    }
     if(y&lt;0)
     {
       noLoop();
       textSize(40);
      fill(255);
      text("GAME OVER", 310, 370);
     }
     if(x&lt;0)
     {
       noLoop();
       textSize(40);
      fill(255);
      text("GAME OVER", 310, 370);
     }


    }

    void keyPressed()
    {
      if(key == CODED)
      {
        if(keyCode == UP)
        {
          y -= 10;
        }
        if(keyCode == DOWN)
        {
          y += 10;
        }
        if(keyCode == LEFT)
        {
          x -= 10;
        }
        if(keyCode == RIGHT)
        {
          x += 10;
        }
      }
    }



    class Slimy
    {
      float a, b;

      PImage img;


      Slimy()
      {
         a = random(0, width);
        b = random(0, height);
        img = loadImage("slimy.png");
         imageMode(CENTER);

      }

      void drawSlimy()
      {

        image(img, a, b,0.15*img.width, 0.15*img.height);

        for(int i = 0; i &lt; slimys.length;i++)
      {
        a-= .018;

      }

     if(a&lt;0)
     {
       a = 800;
       a -= .018;
     }
      if(x&gt;200)
      {
        a -= .3;
      }

      if(x&gt;400)
      {
        a -= .6;
      }
      if(x&gt;600)
      {
        a -= 1;
      }
     }
</code></pre>

<p>I'm having trouble getting my program to detect when the PImage "happy" touches the array of PImages "slimy". Do you use getX() and getY()?Also I know it'll probably be easier to make the PImage "happy" have its own class, but the problem is when I create it in a seperate class I have trouble getting its keyPressed() function to work correctly</p>
]]></description>
   </item>
   </channel>
</rss>