最近、Pythonの勉強を始めました。
今はProcessingの本の内容をPythonで再現してしたりしています。
覚えたり、作ったコードをブログに載せると振り返りやすいし、忘備録にもなる。
ということで、このブログにコードを載せる方法を探してみました。
code-prettifyがいいと思って調べて組み込んでみたのですが、しっくりきませんでした。
どうしようかと悩んでいる時に、Gistの存在を思い出しました。
使い方が簡単なので、とりあえずGistを使おうと思います。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(): | |
size(1200,600) | |
colorMode(HSB,360,100,100,100) | |
noFill() | |
global tileCount,w,strokeWe | |
tileCount=30 | |
w=20 | |
strokeWe=3 | |
def draw(): | |
background(100,0,100,100) | |
# randomSeed | |
randomSeed(0) | |
translate(tileCount/2,tileCount/2) | |
# ellipse | |
stroke(200,100,100,30) | |
for y in range(height/tileCount): | |
for x in range(width/tileCount): | |
strokeWe=map(mouseY,0,width,1,10) | |
strokeWeight(strokeWe) | |
w=map(mouseY,0,width,3,60) | |
posX=x*tileCount | |
posY=y*tileCount | |
shiftX=random(-mouseX,mouseX)/20 | |
shiftY=random(-mouseX,mouseX)/20 | |
ellipse(posX+shiftX,posY+shiftY,w,w) |
コードに色が付かないです。
JavaScriptで試したら問題なかったのですが、Pythonではダメでした。
なんでだろう?
わかったらここに追記します。