0
私はそれを押すと、描画に使うことができるランダムな色を生成するボタンを作る必要があります。私はいくつかの他のランダムなカラージェネレータを見てきましたが、それを実装する方法はわかりません。ここまでは私のコードです。私のコードにランダムな色のボタンを実装する
from processing import *
tool = "paintbrush"
tool = "shapechanger"
red_color = 0
green_color = 0
blue_color = 0
def setup():
size(400,400)
draw_red_button()
def draw_red_button():
set_red()
fill(red_color, green_color, blue_color)
rect(0, 380, 20, 20)
def red_button_pressed():
if mouse.pressed and (mouse.x>0 and
mouse.x<20 and
mouse.y>380 and
mouse.y<400):
return True
else:
return False
def draw():
if red_button_pressed():
set_red()
else:
fill(red_color, green_color, blue_color)
paint()
stroke(red_color, green_color, blue_color)
def paint():
if mouse.pressed:
ellipse(mouse.x, mouse.y, 20,20)
def set_red():
global red_color
global green_color
global blue_color
red_color = 255
green_color = 0
blue_color = 0
run()
助けを求める場合は、必要最小限の例を投稿してください。 1ダースではなく1つのカラーボタンしかないと問題は変わりますか?もしそうでなければ、なぜあなたはほぼ同じ機能定義のダースを読ませてくれるのですか? – DyZ
私はちょうどそれを小さくした –