I am confused about the "unexpected token: float" error message

Hello everyone, I am attempting to make this code function so it flashes randomly, has a lot of ellipses, squares, a really great sun and when one clicks the mouse, a rainbow appears... its not quite doing that yet and I'm looking for some help... If anyone has some input i'd appreciate it!

Cheers, Lauren

//Randomized & remixed sunglasses on sun sketch
//LaurenBritton, Feb 22nd 2014

//declare variables 

    float r;
    float g;
    float b;

    float locX;
    float locY;

    for (int i = 0; i < rainbowThick; ++i) {
    float ratio = i/rainbowThick;
    float hue = ratio;
    float saturation = 1;
    float brightness = 1;
    float alpha = sin( PI*ratio ) * 1.5 / 2;   
    float cx = width/2;
    float cy = height;
    float rainbowThick = width / 5.0;
    float outerDiam = width * .9;

    PImage paintbrush;

// setup

void setup() {

  // Set the size of the window
size(400,400); 
  //Draw paintbrush
paintbrush=loadImage("paint_brush.gif");
}

void mousePressed() {
  colorMode(HSB, 1);
  noFill();                 \ 
    stroke( hue, saturation, brightness, alpha );
    arc(cx, cy, outerDiam-i, outerDiam-i, PI, PI*2);
    arc(mouseX,mouseY,16,16);
}

void draw () {

//initialize variables
r=random(200);
g=random(210);
b=random(200);

//make background color random
background(r,g,b);
ellipseMode(CENTER);
rectMode(CORNER);
stroke(0);

//box size
size(100, 100);

//other box size
size (450,450);

//Paintbrush instructions
imageMode(CENTER);
image(paintbrush,mouseX,mouseY);

//sun
stroke(238, 242, 15);
fill (#F2850F);
ellipse(50,50,50,50);

//shades
stroke(0);
fill(0);
arc(38, 40, 25, 25, 0, PI, CHORD);
arc(63, 40, 25, 25, 0, PI, CHORD);

fill(255);
arc(50, 60, 25, 25, 0, PI, CHORD);

//windows
fill(#F2E6E6);

rect( 350,100,10,20);
rect( 350,250,10,20);
rect( 350,200,10,20);
rect( 350,150,10,20);

rect( 390,100,10,20);
rect( 390,250,10,20);
rect( 390,200,10,20);
rect( 390,150,10,20);

rect( 310,100,10,20);
rect( 310,250,10,20);
rect( 310,200,10,20);
rect( 310,150,10,20);

rect( 300,100,10,20);
rect( 300,250,10,20);
rect( 300,200,10,20);
rect( 300,150,10,20);

rect( 210,100,10,20);
rect( 210,250,10,20);
rect( 210,200,10,20);
rect( 210,150,10,20);

rect( 309,100,10,20);
rect( 309,250,10,20);
rect( 309,200,10,20);
rect( 309,150,10,20);

rect( 350,100,10,20);
rect( 350,250,10,20);
rect( 350,200,10,20);
rect( 350,150,10,20);

rect( 200,100,10,20);
rect( 200,250,10,20);
rect( 200,200,10,20);
rect( 200,150,10,20);

rect( 10,100,10,20);
rect( 10,250,10,20);
rect( 10,200,10,20);
rect( 10,150,10,20);

rect( 15,100,10,20);
rect( 15,250,10,20);
rect( 15,200,10,20);
rect( 15,150,10,20);

rect( 70,100,10,20);
rect( 70,250,10,20);
rect( 70,200,10,20);
rect( 70,150,10,20);

ellipse( 30,100,100,20);
ellipse( 90,140,90,30);
ellipse( 60,180,80,40);
ellipse( 120,200,70,50);
ellipse( 150,220,60,60);
ellipse( 170,240,50,70);
ellipse( 200,260,40,80);
ellipse( 230,280,30,90);
ellipse( 260,300,20,100);
ellipse( 290,320,10,110);
ellipse( 310,340,0,120);

ellipse( 40,110,110,30);
ellipse( 100,150,100,40);
ellipse( 70,190,90,50);
ellipse( 130,210,80,60);
ellipse( 160,230,70,70);
ellipse( 180,250,60,80);
ellipse( 210,270,50,90);
ellipse( 240,290,40,100);
ellipse( 270,310,30,110);
ellipse( 300,330,20,120);
ellipse( 320,350,10,130);

ellipse( 60,130,130,60);
ellipse( 130,170,130,60);
ellipse( 100,220,110,80);
ellipse( 160,240,110,90);
ellipse( 190,260,100,100);
ellipse( 210,280,90,110);
ellipse( 240,300,80,110);
ellipse( 270,310,70,130);
ellipse( 310,340,60,140);
ellipse( 330,360,50,160);
ellipse( 350,380,40,160);

}

Answers

  • _vk_vk
    edited February 2014

    If anyone has some input

    please format your code, both in PDE (command T) and in the forum (ctr K) :)

  • edited February 2014

    The line for (int i = 0; i < rainbowThick; ++i) { should not be in the global declarations.

    You should not use rainbowThick before it is defined.

    There is also a stray \ in the setup().

Sign In or Register to comment.