Search code examples
processing

How to draw semi-transparent arrow in processing.exe


How may I draw a semi-transparent arrow in processing.exe such that each arrow is uniform in color when on a plain background?

This https://processing.org/discourse/beta/num_1219607845.html fails - it shows deeper colour where the shaft and head overlap.


Solution

  • You can use the beginShape() function along with the vertex() function to draw any shape you want, including arrows.

    Here's an example from the reference:

    beginShape();
    vertex(20, 20);
    vertex(40, 20);
    vertex(40, 40);
    vertex(60, 40);
    vertex(60, 60);
    vertex(20, 60);
    endShape(CLOSE);
    


    (source: processing.org)

    You'll have to figure out the points you need to draw in order to create an arrow, but you can't do it using lines, since they're going to overlap.

    Alternatively you might consider creating an image of the arrow and drawing the image instead.