how rotate a controlP5.Button
in
Contributed Library Questions
•
5 months ago
i want to rotate the controlP5.Button b but it didn't work,
hope someone could help me
- import controlP5.*;
- ControlP5 controlP5;
- controlP5.Button b;
- Textarea myTextarea;
- ControllerSprite sprite;
- void setup() {
- size(1000,1000);
- smooth();
- controlP5 = new ControlP5(this);
- sprite = new ControllerSprite(controlP5,loadImage("flowers.jpg"),132,180);
- b = controlP5.addButton("image",100,20,40,100,100);
- b.setSprite(sprite);
- fill(0);
- noStroke();
- myTextarea = controlP5.addTextarea("txt")
- .setPosition(200,20)
- .setSize(200,200)
- .setFont(createFont("arial",12))
- .setLineHeight(14)
- .setColor(color(128))
- .setColorBackground(color(255,100))
- .setVisible(true)
- .setColorForeground(color(255,100));
- ;
- myTextarea.setText("Lorem Ipsum is simply dummy text of the printing and typesetting"
- +" industry. Lorem Ipsum has been the industry's standard dummy text"
- +" ever since the 1500s, when an unknown printer took a galley of type"
- +" and scrambled it to make a type specimen book. It has survived not"
- +" only five centuries, but also the leap into electronic typesetting,"
- +" remaining essentially unchanged. It was popularised in the 1960s"
- +" with the release of Letraset sheets containing Lorem Ipsum passages,"
- +" and more recently with desktop publishing software like Aldus"
- +" PageMaker including versions of Lorem Ipsum."
- );
- }
- void draw() {
- background(0); // black background
- pushMatrix();
- translate(width/2, height/2);
- rotate(PI/2);
- fill(255);rect(200,40, 80, 50, 15, 15);
- //b.setPosition(400,300) ; //in this part i tried to rotate the button but it didn't work
- if(controlP5.isMouseOver(controlP5.getController("image"))){
- myTextarea.setVisible(true);
- }
- else{myTextarea.setVisible(false);}
- popMatrix();
- }
- void controlEvent(ControlEvent theEvent) {
- if(theEvent.isController()) {
- print("control event from : "+theEvent.controller().name());
- println(", value : "+theEvent.controller().value());
- }
- }
1