• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python transform.rotate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: _get_raw_shadow

 def _get_raw_shadow(self):
     target_img = self.target.get_image(self.capture_state)
     r = target_img.get_rect()
     #the shadow will be larger in order to make free space for fadeout.
     r.inflate_ip(2*self.shadow_radius, 2*self.shadow_radius)
     img = Surface(r.size)
     img.fill((255, 255, 255, 255))
     img.blit(target_img, (self.shadow_radius, self.shadow_radius))
     if self.sun_angle <= 0.:
         raise Exception("Sun angle must be greater than zero.")
     elif self.sun_angle != 45. and self.vertical:
         w, h = img.get_size()
         new_h = h / tan(self.sun_angle * pi / 180.)
         screen_size = functions.get_screen().get_size()
         new_h = abs(int(min(new_h, max(screen_size))))
         img = scale(img, (w, new_h))
     if self.angle_mode == "flip":
         img = flip(img, self.mode_value[0], self.mode_value[1])
     elif self.angle_mode == "rotate":
         img = rotate(img, self.mode_value)
     else:
         raise Exception("angle_mode not available: " + str(self.angle_mode))
     shadow = pilgraphics.get_shadow(img,
                                     radius=self.shadow_radius,
                                     black=self.black,
                                     alpha_factor=self.alpha_factor,
                                     decay_mode=self.decay_mode,
                                     color=self.color)
     return shadow
开发者ID:YannThorimbert,项目名称:ThorPy-1.0,代码行数:29,代码来源:_shadow.py


示例2: shortAttack

    def shortAttack(self):
        self.attacking = True
        if self.game.Player.player_face == 'front':
            # I do not know why this vector needs to be 0 while the others are like, 1
            self.directional_attack_image = rotate(self.attack_image, 180)
            self.sub_vector = [0, 0]
        elif self.game.Player.player_face == 'left':
            self.directional_attack_image = rotate(self.attack_image, 90)
            self.sub_vector = [-1, 0]
        elif self.game.Player.player_face == 'back':
            self.directional_attack_image = rotate(self.attack_image, 0)
            self.sub_vector = [0, -1]
        elif self.game.Player.player_face == 'right':
            self.directional_attack_image = rotate(self.attack_image, 270)
            self.sub_vector = [0.8, 0] # editing this seems to change the speed of the right dagger swing a bit

        self.game.Player.can_move = False
        self.receding = False
        self.potent = True
        self.weapon_rect = Rect(1, 1, 1, 1)
        p_coords = [self.game.Player.player_r.x, self.game.Player.player_r.y]
        a_coords = [p_coords[0] + self.game.Player.getRigging()[0], p_coords[1] + self.game.Player.getRigging()[1]]
        if self.game.Player.player_face == 'right' or self.game.Player.player_face == 'left':
            a_coords = [a_coords[0] - self.attack_image.get_height(), a_coords[1] - self.attack_image.get_width()]
        self.blit_pos = a_coords
        self.attack_ticks = self.range
开发者ID:ajay05,项目名称:Necromonster,代码行数:26,代码来源:equipment.py


示例3: __init__

    def __init__(self, radius, angle):
        'Init'
        if angle < 0:
            angle = -angle
        if angle > 180:
            angle = angle % 180
        diameter = radius * 2
        if (diameter, angle) in Portion.portions:
            self.surface = Portion.portions[(diameter, angle)]
            return

        # We need to build the portion, let's start with a circle.
        circ = pygame.Surface((diameter, diameter))
        pygame.draw.circle(circ, COLOR2, (radius, radius), radius, 0)

        # Cut the circle in half by drawing it halfway of another surface.
        circ.fill(BLACK, (0, 0, diameter, radius))

        # Rotate the semicircle.
        circ = rotate(circ, 180 - angle)

        # Cut the same half again (just readjust based on circ's size).
        circ.fill(BLACK, (0, 0, circ.get_width(), circ.get_height() / 2))

        # Reposition the angle (halp up and half down) by rotating halfway.
        circ = rotate(circ, angle / 2)

        # Re-center after rotation because image get's bigger after that.
        self.surface = pygame.Surface((diameter, diameter))
        blit_centered(self.surface, circ)
        Portion.portions[(diameter, angle)] = self.surface
开发者ID:kstenger,项目名称:proto-ninja,代码行数:31,代码来源:monster.py


示例4: _rotate

 def _rotate(self):
     #angle = 90 if self.rotation == 'vertical' else 0
     angle = 0
     pos = (self.rect.x, self.rect.y)
     self.image = transform.rotate(self.image, angle)
     self.msf = transform.rotate(self.msf, angle)
     self.rect = self.image.get_rect()
     self.rect.x, self.rect.y = pos
     self._update_mask()
开发者ID:nullicorn,项目名称:scwordcloudapp,代码行数:9,代码来源:word.py


示例5: generate_resource_dct

 def generate_resource_dct(self):
     """Genrerate animations with rotations and flipping."""
     dct = {Dir.NONE: None}
     # Raw
     diag_image = self.resource.image.get(self.diag_name)
     perp_image = self.resource.image.get(self.perp_name)
     # Rotate
     for r in range(4):
         dct[self.perp_dir[r]] = transform.rotate(perp_image, 90*r)
         dct[self.diag_dir[r]] = transform.rotate(diag_image, 90*r)
     # Opacify
     for image in dct.values():
         if image:
             opacify_ip(image, self.opacity)
     # Return
     return dct
开发者ID:YoannQDQ,项目名称:pyweek-dojo,代码行数:16,代码来源:view.py


示例6: __init__

 def __init__(self, tag, initial_position, rotation=0, fontname=DEFAULT_FONT, fontzoom=5):
     Sprite.__init__(self)
     self.tag = copy(tag)
     self.rotation = rotation
     
     font_spec = load_font(fontname)
     
     #fonter = font.Font(os.path.join(FONT_DIR, font_spec['ttf']), int(tag['size'] * fontzoom)).render(tag['tag'], True, tag['color'])
     # changing to allow for arbitrary local fonts
     fonter = font.Font(font_spec['ttf'], int(tag['size'] * fontzoom)).render(tag['tag'], True, tag['color'])
     self.tag['size'] *= fontzoom
     fonter = transform.rotate(fonter, rotation)
     frect = fonter.get_bounding_rect()
     frect.x = -frect.x
     frect.y = -frect.y
     self.fontoffset = (-frect.x, -frect.y)
     font_sf = Surface((frect.width, frect.height), pygame.SRCALPHA, 32)
     font_sf.blit(fonter, frect)
     self.image = font_sf
     self.rect = font_sf.get_rect()
     self.rect.width += TAG_PADDING
     self.rect.height += TAG_PADDING
     self.rect.x = initial_position[0]
     self.rect.y = initial_position[1]
     self.mask = mask.from_surface(self.image)
     self.mask = self.mask.convolve(CONVMASK, None, (TAG_PADDING, TAG_PADDING))
开发者ID:davepeake,项目名称:PyTagCloud,代码行数:26,代码来源:__init__.py


示例7: movement_controls

    def movement_controls(self, pressed, tilemap):
        if pressed[A]:
            self.rotation += 2
            self.rotate_vehicle(358)
            collision_result = collision_check(self, tilemap, Vec2d(0,0))
            if collision_result.collisions:
                self.rotation -= 2
                self.rotate_vehicle(2)   
        if pressed[D]:
            self.rotation -= 2
            self.rotate_vehicle(2)
            collision_result = collision_check(self, tilemap, Vec2d(0,0))
            if collision_result.collisions:
                self.rotation += 2
                self.rotate_vehicle(358)

        if pressed[W] and abs(self.speed) < self.top_speed:
            self.speed += self.acceleration
        if pressed[S] and abs(self.speed) < self.top_speed:
            self.speed -= self.acceleration

        if not pressed[W] and not pressed[S] and self.speed != 0:
            if abs(self.speed) < abs(self.acceleration):
                self.speed = 0
            else:
                self.speed -= math.copysign(self.acceleration, self.speed)
        if pressed[A] or pressed[D]:
            self.image = transform.rotate(self.base_image, self.rotation)
            self.rect = self.image.get_rect()
开发者ID:gogoantov,项目名称:asuras,代码行数:29,代码来源:__init__.py


示例8: createCharTexture

	def createCharTexture( self, char, mode=None ):
		"""Create character's texture/bitmap as a Numeric array w/ width and height

		This uses PyGame and Numeric to attempt to create
		an anti-aliased luminance texture-map of the given
		character and return it as (data, width, height).
		"""
		try:
			letter_render = self.font.render(
				char,
				1,
				(255,255,255)
			)
		except:
			traceback.print_exc()
			return None, font.CharacterMetrics(char,0,0)
		else:
			# XXX Figure out why this rotate appears to be required :(
			letter_render = transform.rotate( letter_render, -90.0)
			colour = surfarray.array3d( letter_render )
			alpha = surfarray.array_alpha( letter_render )
			colour[:,:,1] = alpha
			colour = colour[:,:,:2]
			colour = contiguous( colour )
			# This produces what looks like garbage, but displays correctly
			colour.shape = (colour.shape[1],colour.shape[0],)+colour.shape[2:]
			return colour, font.CharacterMetrics(
				char,
				colour.shape[0],
				colour.shape[1],
			)
开发者ID:Tcll5850,项目名称:UMC3.0a,代码行数:31,代码来源:pygamefont.py


示例9: draw_word

 def draw_word(self, word):
     rot_image = transform.rotate(
                  word.image,
                  90 * word.platform.body.angle)
     self.window.display_surface.blit(
                 rot_image,
                 word.platform.body.position - word.offset)
开发者ID:mjs,项目名称:ldnpydojo,代码行数:7,代码来源:render.py


示例10: __init__

 def __init__(self, fruit, interp_step):
     """ Prepare the fruit's spr: a square diamond 
     with a number in the center.
     interp_step determines where to position the sprite, 
     based on the view's current sprite step. 
     """
     DirtySprite.__init__(self)
     self.fruit = fruit
     
     # make the square
     sq_surf = Surface((cell_size / 1.414, cell_size / 1.414))
     sq_surf.set_colorkey((255, 0, 255))  # magenta = color key
     sq_surf.fill(FRUIT_COLORS[fruit.fruit_type])
     # rotate for a diamond
     dm_surf = rotate(sq_surf, 45)
     blit_rect = Rect(0, 0, cell_size * 1.414, cell_size * 1.414)
     # blit the diamond as the fruit's image
     img = Surface((cell_size, cell_size))
     img.set_colorkey((255, 0, 255))  # magenta = color key
     img.fill((255, 0, 255))
     img.blit(dm_surf, blit_rect)
     
     # add text at the center
     self.font = Font(None, font_size) 
     txtsurf = self.font.render(str(fruit.fruit_num), True, (0, 0, 0))
     textpos = txtsurf.get_rect(center=(cell_size / 2, cell_size / 2))
     img.blit(txtsurf, textpos)
     
     # prepare rect to blit on screen
     self.resync(interp_step)
     
     self.image = img
开发者ID:gentimouton,项目名称:smofac,代码行数:32,代码来源:fruitspr.py


示例11: _resolve_params

def _resolve_params(data, obj_col):
    """(dict, list) -> NoneType
    For each object in obj_col, resolve the non-type parameters on it, and render the object if applicable."""
    for obj in obj_col:
        if data["img"]:
            obj.img = load_img(data["img"])
        if data["flip"]:
            horiz, vert = None, None
            args = data["flip"].strip("()").split(",")
            if args[0] == "false":
                horiz = False
            else:
                horiz = True
            if args[1] == "false":
                vert = False
            else:
                vert = True

            obj.img = transform.flip(obj.img, horiz, vert)
        if data["rotate"]:
            obj.img = transform.rotate(obj.img, int(data["rotate"].split("=")[-1]))
        if data["scale"]:
            obj.img = transform.scale(obj.img, tuple(int(i) for i in data["scale"].strip("()").split(",")))

        obj.render(screen, update_queue)
开发者ID:Roolymoo,项目名称:fantasygame,代码行数:25,代码来源:main.py


示例12: updateScreen

    def updateScreen(self):
        "Draw everything on the screen"
        
        self.screen.fill(RGB_BLACK)
        
        #Draw Paddle and Ball
        self.screen.blit(transform.rotate(self.paddle.image,
                                self.paddle.angle), self.paddle.position)
        
        for ball in self.balls:
            self.screen.blit(ball.image, (ball.x, ball.y))

        #Draw Points Label and Points String
        self.screen.blit(self.pointsLabel, (10,10))
        self.screen.blit(self.pointsString, (80,10))
        
        #Draw Level Label and Level String
        self.screen.blit(self.levelLabel, (200, 10))
        self.screen.blit(self.levelString, (250, 10))
        
        #Draw non-destroyed Bricks for current level
        self.drawBricks()
        
        #Draw any bonuses that are on screen at the moment
        for boni in self.bonuses:
            self.screen.blit(boni.image, boni.rect)

        #Draw Mini-paddles signifying lifes left
        self.drawMiniPaddles()
        
        pygame.display.flip()
开发者ID:ahmetkeskin61,项目名称:breakout,代码行数:31,代码来源:pybreakout.py


示例13: __animate

	def __animate(self, game):

		if ((game.frame % self.animInterval) == 0):
			self.anim_frame += 1
		
			if (self.anim_frame > self.maxFrames):
				self.anim_frame = 1
			if (self.anim_frame <= 0):
				self.anim_frame = self.maxFrames

				
		imageString = self.sprname + "_" + str(self.anim_frame)
		
		# if we flip the y then we must move adjust the rect.x
		if self.flips[1]:
			self.rect.x = self.orgRect.x + self.posPercent * self.orgRect.height - self.orgRect.height + TILE_SIZE
		else:
			self.rect.x = self.orgRect.x
			
		# clip part of the image
		img = transform.chop(game.images[imageString][0], Rect(0,0,0,self.posPercent * self.orgRect.height))
		
		# apply flipping and rotation if required
		if self.flips[0] or self.flips[1]:
			img = transform.flip(img, self.flips[0], self.flips[1])
		if self.rotation != 0:
			img = transform.rotate(img, self.rotation)
			
		self.setimage(img)
开发者ID:rjzaar,项目名称:Speckpater,代码行数:29,代码来源:popupenemy.py


示例14: _rotate

 def _rotate (self, direct):		# code 0, 1, 2, 3
     """
     rotate tank by code:
     0 - 0 deg, 1 - 90 deg, 2 - 180, 3 - 270;
     """
     if self.direction != direct:
         self.image = transform.rotate(self.image, (self.direction - direct)*90)
         self.direction = direct
开发者ID:zygisx,项目名称:BattleCity,代码行数:8,代码来源:tanks.py


示例15: __init__

 def __init__(self, x, y):
     self.x = x
     self.y = y
     super(Spaceship, self).__init__('sprites/spaceship.png')
     transColor = self.image.get_at((0,0))
     self.image.set_colorkey(transColor)
     self.image = scale(self.image, (60, 70))
     self.image = rotate(self.image, 270)
开发者ID:danielfranca,项目名称:pw-warmup,代码行数:8,代码来源:spaceship.py


示例16: flip

 def flip(self):
     pos = (self.rect.x, self.rect.y)
     angle = 90 if self.rotation == 0 else - 90
     self.image = transform.rotate(self.image, angle)
     self.rect = self.image.get_rect()
     self.rect.x, self.rect.y = pos
     self.mask = mask.from_surface(self.image)
     self.mask = self.mask.convolve(CONVMASK, None, (TAG_PADDING, TAG_PADDING))
开发者ID:mooseburger,项目名称:PyTagCloud,代码行数:8,代码来源:__init__.py


示例17: command_rotate_left

def command_rotate_left(new_img, screen, file, rect):
    "rotate counter clockwise"
    wait_cursor()
    new_img = rotate(new_img, 90)
    rect = get_center(screen, new_img)
    my_update_screen(new_img, rect, file)
    normal_cursor()
    return (new_img, new_img, rect)
开发者ID:rkulla,项目名称:imgv,代码行数:8,代码来源:rotate.py


示例18: update

    def update(self, x, y, course, shutdirection, dead, frag):

        self.rect.x, self.rect.y, self.course, self.shutdirection, self.dead, self.frag = \
            x, y, course, shutdirection, dead, frag

        # если танк взорвали
        if (self.dead > 0):
            if (self.dead < self.config.DEAD_COUNT):

                # показываем анимацию взрыва
                self.image = Surface((self.config.WIDTH,self.config.HEIGHT))
                self.image.fill(Color(self.COLOR))
                self.image.set_colorkey(Color(self.COLOR))
                self.boltAnimDie.blit(self.image, (0, 0))

            else:

                # закончили показывать взрыв, респауним танк
                self.image = image.load(self.config.INIT_IMAGE)
                #  Анимация движения
                boltAnim = []
                for anim in self.config.ANIMATION:
                    boltAnim.append((anim, self.config.ANIMATION_DELAY))
                self.boltAnimMove = pyganim.PygAnimation(boltAnim)
                self.boltAnimMove.play()

        # направление
        else:

            self.image = Surface((self.config.WIDTH,self.config.HEIGHT)) # перерисовываем аватарку
            self.image.fill(Color(self.COLOR))                           # заливаем фон
            self.image.set_colorkey(Color(self.COLOR))                   # делаем фон прозрачным
            self.boltAnimMove.blit(self.image, (0, 0))                   # выводим анимацию

            # движение влево
            if self.shutdirection == "left":
                self.image = transform.rotate(self.image, 90)                # поворачиваем по направлению движения

            # движение вправо
            elif self.shutdirection == "right":
                self.image = transform.rotate(self.image, 270)

            # движение вниз
            elif self.shutdirection == "down":
                self.image = transform.rotate(self.image, 180)
开发者ID:apsmi,项目名称:PyTanks,代码行数:45,代码来源:client_tank.py


示例19: _adjust_bearing

 def _adjust_bearing(self):
     """
     Make the image the face the correct angle
     """
     expected_rotation = self._expected_bearing()
     if expected_rotation != self._rotation:
         self.image = transform.rotate(self._root_image, expected_rotation)
         self.rect = self.image.get_rect(center=self.rect.center)
         self._rotation = expected_rotation
开发者ID:lobobabysaurus,项目名称:CatAndMouseV1,代码行数:9,代码来源:Animal.py


示例20: draw

 def draw(self, surf):
     frame = surf.get_rect()
     if self.highlighted:
         surf.fill(self.highlight_color)
     image = self.image
     image = transform.rotate(image, self._angle)
     r = image.get_rect()
     r.center = frame.center
     surf.blit(image, r)
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:9,代码来源:controls.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python transform.scale函数代码示例发布时间:2022-05-25
下一篇:
Python time.Clock类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap