2013-11-14 5 views

답변

2

견적 :

from PIL import Image, ImageDraw 
import math 

x1 = 100 
y1 = 100 
x2 = 200 
y2 = 175 

# thickness of line 
thick = 4 

# compute angle 
a = math.atan((y2-y1)/(x2-x1)) 
sin = math.sin(a) 
cos = math.cos(a) 
xdelta = sin * thick/2.0 
ydelta = cos * thick/2.0 
xx1 = x1 - xdelta 
yy1 = y1 + ydelta 
xx2 = x1 + xdelta 
yy2 = y1 - ydelta 
xx3 = x2 + xdelta 
yy3 = y2 - ydelta 
xx4 = x2 - xdelta 
yy4 = y2 + ydelta 
draw.polygon((xx1, yy1, xx2, yy2, xx3, yy3, xx4, yy4)) 

다음은이 기술의 결과입니다. 다이얼을 구성하는 세그먼트는 각각 "굵은 선"기술을 사용하여 그려집니다. 편집

dial.png

:

http://gimpforums.com/thread-how-to-draw-this-geometric-pattern-programmatically

:
이 (또한 내가 쓴 전체 스크립트를 포함) 파이썬에서 "굵은 선"기능에 대한 내 검색을 시작한 토론이다
관련 문제