python绘制网格线在原图上面_图像上使用JES(python)的白色网格线
是的,令人驚訝的是,addLine(picture, startX, startY, endX, endY)只能畫黑線!?在
所以讓我們用手來做。下面是一個非常基本的實現(xiàn):def drawGrid(picture, color):
w = getWidth(picture)
h = getHeight(picture)
printNow(str(w) + " x " + str(h))
w_offset = 20 # Vertical lines offset
h_offset = 10 # Horizontal lines offset
# Starting at 1 to avoid drawing on the border
for y in range(1, h):
for x in range(1, w):
# Here is the trick: we draw only
# every offset (% = modulus operator)
if (x % w_offset == 0) or (y % h_offset == 0):
px = getPixel(picture, x, y)
setColor(px, color)
file = pickAFile()
picture = makePicture(file)
# Change the color here
color = makeColor(255, 255, 255) # This is white
drawGrid(picture, color)
show(picture)
注意:使用函數(shù)drawLine()可以更有效地實現(xiàn)這一點,該函數(shù)來自給定的腳本here。
輸出:
……….
………
。。。。。。。在
總結(jié)
以上是生活随笔為你收集整理的python绘制网格线在原图上面_图像上使用JES(python)的白色网格线的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nolo手柄配对不上_用NOLOHOME
- 下一篇: php 基于gbk和 Ascii把汉字转