stderr
YaBB Newbies
Offline
Posts: 6
Re: split float-numbers
Reply #4 - Apr 1st , 2007, 5:20pm
Thanks fry,
but now i use another methode to split/convert ...
nf() ... see code below
Code: void setup() { size(300, 300); background(64); noLoop(); } void draw() { stroke(128); noFill(); arc(150,150,250,250,0,360); arc(150,150,200,200,0,360); arc(150,150,150,150,0,360); arc(150,150,100,100,0,360); arc(150,150,50,50,0,360); stroke(255); line(150,25,150,275); line(25,150,275,150); String XPOSF1 = "-0.050"; String YPOSF1 = "+0.050"; float xpos = float(XPOSF1); float ypos = float(YPOSF1); if ( xpos < 0 && ypos < 0) { // PosX im Minus und PosY im Minus String posx_string = nf(xpos,1,3); String posy_string = nf(ypos,1,3); int posx_string_splitted[] = int(split(posx_string, ',')); int posy_string_splitted[] = int(split(posy_string, ',')); int coordinate_x = 150-posx_string_splitted[1]; int coordinate_y = 150+posy_string_splitted[1]; draw_point(coordinate_x, coordinate_y); } if (xpos > 0 && ypos < 0) { // PosX im Plus und PosY im Minus String posx_string = nf(xpos,1,3); String posy_string = nf(ypos,1,3); int posx_string_splitted[] = int(split(posx_string, ',')); int posy_string_splitted[] = int(split(posy_string, ',')); int coordinate_x = 150+posx_string_splitted[1]; int coordinate_y = 150+posy_string_splitted[1]; draw_point(coordinate_x, coordinate_y); } if ( xpos > 0 && ypos > 0) { // PosX im Plus und YPos im Plus String posx_string = nf(xpos,1,3); String posy_string = nf(ypos,1,3); int posx_string_splitted[] = int(split(posx_string, ',')); int posy_string_splitted[] = int(split(posy_string, ',')); int coordinate_x = 150+posx_string_splitted[1]; int coordinate_y = 150-posy_string_splitted[1]; draw_point(coordinate_x, coordinate_y); } if (xpos < 0 && ypos > 0) { // PosX im Minus und YPos im Plus String posx_string = nf(xpos,1,3); String posy_string = nf(ypos,1,3); int posx_string_splitted[] = int(split(posx_string, ',')); int posy_string_splitted[] = int(split(posy_string, ',')); int coordinate_x = 150-posx_string_splitted[1]; int coordinate_y = 150-posy_string_splitted[1]; draw_point(coordinate_x, coordinate_y); } } void draw_point(int xloc, int yloc) { stroke(255,0,0); fill(255,0,0); arc(xloc, yloc,7,7,0,360); }