本文整理汇总了Python中surface.Surface类的典型用法代码示例。如果您正苦于以下问题:Python Surface类的具体用法?Python Surface怎么用?Python Surface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Surface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,
base=[0, 0, 0],
focal=200.0,
seglen=30.0,
ang=0.006,
r0=5.5,
r1=None
):
'''
Constructor
Parameters:
base: the center point of the wide end of the segment
seglen: the axial length of the segment
ang: angle of the segment side to the axis
r0: radius of the wide end of the segment
r1: radius of the small end of the segment
'''
# instantiate
Surface.__init__(self)
self.base = np.array(base, dt)
self.focal = focal
self.seglen = seglen
self.ang = ang
''' Vanspeybroeck and Chase Parameters '''
self.e = cos(4 * ang) * (1 + (tan(4 * ang) * tan(3 * ang)))
self.d = focal * tan(4 * ang) * tan((4 * ang) - 3 * ang)
self.updateDims(r0, r1)
开发者ID:ehsteve,项目名称:foxsi-optics-sim,代码行数:28,代码来源:segmenth.py
示例2: __init__
def __init__(self, system, frame, Y=0, Z=0, R=1, name=None, tolerance=1e-10, ):
Surface.__init__(self, system, name, tolerance)
self.frame = frame
self.Y = Y
self.Z = Z
self.R = R
self.sign = 1.0
开发者ID:elliothevel,项目名称:whisker_sim,代码行数:7,代码来源:circle.py
示例3: Weapon
class Weapon(Emitter, Inputable):
def __init__(self, level, **kwargs):
super().__init__(**kwargs)
self._level = level
self._part = None
self._s = Surface((20, 10))
self._s.fill((255, 0, 0))
self._input = Input(inputStream=self.getInputStream())
self._input.set(pygame.KEYDOWN, self.createNew, pygame.K_f)
def createNew(self):
x, y = self._offsetFunc()
self._part = Particle((self._anchor.x + x, self._anchor.y + y, 20, 10),
(10, 0),
self._s,
self._level,
Behaviors.killAt(150, 150),
Behaviors.moveAt(self._anchor.getIntDir() * 10, 0),
Behaviors.killOnCollision(exceptions=(self._anchor.getId(),)),
Behaviors.cleanupCollision(),
altname="bullet")
if x < 0:
self._part.x -= self._part.w
self._part.move.setSpeed(x=self._part.move.getTopSpeed(x=True))
def _emit(self):
if self._part:
self._children.append(self._part)
self._part = None
def tick(self):
self._input()
super().tick()
开发者ID:DanCardin,项目名称:PyPlatformer,代码行数:35,代码来源:weapons.py
示例4: __init__
def __init__(self, system, Y, Z, frame, tolerance=1e-10, name=None):
Surface.__init__(self, system, name, tolerance)
self.Y = Y
self.Z = Z
self.frame = frame
self.sign = -1.0
self.pegrw = np.array((0,Y,Z,1))
开发者ID:elliothevel,项目名称:whisker_sim,代码行数:7,代码来源:peg.py
示例5: __init__
def __init__(self, system, X, Y, Z, R, frame, tolerance=1e-10, name=None):
Surface.__init__(self, system, name, tolerance)
self.X = X
self.Y = Y
self.Z = Z
self.R = R
self.frame = frame
self.sign = -1.0
开发者ID:elliothevel,项目名称:whisker_sim,代码行数:8,代码来源:sphere.py
示例6: __init__
def __init__(self, system, point, normal, frame, tolerance=1e-10, name=None):
Surface.__init__(self, system, name, tolerance)
self.normal = normal
self.point = point
self.frame = frame
self.plane_d = -np.dot(point, normal)
self.plane_r = np.sqrt(np.dot(normal,normal))
self.sign = -1.0
开发者ID:elliothevel,项目名称:whisker_sim,代码行数:8,代码来源:plane.py
示例7: resize
def resize(self, width, height):
Surface.resize(self, width, height)
self.surface.resize(width, height)
try:
self.surface._display.textbox.resize()
except (TypeError, AttributeError): #pyjs-O:TypeError/-S:AttributeError
pass
try:
self.surface._display.textarea.resize()
except (TypeError, AttributeError): #pyjs-O:TypeError/-S:AttributeError
pass
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:11,代码来源:display.py
示例8: convert_image
def convert_image(self, image):
"""
Return the image as a Surface.
"""
if env.canvas._isCanvas:
img = image.getElement()
surface = Surface((img.width,img.height))
surface.drawImage(image, 0, 0)
else:
surface = Surf(image)
return surface
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:11,代码来源:image.py
示例9: scale
def scale(self, surface, size, dest=None):
"""
Return Surface resized by the given size.
An optional destination surface can be provided.
"""
if not dest:
surf = Surface(size)
else:
surf = dest
surf.drawImage(surface.canvas, 0, 0, surface.get_width(), surface.get_height(), 0, 0, size[0], size[1]) #pyjs0.8 *.canvas
# surf.drawImage(surface, 0, 0, surface.get_width(), surface.get_height(), 0, 0, size[0], size[1])
return surf
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:12,代码来源:transform.py
示例10: __init__
def __init__(self, origin = [-1,-1,0], ax1 = [2,0,0], ax2 = [0,2,0]):
'''
Constructor
Parameters:
ax1: first edge of parallelogram as a vector
ax2: second edge of parallelogram as a vector
origin: the origin coordinate for both axes
'''
Surface.__init__(self)
self.origin = np.array(origin,dt)
self.ax1 = np.array(ax1,dt)
self.ax2 = np.array(ax2,dt)
开发者ID:ehsteve,项目名称:foxsi-optics-sim,代码行数:13,代码来源:plane.py
示例11: scale
def scale(self, surface, size, dest=None):
"""
Return Surface resized by the given size.
An optional destination surface can be provided.
"""
if not dest:
surf = Surface(size, BufferedImage.TYPE_INT_ARGB)
else:
surf = dest
g2d = surf.createGraphics()
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
g2d.drawImage(surface, 0, 0, size[0], size[1], None)
g2d.dispose()
return surf
开发者ID:YuliReiri,项目名称:WinLifeGame,代码行数:14,代码来源:transform.py
示例12: __init__
def __init__( self,
camera,
scale=1.0,
tileSize=128,
tilesX=1,
tilesZ=1,
depth=30.0):
self.depth = depth
self.tileSize = tileSize
self.tilesX = tilesX
self.tilesZ = tilesZ
self.camera = camera
self.scale = scale
self.surfaceShader = ShaderProgram.open('shaders/colour_by_height.shader')
# Use the shallow pool ripple surface generator
self.heightfield = Ripples(self.camera, self.tileSize)
# The water surface
self.surface = Surface( self.surfaceShader,
self.camera,
texture=None,
heightfield=self.heightfield,
tileSize=self.tileSize,
tilesX=self.tilesX,
tilesZ=self.tilesZ,
scale=self.scale,
offset=Vector3(0.0,self.depth,0.0))
开发者ID:naxIO,项目名称:WaterCaustics,代码行数:33,代码来源:water.py
示例13: apply
def apply(self):
self._log.debug(u"""Applying values
filename: '%s',
subdivisions: '%f',
bezier factor: '%f'""" % (
self.surface_filename,
self.surface_subdivisions,
self.bezier_factor))
if self.surface:
del self.surface
if self.plane:
self.plane.removeNode()
self.plane = None
if self.mls_surface:
self.mls_surface.removeNode()
self.mls_surface = None
if self.bezier_surface:
self.bezier_surface.removeNode()
self.bezier_surface = None
if self.point_cloud:
self.point_cloud.removeNode()
self.point_cloud = None
self.surface = Surface.from_file(self.surface_filename)
self._toggle_plane()
self._toggle_mls_surface()
self._toggle_bezier_surface()
self._toggle_point_cloud()
开发者ID:weltenwort,项目名称:uni_cg2,代码行数:27,代码来源:cg2_ex2.py
示例14: create_life
def create_life(self):
spot_count = len(Level1.LIFE_SPOT)
spot_number = randint(0, spot_count - 1)
life_tile = Surface.get_tile_by_number(Level1.LIFE_SPOT[spot_number])
Life(life_tile.x, life_tile.y)
开发者ID:mmoreirasouza,项目名称:pythonzombiegame,代码行数:7,代码来源:level1.py
示例15: Pool
class Pool():
'''
A shallow pool with concentric ripples on its surface
'''
def __init__( self,
camera,
scale=1.0,
tileSize=128,
tilesX=1,
tilesZ=1,
depth=30.0):
self.depth = depth
self.tileSize = tileSize
self.tilesX = tilesX
self.tilesZ = tilesZ
self.camera = camera
self.scale = scale
self.surfaceShader = ShaderProgram.open('shaders/colour_by_height.shader')
# Use the shallow pool ripple surface generator
self.heightfield = Ripples(self.camera, self.tileSize)
# The water surface
self.surface = Surface( self.surfaceShader,
self.camera,
texture=None,
heightfield=self.heightfield,
tileSize=self.tileSize,
tilesX=self.tilesX,
tilesZ=self.tilesZ,
scale=self.scale,
offset=Vector3(0.0,self.depth,0.0))
def setDepth(self, depth):
self.surface.setDepth(self.depth)
def tap(self, tapPosition):
self.heightfield.tap(tapPosition)
def draw(self,dt):
self.surface.draw(dt)
开发者ID:naxIO,项目名称:WaterCaustics,代码行数:45,代码来源:water.py
示例16: blit_array
def blit_array(self, surface, array):
"""
Generates image pixels from a JNumeric array.
Arguments include surface to generate the image, and array of integer colors.
"""
if not self.initialized:
self._init()
w,h = array.shape
data = Numeric.reshape(array, (1,w*h))[0]
if not surface.getColorModel().hasAlpha():
surface.setRGB(0, 0, surface.width, surface.height, data, 0, surface.width)
else:
surf = Surface((w,h), BufferedImage.TYPE_INT_RGB)
surf.setRGB(0, 0, surface.width, surface.height, data, 0, surface.width)
g2d = surface.createGraphics()
g2d.drawImage(surf, 0, 0, None)
g2d.dispose()
return None
开发者ID:YuliReiri,项目名称:WinLifeGame,代码行数:18,代码来源:surfarray.py
示例17: addLayers
def addLayers(self, final_n):
"""Add layers until the number of layers equals final_n."""
if final_n > settings.max_number_of_layers:
return
if final_n >= len(self.layers):
for i in range(final_n - len(self.layers) + 1):
layer = Surface.create(self)
layer.atom_types = self.substrate_atom_types
layer.hide()
self.layers.append(layer)
开发者ID:SINGROUP,项目名称:MolecularUI,代码行数:10,代码来源:molecular_scene.py
示例18: __init__
def __init__(self, level, **kwargs):
super().__init__(**kwargs)
self._level = level
self._part = None
self._s = Surface((20, 10))
self._s.fill((255, 0, 0))
self._input = Input(inputStream=self.getInputStream())
self._input.set(pygame.KEYDOWN, self.createNew, pygame.K_f)
开发者ID:DanCardin,项目名称:PyPlatformer,代码行数:10,代码来源:weapons.py
示例19: create_enemy
def create_enemy(self, player):
spot_count = len(Level1.ENEMY_SPOT)
spot_number = randint(0, spot_count - 1)
enemy_tile = Surface.get_tile_by_number(Level1.ENEMY_SPOT[spot_number])
type_count = len(Enemy.Types)
type_index = randint(0, type_count - 1)
Enemy(enemy_tile.x, enemy_tile.y, player, Enemy.Types[type_index])
开发者ID:mmoreirasouza,项目名称:pythonzombiegame,代码行数:10,代码来源:level1.py
示例20: load
def load(file):
"""Load an image from a file name in a new surface. Type detected from file name.
Args
file: The name of the image file.
Returns:
A new surface.
"""
return Surface._from_ptr(check_ptr_err(lib.IMG_Load(file)))
开发者ID:jdoda,项目名称:sdl2hl,代码行数:10,代码来源:image.py
注:本文中的surface.Surface类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论