Changing alignment on bang from cp5

Hi all,

I’m using a bang from the cp5 library as a button. Is there a way to make the given coordinates the center of the button, similar to the imageMode(CENTER) for images? I’ve looked through the cp5 library and I can’t find a method that does this.


Not sure if it is possible as controlP5 is an external library and imageMode is a nice feature of Processing. You can always make a request in the controlP5 github but not sure how much support this library is receiving at the moment.

As a temporal solution, you could create a generic function where you can convert from corner-to-center OR center-to-corner. This transformations are generic and required three pieces of information: corner pos, center pos and length/dimension of the object. If you post a simple sketch, I could try to implement the idea, if you think that could help you with your sketches.


Okay I see. I figured out a way around it but thank you so much for offering!!

Could I ask what it was that you figured out?

I didn’t actually find a way to make the coordinates the center. All I wanted to do was center the buttons so I just made the x position width/2-(cp5.get(Bang.class, "Start").getWidth())/2 which is definitely not the best solution but it worked. Eventually I might make a function similar to the one @kfrajer suggested but for now, this will do.

1 Like