Code Mon Apr 13
Started code for PImageButton Child Class
Summary:
This code has 3 tabs, the PImageButton tab will have errors
Make sure to grab the image from the PImageButton page and put in a data folder in your project
Main tab shows logic to display a PImage as a test that the image file is loaded correctly.
Fixed errors in the Button class that caused colors not to display correctly
Added logic in Button class to display the text: label
Main Tab
//Main Tab
//Make objects, objects call methods
//Make an object instance
Button btn1;//declare the variable as global - btn is null
void setup(){
size( 600, 600);
colorMode(HSB, 360, 100, 100);
PImage img1 = loadImage( "pattern1Btn.png");
image( img1, 100, 100); //test to make sure you can display image
// Button( float x, float y, float w, float h, String label )
btn1 = new Button( 20, 20, 100, 100, "Hello"); //initialize
}
void draw( ){
btn1.display();
}
void mouseClicked( ){
btn1.clicked( mouseX, mouseY);
}Last updated
Was this helpful?