用python画一个宝马标志

用python画一个宝马标志,不过字母BMW没画上去。执行下面程序就能在当前目录下生成一个foo.bpm的图片。
点击下载.pbm图片

#!/usr/bin/env python
import sys
import random
m=[[0 for x in range(512)] for y in range(512)]

for i in range(512):
for j in range(512):
p=(256-i)*(256-i)+(256-j)*(256-j)-10000
if ((i==256 or j==256) and p<0) or (p0)) or (p>0 and p<10000):
m[i][j]=1
f=file(‘foo.pbm’,’w’)
sys.stdout=f
print”P1n512 512″
for i in range(512):
for j in range(512):
print m[i][j],
print
f.close()

3 thoughts on “用python画一个宝马标志

  1. pbm – 便携式的数位映象的文件格式(P1) – 1 位每映像点
    pgm – 便携式的graymap 文件格式(P2) – 8 位每映像点
    ppm – 便携式的pixmap 文件格式(P3) – 24 位每映像点, 8为红色, 8 为绿色, 8为蓝色

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.