rrrr
YaBB Newbies
Offline
Posts: 41
Re: map locations
Reply #6 - Mar 9th , 2009, 5:42pm
ok, here is a modified version. i'm not sure if the rest of my code works because i can't get past the error "syntax error, maybe a missing ] character?" where my "byte [832800] neighborhoodKey; " code is. isn't this the way it reads it? //finding coordinate points on map and write out to a txt file int num_hoods = 37; //37 neighborhoods String [] hoodsNames = { "SOMA / south beach", "USF / panhandle", "alamo square / nopa", "bayview", "bernal heights", "castro / upper market", "cole valley / ashbury hts", "downtown / civic / van ness", "excelsior / outer mission", "financial district", "glen park", "haight ashbury", "hayes valley", "ingleside / SFSU / CCSF", "inner richmond", "inner sunset / UCSF", "laurel hts / presidio", "lower haight", "lower nob hill", "lower pac hts", "marina / cow hollow", "mission district", "nob hill", "noe valley", "north beach / telegraph hill", "pacific heights", "portola district", "potrero hill", "richmond / seacliff", "russian hill", "sunset / parkside", "tenderloin", "treasure island", "twin peaks / diamond hts", "visitacion valley", "west portal / forest hill", "western addition" }; color [] colorValues = { #ccae62, #d4c9ae, #452525, #f25f22, #288b43, #a2d5aa, #796227, #f04b23, #f0d123, #9a8d42, #ead76e, #9e2382, #ffeb8d, #3e50a2, #3d58a7, #ad1f23, #d64499, #754d4d, #8f7bb8, #a7d48c, #a3509f, #ed2089, #d0dd2e, #6dcbd9, #d96da5, #6db4d9, #f9f293, #74c162, #f3b386, #2c2c7b, #dee21e, #4dc5d5, #b2d459, #849a72, #cb3d1c, #692d1f, #ffc600 }; //color pink = color(255, 102, 204); //example of structure color [] colorIndex = new color[num_hoods]; //colors array, placing color values to color/neighborhood //loadPixels(); //byte [number of pixels] neighborhoodKey; //size of screen: 1200 x 694 = 832800 byte [832800] neighborhoodKey; PImage sfmap; void setup(){ size(1200, 694); background(0); sfmap = loadImage("sf-map.png"); //sfmap.loadPixels(); //get individual pixels color loadPixels(); //get access to manipulate the onscreen pixels through "pixels[int] = color //for(int i = 0; i < sfmap.pixels.length; i++){ for(int i = 0; i < pixels.length; i++){ //pixels[i] = pink; //each 832,800 bytes = each pixel, which is assigned to a neighborhood # between 0-37 neighborhoodkey[i] = convertColorToNeighborhood(pixels[i]); //assigns each pixel to a hood. pixels are of the color datatype! } //writing out all the entire array of bytes to file. data is saved in binary format saveBytes ("positions.txt", neighborhoodKey); } //convertColorToNeighborhood is a function that returns an int between 0 & 37 void convertColorToNeighborhood(int i){ for (i=0; i<num_hoods.length; i++){ colorValues[i] = hoodsNames[i]; } }