Processing java mode make a nice menu (buttons with THE GIMP)

preview_player
Показать описание
In this video i show you how to make a part of menu with images (created with THE GIMP) (the code really starts at 7 min 13 secondes)
Рекомендации по теме
Комментарии
Автор

PImage blue_button, red_button;
String [] my_menus = {"File", "Edit", "Sketch", "Debug", "Tools", "Help"};
int N_MENUS = my_menus.length;
int posi_cursor = 0;
int button_width = 150;
int button_height = 50;
int [] button_x1, button_y1, button_x2, button_y2;
void settings() {
size(displayWidth, displayHeight, P3D);
}
void setup() {
button_x1 = new int[N_MENUS];
button_y1 = new int[N_MENUS];
button_x2 = new int[N_MENUS];
button_y2 = new int[N_MENUS];
red_button = loadImage("red_button.png");
blue_button = loadImage("blue_button.png");
int x1 = 0;
int padding = 20;
for (int i = 0; i < N_MENUS; i++) {
button_x1[i] = 30 + x1;
button_y1[i] = 50;
button_x2[i] = button_x1[i] + button_width;
button_y2[i] = button_y1[i] + button_height;
x1 += button_width + padding;
}
}
void draw() {
background(100, 50, 200);
display_the_menus();
}
void mouseMoved() {
for (int i = 0; i < N_MENUS; i++) {
if (mouseX > button_x1[i] && mouseX < button_x2[i] &&
mouseY > button_y1[i] && mouseY < button_y2[i]) {
posi_cursor = i;
}
}
}
void display_the_menus() {
fill(255);
textSize(32);
for (int i = 0; i < N_MENUS; i++) {
PImage my_image = (posi_cursor == i) ? red_button : blue_button;
image(my_image, button_x1[i], button_y1[i] );
int x1 = (button_width - (int)textWidth(my_menus[i]) ) / 2;
text(my_menus[i], button_x1[i] + x1, 35 + button_y1[i] );
}
}

coprocessingcoprocessing
visit shbcf.ru