Skip to content
Permalink
a99f4625f2
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
50 lines (43 sloc) 1.3 KB
class Menu{
Selector selector;
PShape rectButton, circleButton, neighborButton, rectIcon, circleIcon, neighborIcon;
Menu(){
rectButton = createShape(RECT,0,0,60,25,0,7,7,0);
rectIcon = createShape(RECT,20,15,40,20);
circleButton = createShape(RECT,0,26,60,25,0,7,7,0);
circleIcon = createShape(ELLIPSE,0,52,60,25,0,7,7,0);
neighborButton = createShape(RECT,0,52,60,25,0,7,7,0);
neighborIcon = createShape(RECT,0,52,60,25,0,7,7,0);
selector = new Selector();
}
void activate(int button){
selector.setSelectMode(button);
}
int onaButton(int x, int y){
if( 0<x && x<=60 && y>0 && y<=25){ return 1; }
else if( 0<x && x<=60 && y>25 && y<=51){ return 2; }
else if( 0<x && x<=60 && y>51 && y<=77){ return 3; }
else { return 0; }
}
void draw(){
shape(rectButton);
shape(rectIcon);
shape(circleButton);
shape(circleIcon);
shape(neighborButton);
shape(neighborIcon);
selector.draw();
}
void mousePressed(MouseEvent e){
int button = onaButton(mouseX,mouseY);
if( button != 0 ){ activate(button); }
//else{ selector.startSelection(); }
selector.startSelection();
}
void mouseReleased(MouseEvent e){
selector.resetSelection();
}
void mouseDragged(MouseEvent e){
selector.stretchSelection();
}
}