python draw-squares.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python draw-squares.py相关的知识,希望对你有一定的参考价值。

j = 0 # vertical counter
k = 0 # horizontal counter
for i,v in enumerate(convert()):
        if i % squares_per_row == 0 and i != 0: # if i is a multiple of squares per row
            j += 1 # increments after the squares per row is hit like 0,0,0,1,1,1,2,2,2...
        if i % squares_per_row == 0 and i != 0:
            k = 0 # increments after the squares per row is hit like 0,1,2,0,1,2...
        points = ((k*s,j*s), (k*s, j*s+s),(k*s+s,j*s+s),(k*s+s, j*s)) #set points with incrementing values :/
        draw.polygon((points[0], points[1], points[2], points[3]), outline='black',  fill = (v[0],v[1],v[2])) # outline='red', fill='blue'
        #borders so redraw the same plots with white lines
        draw.line((points[0], points[1], points[2], points[3], points[0]),  fill="white", width=border_width) # outline='red', fill='blue'
        k += 1
    im.save('square.jpg') # save the image.

以上是关于python draw-squares.py的主要内容,如果未能解决你的问题,请参考以下文章

001--python全栈--基础知识--python安装

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python