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


Python Img类代码示例

本文整理汇总了Python中Img的典型用法代码示例。如果您正苦于以下问题:Python Img类的具体用法?Python Img怎么用?Python Img使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, edit, level=None):
     self.edit = edit
     self.playerdead = False
     self.done = False
     self.level = level
     self.exitcode="NORMAL"
     if edit:
         self.t = []
         self.o = []
         for _ in range(20):
             self.t.append([0] * 20)
             self.o.append([0] * 20)
         self.e = []
     else:
         self.e = []
         self.ps=[]
         if level=="sav":
             savfile = open(Img.np("lvls//save.sav"), "r")
         elif len(level)==2:
             savfile = open(Img.np("lvls//%s-%s.sav" % tuple(level)), "r")
         else:
             savfile = open(Img.np("lvls//%s-%s-%s.sav" % tuple(level)), "r")
         self.t = []
         self.o = []
         self.fx = []
         self.bfx = []
         if level[0]==3 and level[1]!=8:
             for _ in range(randint(50,60)):
                 self.bfx.append(FX.Star(randint(0,638),randint(0,638)))
         savr = savfile.readlines()
         self.fltext = savr[0][:-1]
         del savr[0]
         for row in savr[:20]:
             self.t.append([int(s) for s in row.split()])
         for x, row in enumerate(savr[20:]):
             self.o.append([None] * 20)
             crow = [int(s) for s in row.split()]
             for y, n in enumerate(crow):
                 if n:
                     eo = self.eoconvert(n)
                     if eo[1] == "obj":
                         self.o[x][y] = eo[0](x, y)
                     elif eo[1] == "ent":
                         self.e.append(eo[0](x, y))
                     elif eo[1] == "spawn":
                         self.ps.append(eo[0](x, y))
                         self.e.append(self.ps[-1])
                         self.akey=self.ps[-1].akey
                     elif eo[1] == "gravblock":
                         self.e.append(Entities.SokoBlokGrav(x,y,eo[0]))
         if level[1]==8:
             try:
                 self.boss=Bosses.bosses[level[0]-1](9,9)
                 if level[0]==6:
                     self.o[9][9]=self.boss
                 else:
                     self.e.append(self.boss)
             except IndexError:
                 pass
         savfile.close()
开发者ID:NoNotCar,项目名称:BombAdventures,代码行数:60,代码来源:World.py

示例2: run

 def run(self,screen,player):
     screen.fill((255,255,255))
     Img.bcentre(Img.bfont,"WIN",screen)
     pygame.display.flip()
     pygame.time.wait(1000)
     if not self.p:
         sys.exit()
开发者ID:Nouranium,项目名称:Monolith,代码行数:7,代码来源:GUI.py

示例3: die

def die(screen):
    pygame.display.flip()
    pygame.time.wait(1000)
    screen.fill((0, 0, 0))
    Img.bcentre(Img.bfont, "FOOL", screen, col=(255, 255, 255))
    pygame.display.flip()
    pygame.time.wait(1000)
开发者ID:NoNotCar,项目名称:orbital,代码行数:7,代码来源:Coop.py

示例4: f1

def f1():
  import pgm
  #imgarray,w,h = pgm.pgmread('histo_inp_image.pgm')
  #imgarray,w,h = pgm.pgmread('histo_ref_image.pgm')
  #imgarray,w,h = pgm.pgmread('histo_inp_image2.pgm')
  #imgarray,w,h = pgm.pgmread('histo_ref_image2.pgm')
  imgarray,w,h = pgm.pgmread('lena.pgm')
  #imgarray,w,h = pgm.pgmread('fourier_transform.pgm')
  imgs = Img.Img(imgarray)
  imgt = imgs.add_salt_pepper(0.65)
  imgt1 = imgt.median_filter(np.ones((3,3)))
  imgt1 = imgt1.median_filter(np.ones((5,5)))
  #imgt1 = imgt.median_filter(np.ones((7,7)))
  #imgt1 = imgt.median_filter(np.array([[2,2,2],[2,1,2],[2,2,2]]))
  k = Img.create_gauss_kernel(Img.find_gauss_support(0.75), 0.75)
  imgt2 = imgt.conv(k)
  plot_fig(imgs.pix, 'Original image')
  plot_fig(imgt.pix, 'Added salt and pepper noise')
  plot_fig(imgt1.pix, 'Median filtered image')
  plot_fig(imgt2.pix, 'Gaussian LP filtered image')
  #plot_hist(imgs, 'Original image')
  #plot_hist(imgt, 'Added salt and pepper noise')
  #plot_hist(imgt1, 'Median filtered image')
  #plot_hist(imgt2, 'Gaussian LP filtered image')
  print np.sum((imgs.pix - imgt1.pix)**2)
开发者ID:apvijay,项目名称:image_proc,代码行数:25,代码来源:assign8.py

示例5: update

 def update(self, events):
     """Update Everything"""
     if not pygame.mixer.music.get_busy():
         Img.musply(choice(self.music), 1)
     for n in range(self.tran[0]):
         if not randint(0, self.tran[1]):
             rx = randint(0, self.size[0] - 1)
             ry = randint(0, self.size[1] - 1)
             terrlist[self.terr[rx][ry]].ranupdate(self, rx, ry)
     for ent in self.ents:
         ent.update(self, events)
         ent.mupdate(self, events)
     self.anitick += 1
     if self.anitick == 56:
         self.anitick = 0
         self.map = self.make_map()
     for row in self.objs:
         for obj in row:
             if obj and obj.updatable:
                 obj.update(self)
     if self.player.psupply > 0:
         for pst in self.player.pstorage:
             self.player.psupply -= pst.give_power(self, self.player.psupply)
             if self.player.psupply == 0:
                 break
开发者ID:NoNotCar,项目名称:monolith,代码行数:25,代码来源:World.py

示例6: test

def test():
    download_image("http://jwxt.bupt.edu.cn/validateCodeAction.do?random=",name="hello")
    image=Img(fname="hello.jpg")
    image.binary()
    images=image.divide()

    vcodes=[]
    for temp in images:
        vcodes.append(temp.recognise())
    vcode_result=''.join(vcodes)
    print(vcode_result)
开发者ID:Ncerzzk,项目名称:image-recognise,代码行数:11,代码来源:imgtest.py

示例7: Instruct

def Instruct(instructions, time):
    words = instructions.split()
    text = ""
    for i in range(len(words)):
        pygame.event.pump()
        if i:
            text += " "
        text += words[i]
        screen.fill((255, 255, 255))
        Img.bcentre(Img.dfont, text, screen, col=(0, 0, 0))
        pygame.display.flip()
        pygame.time.wait(time)
开发者ID:NoNotCar,项目名称:orbital,代码行数:12,代码来源:multi.py

示例8: SendPic

def SendPic(command):
    global commands
    messagelist = []
    if command.user in log:
        userhist = log[command.user]
        messagelist.append(userhist[-2][1])
        messagelist.append(userhist[-1][0])
        messagelist.append(userhist[-1][1])
    else:
        messagelist.append("Play the game first!!!")

    image = Img.gen(messagelist)

    try:
        image.save("123.png")
    except IOError:
        print("cannot convert")

    try:
        api.update_with_media(filename = "123.png", status = "Here is a highlight from @" + command.user)
        del commands[0] #remove command from queue. happens after posting, so if there is an error it stays in
        print('POSTED pic to ' + command.user)
        f = open("last.txt", "w")
        f.write(str(command.id))
        f.close()

        #do not update the log when posting a highlight. only keeps track of actual game commands.

    except tweepy.TweepError as e:
        print "Error trying to post status: " + str(e.reason)
开发者ID:dimmondslice,项目名称:ModMUD_TwitterGame,代码行数:30,代码来源:bot1.py

示例9: __init__

 def __init__(self,level,hs):
     self.electric=not level[0]%2
     if self.electric:
         self.ttgo=5460
     self.objects=[[None]*self.size[1] for _ in range(self.size[0])]
     lfile=open(Img.np("levels//%s-%s.sav" % tuple(level)))
     llines=lfile.readlines()
     del llines[0]
     for x,row in enumerate(llines):
         for y,n in enumerate(row.split()):
             if n!="0":
                 obj=n.split(":")
                 for c in editorclasses:
                     if c.symb==obj[0]:
                         newobj=c(int(obj[1]))
                         newobj.fixed=True
                         self.objects[x][y]=newobj
                         if obj[0]=="S":
                             self.fx=x
                             self.fy=y
                             self.nd=D.get_dir(int(obj[1]))
     self.hs=hs
     self.new_pipe()
     self.level=level
     self.nhs=False
开发者ID:NoNotCar,项目名称:OpenPipes,代码行数:25,代码来源:World.py

示例10: __init__

 def __init__(self, level, players,controllers):
     self.done = False
     self.level = level
     self.exitcode="NORMAL"
     self.e = []
     self.ps=[]
     savfile = open(Img.np("lvls//battle//"+level), "r")
     self.t = []
     self.o = []
     self.fx = []
     self.bfx = []
     pn=0
     savr = savfile.readlines()
     for row in savr[:20]:
         self.t.append([int(s) for s in row.split()])
     for x, row in enumerate(savr[20:]):
         self.o.append([None] * 20)
         crow = [int(s) for s in row.split()]
         for y, n in enumerate(crow):
             if n:
                 eo = self.eoconvert(n)
                 if eo[1] == "obj":
                     self.o[x][y] = eo[0](x, y)
                 elif eo[1] == "ent":
                     self.e.append(eo[0](x, y))
                 elif eo[1] == "spawn":
                     self.ps.append(self.pconv[players[pn]](x, y, controllers[pn]))
                     self.e.append(self.ps[-1])
                     pn+=1
     savfile.close()
开发者ID:NoNotCar,项目名称:BombAdventures,代码行数:30,代码来源:BattleWorld.py

示例11: __init__

 def __init__(self, x, y,owner, fent):
     self.x = x
     self.y = y
     self.owner=owner
     self.ent=fent
     simg=pygame.transform.scale(self.ent.img,(16,16))
     self.img.blit(simg,(4,8))
     self.img.blit(Img.imgret("Tutorial\Psign.png"),(16,8))
开发者ID:Nouranium,项目名称:Monolith,代码行数:8,代码来源:Tutorial.py

示例12: __init__

 def __init__(self, x, y, rgb):
     self.x = x
     self.y = y
     self.ileft = 10
     self.rgb = rgb
     self.img = Img.imgret("GoldBlock.png")
     pygame.draw.rect(self.img, rgb, pygame.Rect(4, 4, 8, 8))
     self.img = pygame.transform.scale2x(self.img)
开发者ID:NoNotCar,项目名称:monolith,代码行数:8,代码来源:RGB.py

示例13: win

 def win(self,screen):
     success.play()
     screen.fill((255,255,255))
     Img.bcentre(bfont,"YAY",screen)
     if self.score>self.hs:
         self.nhs=True
         Img.bcentre(tfont,"NEW HIGH SCORE: "+str(self.score),screen,100,(0,255,0))
     else:
         Img.bcentre(tfont,"SCORE: "+str(self.score),screen,100)
         Img.bcentre(tfont,"HIGH SCORE: "+str(self.hs),screen,200)
     pygame.display.flip()
     pygame.time.wait(2000)
     self.done="success"
开发者ID:NoNotCar,项目名称:OpenPipes,代码行数:13,代码来源:World.py

示例14: f1

def f1():
  """ Convolves image and kernel """
  (imgarr,w,h) = pgm.pgmread('cameraman.pgm')
  imgs = Img.Img(imgarr)
  k1 = Img.create_gauss_kernel(Img.find_gauss_support(0.8))
  k2 = Img.create_gauss_kernel(Img.find_gauss_support(1.2))
  k3 = Img.create_gauss_kernel(Img.find_gauss_support(1.6))
  imgt1 = imgs.conv(k1)
  imgt2 = imgs.conv(k2)
  imgt3 = imgs.conv(k3)
#  print imgt1.col, imgt1.row
#  print imgt2.col, imgt2.row
#  print imgt3.col, imgt3.row
  plt.figure(1)
  plt.imshow(imgs.pix, cmap=cm.gray)
  plt.title('Original image')
  plt.figure(2)
  plt.imshow(imgt1.pix, cmap=cm.gray)
  plt.title('Img convolved with Gaussian kernel' + str(shape(k1)))
  plt.figure(3)
  plt.imshow(imgt2.pix, cmap=cm.gray)
  plt.title('Img convolved with Gaussian kernel' + str(shape(k2)))
  plt.figure(4)
  plt.imshow(imgt3.pix, cmap=cm.gray)
  plt.title('Img convolved with Gaussian kernel' + str(shape(k3)))
  plt.show()
开发者ID:apvijay,项目名称:image_proc,代码行数:26,代码来源:assign2.py

示例15: render

 def render(self,p,screen):
     screenrect=screen.get_rect()
     sh,sw=screenrect.h,screenrect.w
     awscale=scales[self.wscale]
     aiscale=scales[self.invscale]
     riscale=self.invscale+1
     m=(sw/float(awscale)+1)/2.0
     rm=int(ceil(m))
     wconvmult=awscale/64.0
     if not (p.shop or (p.dead and not p.dt)):
         asx=p.x*awscale+ir(p.xoff)*wconvmult-(m-1)*awscale
         asy=p.y*awscale+ir(p.yoff)*wconvmult-(m-1)*awscale-aiscale
         r=(p.rumbling-1)//10+1
         rx=randint(-r,r)
         ry=randint(-r,r)
         sx=p.x
         sy=p.y
         for y in range(sy-rm-1,sy+rm+1):
             for x in range(sx-rm-1,sx+rm+1):
                 screen.blit(Tiles.tiles[self.get_t(x,y)].get_img()[self.wscale],(x*awscale-asx+rx,y*awscale-asy+ry))
         for y in range(sy-rm-1,sy+rm+1):
             for x in range(sx-rm-1,sx+rm+1):
                 objs=self.get_os(x,y)
                 for o in objs:
                     if not o.is_hidden(self,p):
                         screen.blit(o.get_img(self)[self.wscale],(x*awscale+ir(o.xoff)*wconvmult-asx+rx,y*awscale+ir(o.yoff)*wconvmult-asy-o.o3d*(self.wscale+1)+ry))
         pygame.draw.rect(screen,(200,200,200),pygame.Rect(0,0,sw,aiscale))
         for n,i in enumerate(p.iinv.inv if p.iinv else p.inv):
             screen.blit(i.get_img(p,self)[self.invscale],(n*aiscale,0))
             if i.stack>1:
                 screen.blit(numerals[i.stack-2][self.invscale],(n*aiscale+(11 if i.stack<10 else 9)*(self.invscale+1),36))
             if n==p.isel:
                 pygame.draw.rect(screen,p.col,pygame.Rect(n*aiscale,15*riscale,aiscale,riscale))
         if p.statuseffects:
             maxt=max([se[1] for se in p.statuseffects])
             maxse=[se for se in p.statuseffects if se[1]==maxt][0]
             pygame.draw.rect(screen,p.col,pygame.Rect(0,sh-9,maxt*sw//Players.etimes[maxse[0]],12))
     elif p.shop:
         screen.fill((150,150,150))
         pygame.draw.rect(screen,(200,200,200),pygame.Rect(0,0,sw,64))
         Img.bcentrex(bcfont,p.shop.title,screen,-16)
         for n,i in enumerate(p.shop.items):
             Img.cxblit(i[0].img[self.invscale],screen,n*aiscale+aiscale,-8*riscale)
             Img.bcentrex(cashfont,str(i[1]),screen,n*aiscale+aiscale,(255,255,0),8*riscale)
         screen.blit(p.simg[self.invscale],(0,p.ssel*aiscale+aiscale))
     else:
         p.dead.render(screen)
     Img.bcentrex(cashfont,str(p.cash),screen,sh-48,(255,255,0))
     pygame.draw.rect(screen,p.col,pygame.Rect(0,0,sw,sh),2)
开发者ID:NoNotCar,项目名称:TrapDungeon,代码行数:49,代码来源:World.py


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