We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › unexpected symbol ignored
Page Index Toggle Pages: 1
unexpected symbol ignored (Read 560 times)
unexpected symbol ignored
Sep 17th, 2007, 10:16am
 
hi
i need major help
trying to do a research topic (see earlier questions) and was given this code;
PImage myImage;
void setup(){
   size(200,200);
   myImage = loadImage("myImage.gif");
   // drag image into processing text-window then it
   // will be copied to <sketch-path>/data/myImage.jpg
}
void draw()
{
   myImage.loadPixels(); // not sure this is needed
   for ( int x = 0; x< myImage.width; x++ )
   {
       for ( int y = 0; y < myImage.height; y++ )
       {
           int i = y * myImage.width + x;
           
           if ( myImage.pixels[i] == color(0) ) {
               // black
               ellipse(x,y,10,10);
           }
           else
           {
               // white
           }
       }
   }
}
to try and help
when trying to adapt it so i could load my own image, make it two colours etc i get unexpected symbol ignored as part of this code;
 int i = (y * polarfleece.width + x);
the whole code i am trying to put in is below;
void setup () {
size (600,600);
polarfleece = loadImage ("polarfleece.JPG");
image(polarfleece, 0, 0);
filter(GRAY);
filter(POSTERIZE, 2);
}
 void draw ();
{
 polarfleece.loadPixels ();
for (int x = 0; x< polarfleece.width; x++)

 for (int y=0; y< polarfleece.height; y++)

  int i = (y * polarfleece.width + x);
}
  if (polarfleece.pixels [i] == color(0) ) {
    ellipse (x,y,40,40) ;
  }
  else
  {
    if (polarfleece.pixels [i] == color(1) ) {
    }


i am trying to get processing to identify a black / white pixel and if the pixel is black place a drawing there (in the above case an eclipse)

hope someone can help me
thanks
Re: unexpected symbol ignored
Reply #1 - Sep 17th, 2007, 12:48pm
 
a little less chaotic formatting would have helped you find the missing / wrongly placed curly braces ...

Code:

void setup () {
size (600,600);
polarfleece = loadImage ("polarfleece.JPG");
image(polarfleece, 0, 0);
filter(GRAY);
filter(POSTERIZE, 2);
}

void draw ();
{
polarfleece.loadPixels ();
for (int x = 0; x< polarfleece.width; x++)
{
for (int y=0; y< polarfleece.height; y++)
{
int i = (y * polarfleece.width + x);
if (polarfleece.pixels [i] == color(0) ) {
ellipse (x,y,40,40) ;
}
else if (polarfleece.pixels [i] == color(1) ) {
}
}
}
}
Page Index Toggle Pages: 1