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


Python Draw.rectangle方法代码示例

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


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

示例1: drawclock

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import rectangle [as 别名]
def drawclock(fontpath,fontsize,fgcolor,bgcolor,style,case,drawLEDs=False):
    # init font
    scaledfontsize = pt2pxy(fontsize)
    font = ImageFont.truetype(size=scaledfontsize,filename=fontpath)
    lines = decodeLetters(style,case)

    img = Image.new("RGBA", (pt2pxx(WIDTH), pt2pxy(HEIGHT)))
    draw = Draw(img)
    draw.rectangle(((0,0), (pt2pxx(WIDTH),pt2pxy(HEIGHT))), fill=bgcolor)

    for h in corner_holes:
        drawhole(draw,h,fgcolor)

    if drawLEDs:
        drawleds(draw,led_xs,led_ys,fgcolor)
    
    drawletters(draw,lines,font,case,led_xs,led_ys,fgcolor)

    del draw
    return img
开发者ID:rupello,项目名称:ClockTHREEjr,代码行数:22,代码来源:clockface.py

示例2: get_frame

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import rectangle [as 别名]
    def get_frame(self, n, im_width, im_height):
        """Return a single frame as a PIL Image.

        Arguments:
        n         -- the frame index
        im_width  -- the width of the Image to return
        im_height -- the height of the Image to return

        """
        offset, length, duration = self.frames[n]
        tiles = self.tiles[offset:offset + length]

        # Create new blank image
        img = PILImage.new('RGBA', (im_width, im_height))
        draw = PILDraw(img)
        draw.rectangle(((0, 0), (im_width, im_height)), fill=self.bg)

        src = self.get_processed_image()

        # Blit tiles
        for tile in tiles:
            x, y, u, v = tile
            # Fix edge repeat by overlapping tiles 1px
            x *= self.tile_w - 1
            y *= self.tile_h - 1
            if x > 0:
                x += 1
            if y > 0:
                y += 1
            # Crop tile
            u *= self.tile_w
            v *= self.tile_h
            box = (u, v, u + self.tile_w, v + self.tile_h)
            part = src.crop(box)
            # Paste onto frame
            box = (x, y, x + self.tile_w, y + self.tile_h)
            img.paste(part, box)
        return img
开发者ID:Met48,项目名称:SGTools,代码行数:40,代码来源:SGTools.py

示例3: Draw

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import rectangle [as 别名]
((16, 8), (18, 8)),
((8, 9), (18, 9)),
((11, 12), (18, 12)),
((11, 13), (18, 13)),
((8, 16), (18, 16)),
((3, 19), (8, 19)),
((3, 23), (8, 22)),
]

# <codecell>

from PIL import Image
from PIL.ImageDraw import Draw
img = Image.new("RGBA", (100, 100))
draw = Draw(img)
draw.rectangle(((0,0), (100, 100)), fill=(255, 100, 0))
draw.rectangle((50,80,100,200), fill=0)
# img.save("foo.png")
imshow(numpy.asarray(img))

# <codecell>

given_image_size = (600, 900)
image_min_dimen = min(given_image_size)
image_center = (given_image_size[0] / 2, given_image_size[1] / 2)

from PIL import Image
from PIL.ImageDraw import Draw
from math import sin, cos, radians
import random
img = Image.new("RGBA", given_image_size)
开发者ID:jeroyang,项目名称:microscopy,代码行数:33,代码来源:Untitled0.py

示例4: display_pil_image

# 需要导入模块: from PIL.ImageDraw import Draw [as 别名]
# 或者: from PIL.ImageDraw.Draw import rectangle [as 别名]

def display_pil_image(im):
   """Displayhook function for PIL Images, rendered as PNG."""

   b = BytesIO()
   im.save(b, format='png')
   data = b.getvalue()

   ip_img = display.Image(data=data, format='png', embed=True)
   return ip_img._repr_png_()


# register display func with PNG formatter:
png_formatter = get_ipython().display_formatter.formatters['image/png']
dpi = png_formatter.for_type(Image.Image, display_pil_image)

# <codecell>

from PIL import Image
from PIL.ImageDraw import Draw
img = Image.new("RGBA", (100, 100))
draw = Draw(img)
draw.rectangle(((0,0), (100, 100)), fill=(255, 100, 0))
# img.save("foo.png")
imshow(img)

# <codecell>


开发者ID:josiahseaman,项目名称:DNAResearch,代码行数:29,代码来源:Notebook_Experimentation.py


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