本文整理汇总了Python中simpleguitk.load_image函数的典型用法代码示例。如果您正苦于以下问题:Python load_image函数的具体用法?Python load_image怎么用?Python load_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
"""
Create a frame and load the cancer data
"""
self._frame = simplegui.create_frame("Cancer risk visualization", CANVAS_WIDTH, CANVAS_HEIGHT)
self._frame.set_canvas_background("White")
self._frame.set_draw_handler(self.draw)
self._frame.add_input("Enter cutoff (scaled by 0.00001)", self.enter_cutoff, 200)
self._frame.add_button("Print data table in CSV", self.print_table, 200)
self._data_table = self.load_data()
self.enter_cutoff("0.0")
self._USA_Counties = simplegui.load_image(MAP_URL)
self._frame.start()
示例2: __init__
def __init__(self, game):
self._cols = game.get_grid_height()
self._rows = game.get_grid_width()
self._frame = simplegui.create_frame(
"2048", self._rows * TILE_SIZE + 2 * BORDER_SIZE, self._cols * TILE_SIZE + 2 * BORDER_SIZE
)
self._frame.add_button("New Game", self.start)
self._frame.set_keydown_handler(self.keydown)
self._frame.set_draw_handler(self.draw)
self._frame.set_canvas_background("#A39480")
self._frame.start()
self._game = game
url = "http://codeskulptor-assets.commondatastorage.googleapis.com/assets_2048.png"
self._tiles = simplegui.load_image(url)
self._directions = {"up": UP, "down": DOWN, "left": LEFT, "right": RIGHT}
示例3: __init__
def __init__(self, game):
self._game = game
self._rows = game.get_grid_height()
self._cols = game.get_grid_width()
self._frame = simplegui.create_frame('2048',
self._cols * TILE_SIZE + 2 * BORDER_SIZE,
self._rows * TILE_SIZE + 2 * BORDER_SIZE)
self._frame.add_button('New Game', self.start)
self._frame.set_keydown_handler(self.keydown)
self._frame.set_draw_handler(self.draw)
self._frame.set_canvas_background("#BCADA1")
self._tiles = simplegui.load_image(IMAGE_URL)
self._directions = {"up": UP, "down": DOWN,
"left": LEFT, "right": RIGHT}
self._frame.start()
示例4: get_radius
def get_radius(self):
return self.radius
def get_lifespan(self):
return self.lifespan
def get_animated(self):
return self.animated
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/debris2_blue.png")
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.f2014.png")
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/splash.png")
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
# missile image - shot1.png, shot2.png, shot3.png
missile_info = ImageInfo([5,5], [10, 10], 3, 50)
示例5: get_radius
return self.size
def get_radius(self):
return self.radius
def get_lifespan(self):
return self.lifespan
def get_animated(self):
return self.animated
# art assets created by Kim Lathrop, may be freely re-used in non-commercial projects, please credit Kim
# ship image
ship_info = ImageInfo([45, 45], [90, 90], 35)
ship_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/double_ship.png")
# sound assets purchased from sounddogs.com, please do not redistribute
ship_thrust_sound = simplegui.load_sound("http://commondatastorage.googleapis.com/codeskulptor-assets/sounddogs/thrust.mp3")
# ship class
class Ship:
def __init__(self, pos, vel, angle, image, info):
self.pos = [pos[0], pos[1]]
self.vel = [vel[0], vel[1]]
self.thrust = False
self.angle = angle
self.angle_vel = 0
self.image = image
self.image_centre = info.get_centre()
self.image_size = info.get_size()
示例6: collide
self.age += 1
if (self.pos[0] < 0) or (self.pos[0] > WIDTH) or (self.age >= self.lifespan):
return True
else:
return False
def collide(self, other_object):
dis = dist(self.get_position(), other_object.get_position())
if dis <= self.get_radius() + other_object.get_radius():
return True
else:
return False
# image and sound resource
background_info = ImageInfo([383, 165], [766, 330])
background_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132516amq1535025.png")
splash_info = ImageInfo([286, 90], [572, 180])
splash_image = simplegui.load_image("http://d2.freep.cn/3tb_1407111325231o85535025.png")
gameover_info = ImageInfo([163, 147], [327, 294])
gameover_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132519y8e8535025.png")
zombie_info = ImageInfo([32, 50], [64, 100], 20, True, 15)
zombie_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132515f08j535025.png")
zombie1_info = ImageInfo([47.5, 56], [95, 112], 22, True, 17)
zombie1_image = simplegui.load_image("http://d2.freep.cn/3tb_140711132528kiko535025.png")
shooter_info = ImageInfo([28.5, 32], [55.5, 64], 20, True, 15)
shooter_image = simplegui.load_image("http://d3.freep.cn/3tb_140711132521gb83535025.png")
示例7:
# -*- coding: utf-8 -*-
import simpleguitk as simplegui
import random
## 定义常量
# 画布的尺寸
WIDTH = 800
HEIGHT = 600
# 骨牌的尺寸、中心位置及所有骨牌的图像
DOMINO_SIZE = (70, 190)
DOMINO_CENTER = (35, 95)
domino_images = simplegui.load_image("http://www.goldata.biz/images/dominoes.png")
# 所有骨牌。文牌是成对的,武牌是独一无二的。
DOMINOES = ('TIAN', 'TIAN', 'DI', 'DI', 'REN', 'REN', 'HE', 'HE', 'MEI', 'MEI', 'CHANG', 'CHANG', \
'BAN', 'BAN', 'FU', 'FU', 'HONG', 'HONG', 'GAO', 'GAO', 'LING', 'LING', \
'JIU1', 'JIU2', 'BA1', 'BA2', 'QI1', 'QI2', 'WU1', 'WU2', 'ZHIZUN1', 'ZHIZUN2')
# 所有骨牌对应的点数
POINTS = {'TIAN':12, 'DI':2, 'REN':8, 'HE':4, 'MEI':10, 'CHANG':6, 'BAN':4, 'FU':11, 'HONG':10, \
'GAO':7, 'LING':6, 'JIU1':9, 'JIU2':9, 'BA1':8, 'BA2':8, 'QI1':7, 'QI2':7, 'WU1':5, \
'WU2':5, 'ZHIZUN1':6, 'ZHIZUN2':3}
# 对牌与其排位、名称
DOMINO_PATTERNS = {('ZHIZUN1', 'ZHIZUN2'):(1, '至尊宝'), ('TIAN', 'TIAN'):(2, '双天'), ('DI', 'DI'):(3, '双地'), \
('REN', 'REN'):(4, '孖人'), ('HE', 'HE'):(5, '孖和'), ('MEI', 'MEI'):(6, '孖梅'), \
('CHANG', 'CHANG'):(7, '孖长'), ('BAN', 'BAN'):(8, '孖板凳'), ('FU', 'FU'):(9, '孖斧头'), \
('HONG', 'HONG'):(10, '孖红头'), ('GAO', 'GAO'):(11, '孖高脚'), ('LING', 'LING'):(12, '孖零霖'), \
('JIU1', 'JIU2'):(13, '杂九'), ('BA1', 'BA2'):(14, '杂八'), ('QI1', 'QI2'):(15, '杂七'), \
示例8: click
__author__ = 'expressyang'
"""
简易放大镜
"""
import simpleguitk as simplegui
MAP_WIDTH = 2000
MAP_HEIGHT = 1818
#map_image = simplegui.load_image("http://ads.xjts.cn/zt/xj_map/images/1.jpg")
map_image = simplegui.load_image("1.jpg")
# 常量
MAP_SCALE = 3
CANVAS_WIDTH = MAP_WIDTH / MAP_SCALE
CANVAS_HEIGHT = MAP_HEIGHT / MAP_SCALE
MAGNIFIER_SIZE = 120
# Event handlers
def click(pos):
magnifier_center[0] = pos[0]
magnifier_center[1] = pos[1]
def drag(pos):
magnifier_center[0] = pos[0]
magnifier_center[1] = pos[1]
def draw(canvas):
# 绘制图片
canvas.draw_image(map_image, (MAP_WIDTH / 2, MAP_HEIGHT / 2), (MAP_WIDTH, MAP_HEIGHT),
(CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2), (CANVAS_WIDTH, CANVAS_HEIGHT))
示例9: toggle
import math
from datetime import datetime
# 全局变量
interval = 1000 # 时间事件处理器触发的周期,1秒
hour = 0.0
minute = 0.0
second = 0.0
hour_radian = 0.0
minute_radian = 0.0
second_radian = 0.0
digit_date = ""
digit_time = ""
display_digit = False
clock_face = simplegui.load_image("images/ClockFace.jpg")
hour = simplegui.load_image("images/Hour.png")
minute = simplegui.load_image("images/Minute.png")
second = simplegui.load_image("images/Second.png")
# 定义按钮的事件处理函数
def toggle():
global display_digit
display_digit = not display_digit
if display_digit:
button.set_text("关闭数显")
else:
button.set_text("开启数显")
示例10: get_size
return self.center
def get_size(self):
return self.size
def get_radius(self):
return self.radius
def get_lifespan(self):
return self.lifespan
def get_animated(self):
return self.animated
grassland_info = ImageInfo([960, 600], [1920, 1200])
grassland_image = simplegui.load_image("resources/grassland.jpg") # 地面背景
arrow_info = ImageInfo([21, 5], [42, 10],5,60)
arrow_image = simplegui.load_image("resources/arrow.png") # 箭
castle_info = ImageInfo([54, 52], [109, 105],50)
castle_image = simplegui.load_image("resources/castle.png") # 城堡
enemy_info = ImageInfo([32, 15], [64, 29], 15, 1000, True)
enemy_image = simplegui.load_image("resources/enemy.png") # 敌人,图像文件中包含4副图片用来实现动画
soldier_info = ImageInfo([32, 26], [64, 52])
soldier_image = simplegui.load_image("resources/soldier.png") # 战士,图像文件中包含2副图片用来实现动画
win_info = ImageInfo([320, 240], [640, 480])
win_image = simplegui.load_image("resources/win.png") # 游戏成功
gameover_info = ImageInfo([320, 240], [640, 480])
gameover_image = simplegui.load_image("resources/gameover.png") # 游戏结束
explosion_info = ImageInfo([64, 64], [128, 128], 17, 24, True)
explosion_image = simplegui.load_image("resources/explosion.png") # 爆炸,图像文件中包含多副图片用来实现动画
示例11: newgame
import random
#定义全局变量
WIDTH = 400
HEIGHT = 400 #画布高度和宽度
image_size= [60,60] #手势图像高度和宽度
gesture_image = [] # 3张手势图片
choice_image = [] # 显示的2张出拳的图片
#index_image = [0,1,2]
turns = 0 #表示局数
score1,score2 = 0, 0 #得分
started = False #控制是否进入游戏界面
mouse_pos =(0,0)
message = "" #屏幕上显示输赢的信息
background1_image = simplegui.load_image("images\\background1.png")
background2_image = simplegui.load_image("images\\background2.png")
start_image = simplegui.load_image("images\\start.png")
gesture_image.append(simplegui.load_image("images\\scissors.png"))
gesture_image.append(simplegui.load_image("images\\stone.png"))
gesture_image.append(simplegui.load_image("images\\cloth.png"))
choice_image.append(simplegui.load_image("images\\stone.png"))
choice_image.append(simplegui.load_image("images\\stone.png"))
background_sound = simplegui.load_sound("sound\\sound1.ogg")
# 定义函数
#定义事件处理函数
def newgame():
global turns, score1, score2, message
turns = 0
score1,score2 = 0, 0
示例12:
# 创建窗口
# 16强共32张图片,每个图片的显示大小为128x128像素
# 32张图片显示为4行8列,因此窗口的宽度为128x8=1024像素,高度为128x4=512像素
frame = simplegui.create_frame("2014巴西世界杯16强连连看", 1024, 512)
frame.add_button("重新开始", new_game, 100)
label = frame.add_label("回合次数 = 0")
# 注册事件处理函数
frame.set_mouseclick_handler(mouseclick)
frame.set_draw_handler(draw)
# 读取图片
logo_image = simplegui.load_image("images\\Logo.png")
flag_image.append(simplegui.load_image("images\\Algeria.png"))
flag_image.append(simplegui.load_image("images\\Argentina.png"))
flag_image.append(simplegui.load_image("images\\Belgium.png"))
flag_image.append(simplegui.load_image("images\\Brazil.png"))
flag_image.append(simplegui.load_image("images\\Chile.png"))
flag_image.append(simplegui.load_image("images\\Colombia.png"))
flag_image.append(simplegui.load_image("images\\Costa-rica.png"))
flag_image.append(simplegui.load_image("images\\France.png"))
flag_image.append(simplegui.load_image("images\\Germany.png"))
flag_image.append(simplegui.load_image("images\\Greece.png"))
flag_image.append(simplegui.load_image("images\\Mexico.png"))
flag_image.append(simplegui.load_image("images\\Netherlands.png"))
flag_image.append(simplegui.load_image("images\\Nigeria.png"))
flag_image.append(simplegui.load_image("images\\Switzerland.png"))
flag_image.append(simplegui.load_image("images\\Uruguay.png"))
示例13: get_radius
def get_radius(self):
return self.radius
def get_lifespan(self):
return self.lifespan
def get_animated(self):
return self.animated
# debris images - debris1_brown.png, debris2_brown.png, debris3_brown.png, debris4_brown.png
# debris1_blue.png, debris2_blue.png, debris3_blue.png, debris4_blue.png, debris_blend.png
debris_info = ImageInfo([320, 240], [640, 480])
debris_image = simplegui.load_image(
"https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/debris2_blue.png"
)
# nebula images - nebula_brown.png, nebula_blue.png
nebula_info = ImageInfo([400, 300], [800, 600])
nebula_image = simplegui.load_image(
"https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/nebula_blue.png"
)
# splash image
splash_info = ImageInfo([200, 150], [400, 300])
splash_image = simplegui.load_image(
"https://raw.githubusercontent.com/EduIbanez/introduction-programming-python/master/mini-project-7/images/splash.png"
)
# ship image
示例14: draw
"""
The explosion example in code skulptor
"""
import simpleguitk as simplegui
EXPLOSION_CENTRE = [50, 50]
EXPLOSION_SIZE = [100, 100]
EXPLOSION_DIM = [9, 9]
explosion_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/explosion.hasgraphics.png")
# create timer that iterate current_sprite_centre through sprite
time = 0
# define draw handler
def draw(canvas):
global time
explosion_index = [time % EXPLOSION_DIM[0], (time // EXPLOSION_DIM[0]) % EXPLOSION_DIM[1]]
canvas.draw_image(explosion_image,
[EXPLOSION_CENTRE[0] + explosion_index[0] * EXPLOSION_SIZE[0],
EXPLOSION_CENTRE[1] + explosion_index[1] * EXPLOSION_SIZE[1]],
EXPLOSION_SIZE, EXPLOSION_CENTRE, EXPLOSION_SIZE)
time += 1
# end of draw()
# create frame and size frame based on 100x100 pixel sprite
frame = simplegui.create_frame("Asteroid sprite", EXPLOSION_SIZE[0], EXPLOSION_SIZE[1])
# set draw handler and canvas background using custom HTML colour
frame.set_draw_handler(draw)
frame.set_canvas_background("blue")
示例15: __init__
# demo for drawing using tiled images
import simpleguitk as simplegui
# define globals for cards
RANKS = ('A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K')
SUITS = ('C', 'S', 'H', 'D')
# card sprite - 950x392
CARD_CENTER = (36.5, 49)
CARD_SIZE = (73, 98)
card_image = simplegui.load_image("http://commondatastorage.googleapis.com/codeskulptor-assets/cards.jfitz.png")
# define card class
class Card:
def __init__(self, suit, rank):
self.rank = rank
self.suit = suit
def draw(self, canvas, loc):
i = RANKS.index(self.rank)
j = SUITS.index(self.suit)
card_pos = [CARD_CENTER[0] + i * CARD_SIZE[0],
CARD_CENTER[1] + j * CARD_SIZE[1]]
canvas.draw_image(card_image, card_pos, CARD_SIZE, loc, CARD_SIZE)
# define draw handler
def draw(canvas):
one_card.draw(canvas, (155, 90))