本文整理汇总了Python中surface.Surface类的典型用法代码示例。如果您正苦于以下问题:Python Surface类的具体用法?Python Surface怎么用?Python Surface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Surface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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()
示例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))
示例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
示例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
示例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
示例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
示例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
示例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)
示例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
示例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))
示例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()
示例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)
示例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)