Processingのおさらい(第3問)

ステップ2

おさらいの応用でカラーピッカーを作ってみました。ウィンドウ内をマウスでなぞると背景色が変わり、中央にRGB値が表示されます。クリックすると色の変化が止まり、またクリックすると変化が再開します。気に入った色が出来たらメモして教えてね!

isActive = True

def setup():
    size(256,256)
    font = createFont("MisakiGothic", 8, False)
    textFont(font)
    textSize(40)
    textAlign(CENTER)
    
def draw():
    global isActive
    
    if isActive:
        background(255, mouseX, mouseY)
        fill(255)
        text("255," + str(mouseX) + "," + str(mouseY), width / 2, height /2)
        
    if mousePressed:
        isActive = not isActive
        delay(100)
    

コメントする