当前位置: 首页>>代码示例>>Python>>正文


Python Draw.point方法代码示例

本文整理汇总了Python中PIL.ImageDraw.Draw.point方法的典型用法代码示例。如果您正苦于以下问题:Python Draw.point方法的具体用法?Python Draw.point怎么用?Python Draw.point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PIL.ImageDraw.Draw的用法示例。


在下文中一共展示了Draw.point方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mapdraw

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
def mapdraw(args,colorbar):
   img = Image.new('RGB',(args['xlen'],args['ylen']),'white')
   draw = Draw(img)

   for key,value in args['datamap'].iteritems():
      draw.point(value,getrgb(str(key)))

   img2 = img.resize((args['y'],args['y']), Image.BILINEAR)

   imgclr = colorbar.resize((args['colorbar'],img2.size[1]), Image.BILINEAR)

   # ===== ENTIRE IMAGE CREATION W/ TEXT=====
   imgbox = Image.new('RGB',((300+args['y']+args['colorbar']),(img2.size[1]+200)),args['background'])
   imgbox.paste(img2,(100,100))
   imgbox.paste(imgclr,((200+img2.size[0]),100))

   drawbox = Draw(imgbox)
   title = args['title']
   titlesize = 50 # future user input
   font = truetype("/library/fonts/Arial.ttf",titlesize)
   smfontsize = 30 # future user input
   smfont = truetype("/library/fonts/Arial.ttf",smfontsize)
   titlewidth = font.getsize(title)[0]
   drawbox.text(((imgbox.size[0]/2 - titlewidth/2), titlesize/2),title,(0,0,0),font=font)

   drawbox.text(((imgbox.size[0] - 95),100),str(args['max']),(0,0,0),font=smfont)
   drawbox.text(((imgbox.size[0] - 95),(100 + img2.size[1] - smfontsize)),str(args['min']),(0,0,0),font=smfont)

   imgbox.show()
   if 'title' in args:
      title = args['title']+'_'+str(args['min'])+'_'+str(args['max'])+'.png'
   else:
      title = 'output_'+str(args['min'])+'_'+str(args['max'])+'.png'
   imgbox.save(args['save']+'/'+title)
开发者ID:jmclinn,项目名称:CSC453-Project,代码行数:36,代码来源:mapdraw.py

示例2: point

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
 def point(self, patterns, color='black'):
     hasher = md5()
     draw = Draw(self.image)
     for y, pattern in enumerate(patterns):
         pattern_data = pattern.pattern_data
         hasher.update(pattern_data)
         points = [
             (x, y)
             for x, dot in enumerate(_to_bit(pattern_data)) if dot == '1'
         ]
         draw.point(points, color)
     self.hash = hasher.hexdigest()
开发者ID:sretent,项目名称:ariblib,代码行数:14,代码来源:drcs.py

示例3: colormap

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import point [as 别名]
def colormap(args):
   rangelen = args['max'] - args['min']
   rangemid = args['min'] + (rangelen / 2)
   rangemax = args['max']
   rangemin = args['min']
   
   cr2 = rgb2hex.linear_gradient(args['colors'][1],args['colors'][2],(int(rangelen/2*1000))+1)['hex']
   cr1 = rgb2hex.linear_gradient(args['colors'][0],args['colors'][1],(int(rangelen/2*1000))+1)['hex']
   dictlist = {}

   # === PAIR DATA WITH COLOR MAP ===
   for y,sl in enumerate(args['data']): # for each sublist within dataset (row)
      for x,i in enumerate(sl): # for each point in sublist (column)
         val = args['colors'][1]
         #top half of data range
         if i > rangemid:
            if i <= rangemax:
               val = cr2[int((i - (rangemin + rangelen/2)) * 1000)]
            else:
               val = args['colors'][2]
         #bottom half of data range
         elif i < rangemid:
            if i >= rangemin:
               val = cr1[int((i - rangemin) * 1000)]
            else:
               val = args['colors'][0] 
         # mask
         if 'mask' in args:
            if i <= args['mask'][0]:
               val = args['mask'][1]
         # add to dict
         if val in dictlist:
            dictlist[val].append((x,y))
         else:
            dictlist[val] = [(x,y)]
            
   args['datamap'] = dictlist

   # ===== COLORBAR CREATION =====
   clr = (cr1 + cr2)
   clr = clr[::-1000]
   widthclr = args['colorbar']
   heightclr = len(clr)

   imgclr = Image.new("RGB",(widthclr,heightclr),"white")
   drawclr = Draw(imgclr)

   for y,val in enumerate(clr):
      for x in range(widthclr):
         drawclr.point((x,y),getrgb(str(val)))
   
   return args, imgclr
开发者ID:jmclinn,项目名称:CSC453-Project,代码行数:54,代码来源:mapdraw.py


注:本文中的PIL.ImageDraw.Draw.point方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。