Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Button{
- public int x, y, w, h;
- public float rectFill;
- public float rectFillR, rectFillG, rectFillB;
- public int textSize;
- public int textFillR, textFillG, textFillB;
- public String text;
- private float swap;
- private float[] swap2 = {0, 0, 0};
- private int checkThingy = 0;
- private int checkThingy2 = 0;
- private int type;
- public Button(){
- }
- public Button(int x, int y, int w, int h, float rectFill, int textFillR, int textFillG, int textFillB, String text, int textSize ){
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.rectFill = rectFill;
- this.swap = rectFill;
- this.textFillR = textFillR;
- this.textFillG = textFillG;
- this.textFillB = textFillB;
- this.text = text;
- this.textSize = textSize;
- this.type = 1;
- }
- public Button(int x, int y, int w, int h, float rectFillR, float rectFillG, float rectFillB, int textFillR, int textFillG, int textFillB, String text, int textSize ){
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- this.rectFill = rectFill;
- this.swap = rectFill;
- this.textFillR = textFillR;
- this.textFillG = textFillG;
- this.textFillB = textFillB;
- this.text = text;
- this.textSize = textSize;
- this.rectFillR = rectFillR; swap2[0] = rectFillR;
- this.rectFillG = rectFillG; swap2[1] = rectFillG;
- this.rectFillB = rectFillB; swap2[2] = rectFillB;
- this.type = 2;
- }
- public void render(){
- if( this.type == 1 ){
- fill(rectFill);
- rect(x, y, w, h);
- textSize(32);
- fill(textFillR, textFillG, textFillB);
- text(text, x + x, y + 30);
- }else if ( this.type == 2 ) {
- fill(rectFillR, rectFillG, rectFillB, 255);
- rect(x, y, w, h);
- textSize(32);
- fill(textFillR, textFillG, textFillB);
- text(text, x + x, y + 30);
- }
- }
- public void render2(){
- render();
- }
- public void click(){
- if ( this.type == 1 ){
- this.rectFill = this.rectFill + 100;
- }else if ( this.type == 2 ){
- this.rectFillR = this.rectFillR + 100;
- this.rectFillG = this.rectFillG + 100;
- this.rectFillB = this.rectFillB + 100;
- }
- }
- public void highLight(float value){
- if ( checkThingy == 0 ) {
- swap = this.rectFill;
- checkThingy = 1;
- }
- this.rectFill = value;
- }
- public void deHighLight(){
- this.rectFill = swap;
- }
- public void highLight2(float r, float g, float b){
- if ( checkThingy2 == 0 ) {
- swap2[0] = this.rectFillR;
- swap2[1] = this.rectFillG;
- swap2[2] = this.rectFillB;
- checkThingy2 = 1;
- }
- this.rectFillR = r;
- this.rectFillG = g;
- this.rectFillB = b;
- }
- public void deHighLight2(){
- this.rectFillR = swap2[0];
- this.rectFillG = swap2[1];
- this.rectFillB = swap2[2];
- }
- public boolean isMosueInside(){
- if ( mouseX > this.getX() && mouseX <= this.getW() + 10 && mouseY > this.getY() && mouseY - this.getY() <= this.getH() + 10 ){
- //println("Inside");
- return true;
- }
- //println("not Inside");
- return false;
- }
- public void setX(int x){
- this.x = x;
- }
- public void setY(int y){
- this.y = y;
- }
- public void setW(int w){
- this.w = w;
- }
- public void setH(int h){
- this.h = h;
- }
- public void setText(String text){
- this.text = text;
- }
- public void setTextSize(int size){
- this.textSize = size;
- }
- public void setRectFill(float rectFill){
- this.rectFill = rectFill;
- }
- public void setTextFill(int textFillR, int textFillG, int textFillB){
- this.textFillR = textFillR;
- this.textFillG = textFillG;
- this.textFillB = textFillB;
- }
- public int getX(){
- return this.x;
- }
- public int getY(){
- return this.y;
- }
- public int getW(){
- return this.w;
- }
- public int getH(){
- return this.h;
- }
- public String getText(){
- return this.text;
- }
- public float getRectFill(){
- return this.rectFill;
- }
- public float getRectFillR(){
- return this.rectFillR;
- }
- public float getRectFillG(){
- return this.rectFillG;
- }
- public float getRectFillB(){
- return this.rectFillB;
- }
- public int getTextSize(){
- return this.textSize;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement