本文整理汇总了Python中collection.Collection类的典型用法代码示例。如果您正苦于以下问题:Python Collection类的具体用法?Python Collection怎么用?Python Collection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Collection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, base):
Collection.__init__(self, Artist)
self.base = base
self.model = base.model
self.populate()
示例2: append
def append( self, centers=(0, 0, 0), radius=3.0,
fg_color=(0, 0, 0, 1), bg_color=(1, 1, 1, 1),
linewidth=1.5, antialias=1.5,
translate=(0, 0, 0), scale=1.0, rotate=0.0 ):
centers = np.atleast_2d(np.array(centers))
n = len(centers)
V = np.zeros(4*n, self.vtype)
U = np.zeros(n, self.utype)
V['a_center'][0::4] = centers
V['a_center'][1::4] = V['a_center'][::4]
V['a_center'][2::4] = V['a_center'][::4]
V['a_center'][3::4] = V['a_center'][::4]
V['a_texcoord'][0::4] = -1, -1
V['a_texcoord'][1::4] = -1, +1
V['a_texcoord'][2::4] = +1, -1
V['a_texcoord'][3::4] = +1, +1
U['fg_color'][:] = fg_color
U['bg_color'][:] = bg_color
U['radius'][:] = radius
U['scale'][:] = scale
U['linewidth'][:] = linewidth
U['antialias'][:] = antialias
I = np.resize(np.array([0,1,2,1,2,3], dtype=np.uint32), n*(2*3))
Collection.append(self, V, I, U, (4,6) )
示例3: append
def append( self, points, fg_color=(0, 0, 0, 1),
linewidth=1.0, antialias=1.0, caps = ('round','round')):
P = np.array(points).astype(np.float32)
n = len(P)
V = np.zeros(2*(n+2),self.vtype)
U = np.zeros(1, self.utype)
I = (np.ones((2*n-2,3),dtype=np.uint32)*[0,1,2]).ravel()
I += np.repeat(np.arange(2*n-2),3)
I = I.ravel()
D = ((P[:-1]-P[1:])**2).sum(axis=1)
D = np.sqrt(D).cumsum().astype(np.float32)
U['fg_color'] = fg_color
U['linewidth'] = linewidth
U['antialias'] = antialias
U['length'] = D[-1]
U['caps'] = (self.caps.get(caps[0], 'round'),
self.caps.get(caps[1], 'round'))
V['a_curr'][2:2+2*n:2] = P
V['a_curr'][3:3+2*n:2] = P
V['a_curr'][:2] = P[0] - (P[ 1] - P[ 0])
V['a_curr'][-2:] = P[-1] + (P[-1] - P[-2])
V['a_texcoord'][4:4+2*(n-1):2,0] = D
V['a_texcoord'][5:5+2*(n-1):2,0] = D
V['a_texcoord'][0::2,1] = -1
V['a_texcoord'][1::2,1] = +1
Collection.append(self, V, I, U )
示例4: Initialize
def Initialize(credentials=None, opt_url=None):
"""Initialize the EE library.
If this hasn't been called by the time any object constructor is used,
it will be called then. If this is called a second time with a different
URL, this doesn't do an un-initialization of e.g.: the previously loaded
Algorithms, but will overwrite them and let point at alternate servers.
Args:
credentials: OAuth2 credentials.
opt_url: The base url for the EarthEngine REST API to connect to.
"""
data.initialize(credentials, (opt_url + '/api' if opt_url else None), opt_url)
# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
示例5: add_child
def add_child(self, name, child):
Collection.add_child(self, name, child)
names = self.get_ordered_names()
if names is not None:
names.append(name)
self._ordered_names = names
self.save()
示例6: Initialize
def Initialize(credentials="persistent", opt_url=None):
"""Initialize the EE library.
If this hasn't been called by the time any object constructor is used,
it will be called then. If this is called a second time with a different
URL, this doesn't do an un-initialization of e.g.: the previously loaded
Algorithms, but will overwrite them and let point at alternate servers.
Args:
credentials: OAuth2 credentials. 'persistent' (default) means use
credentials already stored in the filesystem, or raise an explanatory
exception guiding the user to create those credentials.
opt_url: The base url for the EarthEngine REST API to connect to.
"""
if credentials == "persistent":
credentials = _GetPersistentCredentials()
data.initialize(credentials, (opt_url + "/api" if opt_url else None), opt_url)
# Initialize the dynamically loaded functions on the objects that want them.
ApiFunction.initialize()
Element.initialize()
Image.initialize()
Feature.initialize()
Collection.initialize()
ImageCollection.initialize()
FeatureCollection.initialize()
Filter.initialize()
Geometry.initialize()
List.initialize()
Number.initialize()
String.initialize()
Date.initialize()
Dictionary.initialize()
Terrain.initialize()
_InitializeGeneratedClasses()
_InitializeUnboundMethods()
示例7: __init__
def __init__(self, dash_atlas=None):
self.dash_atlas = dash_atlas
self.vtype = np.dtype([('a_center', 'f4', 2),
('a_texcoord', 'f4', 2)])
self.utype = np.dtype([('fg_color', 'f4', 4),
('bg_color', 'f4', 4),
('translate', 'f4', 2),
('scale', 'f4', 1),
('rotate', 'f4', 1),
('radius', 'f4', 1),
('linewidth', 'f4', 1),
('antialias', 'f4', 1),
('dash_phase', 'f4', 1),
('dash_period', 'f4', 1),
('dash_index', 'f4', 1),
('dash_caps', 'f4', 2)])
Collection.__init__(self, self.vtype, self.utype)
if dash_atlas is None:
self.dash_atlas = DashAtlas()
else:
self.dash_atlas = dash_atlas
shaders = os.path.join(os.path.dirname(__file__),'shaders')
vertex_shader= os.path.join( shaders, 'circles.vert')
fragment_shader= os.path.join( shaders, 'circles.frag')
self.shader = Shader( open(vertex_shader).read(),
open(fragment_shader).read() )
示例8: __init__
def __init__(self):
self.vtype = np.dtype([('a_curr', 'f4', 3),
('a_texcoord', 'f4', 2)])
self.utype = np.dtype([('fg_color', 'f4', 4),
('length', 'f4', 1),
('linewidth', 'f4', 1),
('antialias', 'f4', 1),
('caps', 'f4', 2)])
Collection.__init__(self, self.vtype, self.utype)
dsize = self.vbuffer._dsize
a_curr = self.vbuffer.attribute('a_curr')
a_texcoord = self.vbuffer.attribute('a_texcoord')
a_index = self.vbuffer.attribute('a_index')
a_next = VertexAttribute(
'a_next', a_curr.count, a_curr.gltype, a_curr.stride, a_curr.offset)
a_prev = VertexAttribute(
'a_prev', a_curr.count, a_curr.gltype, a_curr.stride, a_curr.offset)
self.attributes.extend([a_prev, a_next])
a_index.offset += 2*dsize
a_curr.offset += 2*dsize
a_texcoord.offset += 2*dsize
a_next.offset += 4*dsize
shaders = os.path.join(os.path.dirname(__file__),'.')
vertex_shader= os.path.join( shaders, 'lines.vert')
fragment_shader= os.path.join( shaders, 'lines.frag')
self.shader = Shader( open(vertex_shader).read(),
open(fragment_shader).read() )
示例9: upload
def upload(self):
if not self._dirty:
return
Collection.upload( self )
gl.glActiveTexture( gl.GL_TEXTURE2 )
data = self._gbuffer.data.view(np.float32)
shape = len(self._gbuffer), 4*1024
if not self._gbuffer_id:
self._gbuffer_id = gl.glGenTextures(1)
gl.glBindTexture( gl.GL_TEXTURE_2D, self._gbuffer_id )
gl.glPixelStorei( gl.GL_UNPACK_ALIGNMENT, 1 )
gl.glPixelStorei( gl.GL_PACK_ALIGNMENT, 1 )
gl.glTexParameterf( gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST )
gl.glTexParameterf( gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST )
gl.glTexParameterf( gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE )
gl.glTexParameterf( gl.GL_TEXTURE_2D,
gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE )
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_BASE_LEVEL, 0)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MAX_LEVEL, 0)
gl.glTexImage2D( gl.GL_TEXTURE_2D, 0, gl.GL_RGBA32F,
shape[1]//4, shape[0], 0, gl.GL_RGBA, gl.GL_FLOAT, data )
gl.glActiveTexture( gl.GL_TEXTURE2 )
gl.glBindTexture( gl.GL_TEXTURE_2D, self._gbuffer_id )
gl.glTexImage2D( gl.GL_TEXTURE_2D, 0, gl.GL_RGBA32F,
shape[1]//4, shape[0], 0, gl.GL_RGBA, gl.GL_FLOAT, data )
self._dirty = False
示例10: display_collection
def display_collection(self, id):
collection = Collection.get_by_id(self.db, id);
if collection == None:
raise Exception("No collection with id {}!".format(id))
Collection.print_table_header()
collection.print_for_table()
items = Item.get_by_collection(self.db, collection.id)
print("ITEMS")
Item.print_table_header()
for item in items:
item.print_for_table()
示例11: append
def append( self, center=(0, 0), radius=100.0, color=(0, 0, 0, 1),
linewidth=1.0, antialias=1.0, translate=(0, 0), scale=1.0, rotate=0.0 ):
V, I, _ = self.bake(center)
U = np.zeros(1, self.utype)
U['linewidth'] = linewidth
U['antialias'] = antialias
U['color'] = color
U['translate'] = translate
U['scale'] = scale
U['rotate'] = rotate
U['radius'] = radius
Collection.append(self, V, I, U)
示例12: Reset
def Reset():
"""Reset the library. Useful for re-initializing to a different server."""
data.reset()
ApiFunction.reset()
Image.reset()
Feature.reset()
Collection.reset()
ImageCollection.reset()
FeatureCollection.reset()
Filter.reset()
Geometry.reset()
Number.reset()
String.reset()
_ResetGeneratedClasses()
global Algorithms
Algorithms = _AlgorithmsContainer()
示例13: create_child
def create_child(self, id):
if id == -1:
src = self.shell.get_player().props.source
return Source(self, id, src, src.props.query_model)
else:
return Collection.create_child(self, id)
示例14: __init__
def __init__(self, shell):
Collection.__init__(self, Source)
self.shell = shell
self.sources = {}
self.sources_rev = {}
self.source_id = 0
self.add_source(self.shell.props.library_source)
pm = self.shell.get_playlist_manager()
for pl in pm.get_playlists():
self.add_source(pl)
pm.connect('playlist-added', self.on_playlist_added)
示例15: __init__
def __init__(self):
self.vtype = np.dtype([('a_center', 'f4', 3),
('a_texcoord', 'f4', 2)])
self.utype = np.dtype([('fg_color', 'f4', 4),
('bg_color', 'f4', 4),
('translate', 'f4', 3),
('scale', 'f4', 1),
('radius', 'f4', 1),
('linewidth', 'f4', 1),
('antialias', 'f4', 1)])
Collection.__init__(self, self.vtype, self.utype)
shaders = os.path.join(os.path.dirname(__file__),'.')
vertex_shader= os.path.join( shaders, 'scatter.vert')
fragment_shader= os.path.join( shaders, 'scatter.frag')
self.shader = Shader( open(vertex_shader).read(),
open(fragment_shader).read() )