Using Image files for hotspots?

edited August 14 in Python Mode

I just finished making a very basic player with processing. It works fine using mimin but I was wondering how someone would work with a ellipse instead of a rectangle as far as hotspots work? How about using an image instead that isn't a rectangle? Here is my code below using rectangle, but I would have loved to use a triangle for a play button and the two "i's" for the pause button, but I wanted to have them hotspotted, if that makes sense.

    global sf
    size(200, 200)
    background(255) # white
    minim=Minim(this)
    sf=minim.loadFile("Sleep Away.mp3")
    textSize(28)

def draw():
    print(str(mouseX) + " : " + str(mouseY))

    global x1, y1, x2, y2
    # setting up PLAY button with text and rectangle
    fill(255,0,255)
    text("PLAY", 10, 40)
    fill(0,0,155)
    rect(x1,y1,50, 60)

    # setting up PAUSE button with text and rectangle
    fill(255,0,255)
    text("PAUSE", 100, 40)
    fill(123,0,155)
    rect(x2,y2,50, 60)

    #creating a change of colour when hovering over the play button
    if (mouseX>20) and (mouseX <70) and (mouseY > 50) and (mouseY < 110):
           fill(0,155,45)
           rect(x1,y1,50, 60)
           if (mousePressed == True):
               sf.play()
    elif (mouseX>120) and (mouseX<170) and (mouseY>50) and (mouseY<110):
           fill(13,90,90)
           rect(x2,y2,50, 60)
           if (mousePressed == True):
               sf.pause()

Answers

Sign In or Register to comment.