hey guys, just a quick question...how to place a text inside a button ?
Quote:int [] data = new int[361];
int selected = 1;
PFont font;
PImage a;
void setup(){
size(650,650);
font = loadFont("Aparajita-20.vlw");
a = loadImage("Erase.png");
}
void draw(){
background(255);
textFont(font, 20);
// Draw the tiles.
for(int i=0; i < 19; i++){
for(int j=0; j < 19; j++){
drawTile(i,j);
}
}
// Draw the buttons.
stroke(0);
fill(255, 255, 255);
if( selected == 1){
fill(0);
}
image (a, 30, 580);
fill(255);
rect(20, 610, 40, 40 );
fill(47, 19, 235);
if( selected == 2){
fill(100,255,100);
}
rect(60, 610, 40, 40 );
fill(158,158,160);
if( selected == 0){
fill(100,255,100);
}
rect(100, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(140, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(180, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(220, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(260, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(300, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(340, 610, 40, 40 );
fill(255, 255, 255);
if( selected == 0){
fill(100,255,100);
}
rect(380, 610, 40, 40 );
}
void drawTile(int i, int j){
drawBlank(i,j);
if( data[i+3*j] == 1 ){
drawCross(i,j);
}
if( data[i+3*j] == 2 ){
drawCircle(i,j);
}
}
void drawBlank(int i, int j){
stroke(0);
fill(200,255,200);
rect(30+30*i,30+30*j,30,30);
}
void drawCross(int i, int j){
noStroke();
fill(0,0,255);
rect(-10,-30,20,60);
rect(-30,-10,60,20);
}
void drawCircle(int i, int j){
noStroke();
fill(255,0,0);
ellipse(70+80*i,70+80*j, 60, 60 );
fill(200,255,200);
ellipse(70+80*i,70+80*j, 40, 40 );
}
the text "erase" should be placed in the first button as shown in picture in my first post