Created
July 24, 2012 16:29
-
-
Save catupper/3171033 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Image | |
| import ImageDraw | |
| import ImageChops | |
| HEIGHT=500 #0.0-1.0 | |
| WIDTH=1000 #2.0-4.0 | |
| red=(255,0,0) | |
| whtle=(255,255,255) | |
| zahyo = Image.new("RGB",(WIDTH+15,HEIGHT+15),white) | |
| d=ImageDraw.Draw(zahyo) | |
| #座標 | |
| #Y軸 | |
| d.line((15,0)+(15,HEIGHT),fill=red,width=2) | |
| for x in range(10): | |
| d.line((0,HEIGHT*x/10)+(30,HEIGHT*x/10),fill=red,width=1)#横線 | |
| d.text((18,HEIGHT*x/10),str((10.0-x)/10),fill=red)#数字 | |
| #X軸 | |
| d.line((15,HEIGHT)+(WIDTH+15,HEIGHT),fill=red,width=2) | |
| for x in range(1,21): | |
| d.line((15+WIDTH*x/20,HEIGHT-15)+(15+WIDTH*x/20,HEIGHT+15),fill=red,width=1)#縦線 | |
| d.text((18+WIDTH*x/20,HEIGHT-10),str(2.0+x/10.0),fill=red)#数字 | |
| #ロジステック写像のプロット | |
| prot = Image.new("RGB",(WIDTH,HEIGHT),white) | |
| l=prot.load() | |
| def pointjen(a):#写像関数 | |
| x=0.5 | |
| for y in range(1000): | |
| x=a*x*(1-x) | |
| for y in range(5000): | |
| yield x | |
| x=a*x*(1-x) | |
| def min((a,b,c)):#プロットするとちょっと暗くなる | |
| if a==b==c==0: | |
| return (a,b,c) | |
| else: | |
| return (a-5,b-5,c-5) | |
| for x in range(1000): | |
| for y in pointjen(2.0+2.0*x/1000): | |
| l[x,499-int(y*500)]=min(l[x,499-int(y*500)]) | |
| #プロットと座標の合成 | |
| imagez = Image.new("RGB",(WIDTH+30,HEIGHT+30),white) | |
| imagep = Image.new("RGB",(WIDTH+30,HEIGHT+30),white) | |
| imagez.paste(zahyo,(10,10))#(10,10)に座標を貼り付け | |
| imagep.paste(prot,(25,10))#(25,10)にプロットした画像を貼り付け | |
| image = ImageChops.darker(imagez,imagep)#合成 | |
| image.save("logi.bmp","BMP")#保存 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment