本文整理汇总了Python中tile.Tile.load方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.load方法的具体用法?Python Tile.load怎么用?Python Tile.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile.Tile
的用法示例。
在下文中一共展示了Tile.load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import load [as 别名]
def load(self):
x, y = self.pos
fileName = self.saveDir + str(x) + "_" + str(y)
if not os.path.isfile(fileName):
self.generate()
self.save()
return
with open(fileName, "r") as f:
chunkData = json.load(f)
tileList = chunkData["tiles"]
for data in tileList:
tileToLoad = Tile()
tileToLoad.load(data)
self.tiles.append(tileToLoad)
self.mobs.load(chunkData["mobs"])
示例2: __init__
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import load [as 别名]
def __init__(self, manager, tile):
'''
'''
# setup transform kernel
loader = Powertrain(True)
loader.program = """
__kernel void ds(__global const uchar *img_g,
const int width,
const int height,
const int out_width,
const int out_height,
__global uchar *out_g) {
int gid = get_global_id(0);
int col = gid % width;
int row = gid / width;
if ((col >= width) || (row >= height)) {
return;
}
if (col < 0) {
return;
}
int new_row = row/2;
int new_col = col/2;
if ((new_col >= out_width) || (new_row >= out_height)) {
return;
}
if (new_col < 0) {
return;
}
int k = new_row*out_width + new_col;
if (row % 2 == 0 && col % 2 == 0) {
uchar c = img_g[gid];
uchar r = img_g[gid+1];
uchar b = img_g[gid+width];
uchar b_r = img_g[gid+width+1];
uchar val = (c + r + b + b_r) / 4;
//out_g[k] = img_g[gid];
out_g[k] = val;
}
}
__kernel void transform(__global const uchar *img_g,
const int width,
const int height,
const float angle,
const float Tx,
const float Ty,
const int out_width,
const int out_height,
__global uchar *out_g) {
int gid = get_global_id(0);
int col = gid % width;
int row = gid / width;
if ((col >= width) || (row >= height)) {
return;
}
if (col < 0) {
return;
}
//
float c = cos(angle);
float s = sin(angle);
// new position
int new_col = c * col - s * row + Tx;
int new_row = s * col + c * row + Ty;
if ((new_col >= out_width) || (new_row >= out_height)) {
return;
}
if (new_col < 0) {
return;
}
int k = new_row*out_width + new_col;
out_g[k] = img_g[gid];
}
"""
#.........这里部分代码省略.........