Greeking-project - need triangles on different positions to point to my mouse

Hi! For a school project I need to realize a creative greeking-project.
Therefore I’ve got a template which I have to use, that includes different symbol-systems. I have to use it as the base of my project.

Just to give you a rough overview on what I have to do, the specific task is the following:

“Use processing to create a graphically impressive INTERACTIVE INTERPRETATION OF SYMBOLS. Develop a rule-based representation that artistically renders the character-arrays read in live. You might want to focus on the form of the single placeholders or emphasize their synergy/connections. As one can be distracted by meaningful content, “greeking” unimportant text forces the viewer to focus on layout and design.
In addition, either appropriate interaction via mouse/keyboard should be possible for the user, or a time-based change shall be implemented - or both.”

Now on to my specific problem:

I decided that I want a small triangle to be built on each position where there randomly displays an ‘e’, when running the system. That I got.

I also want these triangles not to be static, but to always have their tips pointing to where my mouse is.
I know (or at least I think) that I have to use atan2 to get there.
So I already managed my triangles to interact with my mouse in a certain way by using atan2. BUT I’m not able to get the top tips pointing at the mouse.

This is the code I got at the moment:

float siz = my_xs[1] - my_xs[0];
  
  background( 135, 124, 255 );                                       
  textAlign( CENTER, CENTER );                                          
  for( int i=0; i<my_chars.length; i++ ) {
    stroke( 0 );                                                        
    fill( 0 );
    textSize( siz/2 );
    text( my_chars[i], my_xs[i], my_ys[i] );
    
  
    if( my_chars[i]=='e' ) {                                              
      fill (232, 220, 202);                                               
      stroke (232, 220, 202);                                             
      
      float triangleHeight = siz; 
      float triangleBase = siz/2; 
      
      float triangleTopX = my_xs[i]; 
      float triangleTopY = my_ys[i] - siz/2; 
      //float triangleLeftX = triangleTopX - triangleBase/2;  //not used at the moment
      //float triangleRightX = triangleTopX + triangleBase/2;   //not used at the moment
      //float triangleBottomY = triangleTopY + triangleHeight;  //not used at the moment
 
      float angle = atan2(mouseY - triangleTopY, mouseX - triangleTopX);
      
      pushMatrix();
      translate(triangleTopX, triangleTopX); 
      rotate(angle);                                                          
      triangle(-triangleBase / 2, 0, 0, -triangleHeight, triangleBase / 2, 0); 
      popMatrix();
    }
  }

I’d also prefer my triangles not to be sitting that high above my 'e’s, but I think this happens because of the translation and is definitly not my main problem here.

Thank you!

1 Like