コード例 #1
0
    def __init__(self, user_dtype=None, transform=None,
                 viewport=None, vertex=None, fragment=None, **kwargs):
        """
        Initialize the collection.

        Parameters
        ----------

        user_dtype: list
            The base dtype can be completed (appended) by the used_dtype. It
            only make sense if user also provide vertex and/or fragment shaders

        transform: glumpy.Tranforms
            The default vertex shader apply the supplied transform to the
            vertices positions before computing the actual vertices positions
            for path thickness.

        vertex: string
            Vertex shader code

        fragment: string
            Fragment  shader code

        color : string
            'local', 'shared' or 'global'
        """
        if vertex is None:
            vertex = library.get("collections/agg-point.vert")
        if fragment is None:
            fragment = library.get("collections/agg-point.frag")

        RawPointCollection.__init__(self, user_dtype=user_dtype,
                                    transform=transform, viewport=viewport,
                                    vertex=vertex, fragment=fragment, **kwargs)
コード例 #2
0
    def __init__(self, user_dtype=None, transform=None, viewport=None,
                 vertex = None, fragment = None, **kwargs):

        base_dtype = [('position', (np.float32, 3), '!local', (0,0,0)),
                      ('color',    (np.float32, 4), 'local',  (0,0,0,1)) ]

        dtype = base_dtype
        if user_dtype:
            dtype.extend(user_dtype)

        if vertex is None:
            vertex = library.get('collections/raw-triangle.vert')
        if fragment is None:
            fragment = library.get('collections/raw-triangle.frag')

        Collection.__init__(self, dtype=dtype, itype=np.uint32, mode=gl.GL_TRIANGLES,
                            vertex=vertex, fragment=fragment, **kwargs)

        # Set hooks if necessary
        program = self._programs[0]
        if "transform" in program.hooks:
            if transform is not None:
                program["transform"] = transform
            else:
                program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()
コード例 #3
0
    def _merge(self, shaders, shader_class):
        """
        Merge a list of shaders
        """

        if isinstance(shaders, shader_class):
            return shaders
        elif isinstance(shaders, str):
            return shader_class(shaders if '{' in shaders else library.get(shaders))
        elif shaders is None:
            return None
        elif isinstance(shaders, (tuple, list)):
            pass
        else:
            raise ValueError('shaders must be str, Shader or list')

        # Merge shader list
        code = ''
        for shader in shaders:
            if isinstance(shader, str):
                code += library.get(shader)
            elif isinstance(shader, shader_class):
                code += shader.code
            else:
                raise ValueError('Cannot make a Shader out of %r.' % type(shader))
        return shader_class(code)
コード例 #4
0
    def __init__(self, user_dtype=None, transform=None, viewport=None,
                 vertex = None, fragment = None, **kwargs):

        base_dtype = [('position', (np.float32, 3), '!local', (0,0,0)),
                      ('color',    (np.float32, 4), 'local', (0,0,0,1)) ]

        dtype = base_dtype
        if user_dtype:
            dtype.extend(user_dtype)

        if vertex is None:
            vertex = library.get('collections/raw-triangle.vert')
        if fragment is None:
            fragment = library.get('collections/raw-triangle.frag')

        Collection.__init__(self, dtype=dtype, itype=np.uint32, mode=gl.GL_TRIANGLES,
                            vertex=vertex, fragment=fragment, **kwargs)

        # Set hooks if necessary
        program = self._programs[0]
        if "transform" in program.hooks:
            if transform is not None:
                program["transform"] = transform
            else:
                program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()
コード例 #5
0
    def __init__(self, vertex=None, fragment=None, geometry=None, count=0):
        """
        Initialize the program and optionnaly buffer.
        """

        GLObject.__init__(self)
        self._count = count
        self._buffer = None
        self._vertex = None
        self._fragment = None
        self._geometry = None

        if vertex is not None:
            if isinstance(vertex, str):
                if not '{' in vertex:
                    vertex = library.get(vertex)
                self._vertex = VertexShader(vertex)
            elif isinstance(vertex, VertexShader):
                self._vertex = vertex
            else:
                log.error("vertex must be a string or a VertexShader")

        if fragment is not None:
            if isinstance(fragment, str):
                if not '{' in fragment:
                    fragment = library.get(fragment)
                self._fragment = FragmentShader(fragment)
            elif isinstance(fragment, FragmentShader):
                self._fragment = fragment
            else:
                log.error("fragment must be a string or a FragmentShader")

        if geometry is not None:
            if isinstance(geometry, str):
                if not '{' in geometry:
                    geometry = library.get(geometry)
                self._geometry = GeometryShader(geometry)
            elif isinstance(geometry, GeometryShader):
                self._geometry = geometry
            else:
                log.error("geometry must be a string or a GeometryShader")

        self._uniforms = {}
        self._attributes = {}

        # Build hooks, uniforms and attributes
        self._build_hooks()
        self._build_uniforms()
        self._build_attributes()

        # Build associated structured vertex buffer if count is given
        if self._count > 0:
            dtype = []
            for attribute in self._attributes.values():
                dtype.append(attribute.dtype)
            self._buffer = np.zeros(self._count,
                                    dtype=dtype).view(VertexBuffer)
            self.bind(self._buffer)
コード例 #6
0
ファイル: program.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, vertex=None, fragment=None, geometry=None, count=0):
        """
        Initialize the program and optionnaly buffer.
        """

        GLObject.__init__(self)
        self._count = count
        self._buffer = None
        self._vertex =  None
        self._fragment = None
        self._geometry = None
        
        if vertex is not None:
            if isinstance(vertex, str):
                if not '{' in vertex:
                    vertex = library.get(vertex)
                self._vertex = VertexShader(vertex)
            elif isinstance(vertex,VertexShader):
                self._vertex = vertex
            else:
                log.error("vertex must be a string or a VertexShader")

        if fragment is not None:
            if isinstance(fragment, str):
                if not '{' in fragment:
                    fragment = library.get(fragment)
                self._fragment = FragmentShader(fragment)
            elif isinstance(fragment, FragmentShader):
                self._fragment = fragment
            else:
                log.error("fragment must be a string or a FragmentShader")

        if geometry is not None:
            if isinstance(geometry, str):
                if not '{' in geometry:
                    geometry = library.get(geometry)
                self._geometry = GeometryShader(geometry)
            elif isinstance(geometry, GeometryShader):
                self._geometry = geometry
            else:
                log.error("geometry must be a string or a GeometryShader")
                

        self._uniforms = {}
        self._attributes = {}

        # Build hooks, uniforms and attributes
        self._build_hooks()
        self._build_uniforms()
        self._build_attributes()

        # Build associated structured vertex buffer if count is given
        if self._count > 0:
            dtype = []
            for attribute in self._attributes.values():
                dtype.append(attribute.dtype)
            self._buffer = np.zeros(self._count, dtype=dtype).view(VertexBuffer)
            self.bind(self._buffer)
コード例 #7
0
    def __init__(self, user_dtype=None, transform=None,
                 viewport=None, vertex=None, fragment=None, **kwargs):
        """
        Initialize the collection.

        Parameters
        ----------

        user_dtype: list
            The base dtype can be completed (appended) by the used_dtype. It
            only make sense if user also provide vertex and/or fragment shaders

        transform: glumpy.Tranforms
            The default vertex shader apply the supplied transform to the
            vertices positions before computing the actual vertices positions
            for path thickness. Note that it is necessary to add the
            glumpy.transforms.Viewport transform at the end of the supplied transform.

        vertex: string
            Vertex shader code

        fragment: string
            Fragment  shader code

        color : string
            'local', 'shared' or 'global'
        """

        base_dtype = [ ('P',     (np.float32, 3), '!local', (0,0,0)),
                       ('color', (np.float32, 4), 'global', (0,0,0,1)) ]

        dtype = base_dtype
        if user_dtype:
            dtype.extend(user_dtype)

        if vertex is None:
            vertex = library.get('collections/raw-segment.vert')
        if fragment is None:
            fragment = library.get('collections/raw-segment.frag')

        Collection.__init__(self, dtype=dtype, itype=None, mode=gl.GL_LINES,
                            vertex=vertex, fragment=fragment, **kwargs)

        # Set hooks if necessary
        program = self._programs[0]
        if "transform" in program.hooks:
            if transform is not None:
                program["transform"] = transform
            else:
                program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()
コード例 #8
0
    def __init__(self,
                 transform=None,
                 viewport=None,
                 color=(1, 1, 1, 1),
                 **kwargs):
        dtype = [('position', (np.float32, 2), '!local', (0, 0)),
                 ('texcoord', (np.float32, 2), '!local', (0, 0)),
                 ('offset', (np.float32, 1), '!local', 0),
                 ('origin', (np.float32, 3), 'shared', (0, 0, 0)),
                 ('color', (np.float32, 4), 'shared', color)]

        print('===========================')
        if "vertex" in kwargs.keys():
            vertex = kwargs["vertex"]
            del kwargs["vertex"]
        else:
            vertex = library.get('collections/agg-glyph.vert')

        if "fragment" in kwargs.keys():
            fragment = kwargs["vertex"]
            del kwargs["vertex"]
        else:
            fragment = library.get('collections/agg-glyph.frag')

        Collection.__init__(self,
                            dtype=dtype,
                            itype=np.uint32,
                            mode=gl.GL_TRIANGLES,
                            vertex=vertex,
                            fragment=fragment)

        program = self._programs[0]

        if transform is not None:
            program["transform"] = transform
        else:
            program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()

        manager = FontManager()
        atlas = manager.atlas_agg
        self['atlas_data'] = atlas
        self['atlas_data'].interpolation = gl.GL_LINEAR
        self['atlas_shape'] = atlas.shape[1], atlas.shape[0]
コード例 #9
0
    def __init__(self, code=None, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        transform : bool (default is False)
            Whether to enforce viewport transformation

        clipping : bool (default is False)
            Whether to enforce viewport clipping

        viewport : tuple of 4 floats (default is None)
            Viewport (x,y,w,h) in window coordinates
        """

        if code is None:
            code = library.get("transforms/viewport.glsl")

        self._global = 0,0,512,512
        self._local = Transform._get_kwarg("viewport", kwargs) or None
        self._clipping = Transform._get_kwarg("clipping", kwargs) or True
        self._transform = Transform._get_kwarg("transform", kwargs) or True

        Transform.__init__(self, code, *args, **kwargs)
コード例 #10
0
ファイル: trackball_pan.py プロジェクト: wangvei/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        code = library.get("transforms/trackball-pan.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or 1
        self._znear = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0
        theta = Transform._get_kwarg("theta", kwargs) or 45
        phi = Transform._get_kwarg("phi", kwargs) or 45
        self._distance = Transform._get_kwarg("distance", kwargs) or 8
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 35
        self._width = 1
        self._height = 1
        self._window_aspect = 1
        self._view_x = 0
        self._view_y = 0
        self._shift = False

        self._trackball = _trackball.Trackball(45, 45)
        self._projection = np.eye(4, dtype=np.float32)
        self._view = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -abs(self._distance))
コード例 #11
0
ファイル: log_scale.py プロジェクト: jk34/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        base : float (default is 10)
            Log base

        domain : tuple of 2 floats (default is (1,10))
            Input domain

        range : tuple of 2 floats (default is (-1,1))
            Output range

        clamp : bool (default is False)
           Clamping test

        discard : bool (default is False)
           Discard test
        """

        self._base = float(Transform._get_kwarg("base", kwargs) or 10.0)
        kwargs["domain"] = kwargs.get("domain", (1,10))
        code = library.get("transforms/log-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #12
0
ファイル: trackball_pan.py プロジェクト: glumpy/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        code = library.get("transforms/trackball-pan.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or 1
        self._znear = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0
        theta = Transform._get_kwarg("theta", kwargs) or 45
        phi = Transform._get_kwarg("phi", kwargs) or 45
        self._distance = Transform._get_kwarg("distance", kwargs) or 8
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 35
        self._width = 1
        self._height = 1
        self._window_aspect = 1
        self._view_x = 0
        self._view_y = 0
        self._shift = False

        self._trackball = _trackball.Trackball(45,45)
        self._projection = np.eye(4, dtype=np.float32)
        self._view = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -abs(self._distance))
コード例 #13
0
ファイル: power_scale.py プロジェクト: jk34/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        exponent : float (default is 1)
            Power exponent

        domain : tuple of 2 floats (default is (-1,1))
            Input domain

        range : tuple of 2 floats (default is (-1,1))
            Output range

        clamp : bool (default is False)
           Clamping test

        discard : bool (default is False)
           Discard test
        """

        self._exponents = Transform._get_kwarg("exponent", kwargs, 1.0)
        code = library.get("transforms/power-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #14
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        exponent : float (default is 1)
            Power exponent

        domain : tuple of 2 floats (default is (-1,1))
            Input domain

        range : tuple of 2 floats (default is (-1,1))
            Output range

        clamp : bool (default is False)
           Clamping test

        discard : bool (default is False)
           Discard test
        """

        self._exponents = Transform._get_kwarg("exponent", kwargs, 1.0)
        code = library.get("transforms/power-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #15
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        base : float (default is 10)
            Log base

        domain : tuple of 2 floats (default is (1,10))
            Input domain

        range : tuple of 2 floats (default is (-1,1))
            Output range

        clamp : bool (default is False)
           Clamping test

        discard : bool (default is False)
           Discard test
        """

        self._base = float(Transform._get_kwarg("base", kwargs) or 10.0)
        kwargs["domain"] = kwargs.get("domain", (1, 10))
        code = library.get("transforms/log-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #16
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        self._exponents = Transform._get_kwarg("exponent", kwargs, 1.0)
        code = library.get("transforms/power-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #17
0
ファイル: power_scale.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        self._exponents = Transform._get_kwarg("exponent", kwargs, 1.0)
        code = library.get("transforms/power-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #18
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform
        """

        self._base = float(Transform._get_kwarg("base", kwargs) or 10.0)
        kwargs["domain"] = kwargs.get("domain", (1, 10))
        code = library.get("transforms/log-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #19
0
ファイル: log_scale.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform
        """

        self._base = float(Transform._get_kwarg("base", kwargs) or 10.0)
        kwargs["domain"] = kwargs.get("domain", (1,10))
        code = library.get("transforms/log-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #20
0
    def __init__(self, transform=None, viewport=None, **kwargs):
        dtype = [('position', (np.float32, 2), '!local', (0, 0)),
                 ('texcoord', (np.float32, 2), '!local', (0, 0)),
                 ('origin', (np.float32, 3), 'shared', (0, 0, 0)),
                 ('direction', (np.float32, 3), 'shared', (1, 0, 0)),
                 ('scale', (np.float32, 1), 'shared', 0.005),
                 ('color', (np.float32, 4), 'shared', (0, 0, 0, 1))]

        if "vertex" in kwargs.keys():
            vertex = library.get(kwargs["vertex"])
            del kwargs["vertex"]
        else:
            vertex = library.get('collections/sdf-glyph.vert')

        if "fragment" in kwargs.keys():
            fragment = library.get(kwargs["fragment"])
            del kwargs["fragment"]
        else:
            fragment = library.get('collections/sdf-glyph.frag')

        Collection.__init__(self,
                            dtype=dtype,
                            itype=np.uint32,
                            mode=gl.GL_TRIANGLES,
                            vertex=vertex,
                            fragment=fragment)
        program = self._programs[0]
        if transform is not None:
            program["transform"] = transform
#        else:
#            program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()

        manager = FontManager()
        atlas = manager.atlas_sdf
        self['u_kernel'] = data.get("spatial-filters.npy")
        self['atlas_data'] = atlas
        self['atlas_data'].interpolation = gl.GL_LINEAR
        self['atlas_shape'] = atlas.shape[1], atlas.shape[0]
コード例 #21
0
    def __init__(self, *args, **kwargs):
        code = library.get("transforms/pvm.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._fovy = 40
        self._znear, self._zfar = 2.0, 100.0
        self._view = np.eye(4, dtype=np.float32)
        self._model = np.eye(4, dtype=np.float32)
        self._projection = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -5)
コード例 #22
0
ファイル: pvm_projection.py プロジェクト: jk34/glumpy
    def __init__(self, *args, **kwargs):
        code = library.get("transforms/pvm.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._fovy = 40
        self._znear, self._zfar = 2.0, 100.0
        self._view = np.eye(4, dtype=np.float32)
        self._model = np.eye(4, dtype=np.float32)
        self._projection = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -5)
コード例 #23
0
    def __init__(self,
                 user_dtype=None,
                 transform=None,
                 viewport=None,
                 vertex=None,
                 fragment=None,
                 **kwargs):
        """
        Initialize the collection.

        Parameters
        ----------

        user_dtype: list
            The base dtype can be completed (appended) by the used_dtype. It
            only make sense if user also provide vertex and/or fragment shaders

        transform: glumpy.Tranforms
            The default vertex shader apply the supplied transform to the
            vertices positions before computing the actual vertices positions
            for path thickness.

        vertex: string
            Vertex shader code

        fragment: string
            Fragment  shader code

        color : string
            'local', 'shared' or 'global'
        """
        if vertex is None:
            vertex = library.get("collections/agg-point.vert")
        if fragment is None:
            fragment = library.get("collections/agg-point.frag")

        RawPointCollection.__init__(self,
                                    user_dtype=user_dtype,
                                    transform=transform,
                                    viewport=viewport,
                                    vertex=vertex,
                                    fragment=fragment,
                                    **kwargs)
コード例 #24
0
ファイル: viewport.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, code=None, *args, **kwargs):
        if code is None:
            code = library.get("transforms/viewport.glsl")

        self._global = 0,0,512,512
        self._local = Transform._get_kwarg("viewport", kwargs) or None
        self._clipping = Transform._get_kwarg("clipping", kwargs) or True
        self._transform = Transform._get_kwarg("transform", kwargs) or True

        Transform.__init__(self, code, *args, **kwargs)
コード例 #25
0
    def __init__(self, code=None, *args, **kwargs):
        if code is None:
            code = library.get("transforms/viewport.glsl")

        self._global = 0, 0, 512, 512
        self._local = Transform._get_kwarg("viewport", kwargs) or None
        self._clipping = Transform._get_kwarg("clipping", kwargs) or True
        self._transform = Transform._get_kwarg("transform", kwargs) or True

        Transform.__init__(self, code, *args, **kwargs)
コード例 #26
0
    def __init__(self, transform=None, viewport=None, **kwargs):
        dtype = [('position',  (np.float32, 2), '!local', (0,0)),
                 ('texcoord',  (np.float32, 2), '!local', (0,0)),
                 ('origin',    (np.float32, 3), 'shared', (0,0,0)),
                 ('direction', (np.float32, 3), 'shared', (1,0,0)),
                 ('scale',     (np.float32, 1), 'shared', 0.005),
                 ('color',     (np.float32, 4), 'shared', (0,0,0,1))]

        if "vertex" in kwargs.keys():
            vertex = library.get(kwargs["vertex"])
            del kwargs["vertex"]
        else:
            vertex = library.get('collections/sdf-glyph.vert')

        if "fragment" in kwargs.keys():
            fragment = library.get(kwargs["fragment"])
            del kwargs["fragment"]
        else:
            fragment = library.get('collections/sdf-glyph.frag')

        Collection.__init__(self, dtype=dtype, itype=np.uint32,
                            mode = gl.GL_TRIANGLES,
                            vertex=vertex, fragment=fragment)
        program = self._programs[0]
        if transform is not None:
            program["transform"] = transform
#        else:
#            program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()


        manager = FontManager()
        atlas = manager.atlas_sdf
        self['u_kernel'] = data.get("spatial-filters.npy")
        self['atlas_data'] = atlas
        self['atlas_data'].interpolation = gl.GL_LINEAR
        self['atlas_shape'] = atlas.shape[1], atlas.shape[0]
コード例 #27
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------
        """

        code = library.get("transforms/hammer.glsl")
        Transform.__init__(self, code, *args, **kwargs)
コード例 #28
0
    def __init__(self, *args, **kwargs):

        code = library.get("transforms/projection.glsl")

        self._width = None
        self._height = None
        self._aspect = Transform._get_kwarg("aspect", kwargs) or None
        self._xinvert = Transform._get_kwarg("xinvert", kwargs) or False
        self._yinvert = Transform._get_kwarg("yinvert", kwargs) or False
        self._znear = Transform._get_kwarg("znear", kwargs) or -1000
        self._zfar = Transform._get_kwarg("znear", kwargs) or +1000
        self._normalize = Transform._get_kwarg("normalize", kwargs) or False
        Transform.__init__(self, code, *args, **kwargs)
コード例 #29
0
    def __init__(self, *args, **kwargs):

        code = library.get("transforms/projection.glsl")

        self._width     = None
        self._height    = None
        self._aspect    = Transform._get_kwarg("aspect", kwargs) or None
        self._xinvert   = Transform._get_kwarg("xinvert", kwargs) or False
        self._yinvert   = Transform._get_kwarg("yinvert", kwargs) or False
        self._znear     = Transform._get_kwarg("znear", kwargs) or -1000
        self._zfar      = Transform._get_kwarg("znear", kwargs) or +1000
        self._normalize = Transform._get_kwarg("normalize", kwargs) or False
        Transform.__init__(self, code, *args, **kwargs)
コード例 #30
0
ファイル: rotate.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, *args, **kwargs):
        """ Initialize the transform.  """
        self._forward = np.zeros((4,4), dtype=np.float32)
        self._inverse = np.zeros((4,4), dtype=np.float32)
        self._axis = Transform._get_kwarg("axis", kwargs, (0,0,1))
        self._angle = Transform._get_kwarg("angle", kwargs, 0.0)
        self._origin = Transform._get_kwarg("origin", kwargs, (0.,0.,0.))

        code = library.get("transforms/rotate.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        # Force building of rotation matrices
        self.axis = self._axis
コード例 #31
0
    def __init__(self, *args, **kwargs):
        """ Initialize the transform.  """
        self._forward = np.zeros((4, 4), dtype=np.float32)
        self._inverse = np.zeros((4, 4), dtype=np.float32)
        self._axis = Transform._get_kwarg("axis", kwargs, (0, 0, 1))
        self._angle = Transform._get_kwarg("angle", kwargs, 0.0)
        self._origin = Transform._get_kwarg("origin", kwargs, (0., 0., 0.))

        code = library.get("transforms/rotate.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        # Force building of rotation matrices
        self.axis = self._axis
コード例 #32
0
ファイル: pvm_projection.py プロジェクト: glumpy/glumpy
    def __init__(self, *args, **kwargs):
        code = library.get("transforms/pvm.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._width     = None
        self._height    = None
        self._distance = Transform._get_kwarg("distance", kwargs) or 5
        self._fovy     = Transform._get_kwarg("fovy", kwargs) or 40
        self._znear    = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar     = Transform._get_kwarg("zfar", kwargs) or 100.0
        self._view = np.eye(4, dtype=np.float32)
        self._model = np.eye(4, dtype=np.float32)
        self._projection = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -self._distance)
コード例 #33
0
ファイル: pvm_projection.py プロジェクト: wzunknown/glumpy
    def __init__(self, *args, **kwargs):
        code = library.get("transforms/pvm.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._width = None
        self._height = None
        self._distance = Transform._get_kwarg("distance", kwargs) or 5
        self._fovy = Transform._get_kwarg("fovy", kwargs) or 40
        self._znear = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar = Transform._get_kwarg("zfar", kwargs) or 100.0
        self._view = np.eye(4, dtype=np.float32)
        self._model = np.eye(4, dtype=np.float32)
        self._projection = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -self._distance)
コード例 #34
0
ファイル: trackball.py プロジェクト: jk34/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        aspect : float (default is None)
           Indicate what is the aspect ratio of the object displayed. This is
           necessary to convert pixel drag move in oject space coordinates.

        znear : float, float (default is 2)
           Near clip plane

        zfar : float, float (default is 1000)
           Distance clip plane

        theta : float (default is 45)
           Angle (in degrees) around the z axis

        phi:  float (default is 45)
           Angle (in degrees) around the x axis

        distance: float (default is 8)
           Distance from the trackball to the object

        zoom : float (default is 35)
           Zoom level
        """

        code = library.get("transforms/trackball.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or 1
        self._znear = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0
        theta = Transform._get_kwarg("theta", kwargs) or 45
        phi = Transform._get_kwarg("phi", kwargs) or 45
        self._distance = Transform._get_kwarg("distance", kwargs) or 8
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 35
        self._width = 1
        self._height = 1
        self._window_aspect = 1

        self._trackball = _trackball.Trackball(45,45)
        self._projection = np.eye(4, dtype=np.float32)
        self._view = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -abs(self._distance))
コード例 #35
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        aspect : float (default is None)
           Indicate what is the aspect ratio of the object displayed. This is
           necessary to convert pixel drag move in oject space coordinates.

        znear : float, float (default is 2)
           Near clip plane

        zfar : float, float (default is 1000)
           Distance clip plane

        theta : float (default is 45)
           Angle (in degrees) around the z axis

        phi:  float (default is 45)
           Angle (in degrees) around the x axis

        distance: float (default is 8)
           Distance from the trackball to the object

        zoom : float (default is 35)
           Zoom level
        """

        code = library.get("transforms/trackball.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or 1
        self._znear = Transform._get_kwarg("znear", kwargs) or 2.0
        self._zfar = Transform._get_kwarg("zfar", kwargs) or 1000.0
        theta = Transform._get_kwarg("theta", kwargs) or 45
        phi = Transform._get_kwarg("phi", kwargs) or 45
        self._distance = Transform._get_kwarg("distance", kwargs) or 8
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 35
        self._width = 1
        self._height = 1
        self._window_aspect = 1

        self._trackball = _trackball.Trackball(45, 45)
        self._projection = np.eye(4, dtype=np.float32)
        self._view = np.eye(4, dtype=np.float32)
        glm.translate(self._view, 0, 0, -abs(self._distance))
コード例 #36
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        origin : float (default is 0)
            Angle origin (radians)
        """

        self._origin = Transform._get_kwarg("origin", kwargs) or 0.0
        code = library.get("transforms/polar.glsl")
        Transform.__init__(self, code, *args, **kwargs)
コード例 #37
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        code = library.get("transforms/panzoom.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or None
        self._pan = np.array(Transform._get_kwarg("pan", kwargs) or (0., 0.))
        self._zoom_min = Transform._get_kwarg("zoom_min", kwargs) or 0.01
        self._zoom_max = Transform._get_kwarg("zoom_max", kwargs) or 1000
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 1
        self._width = 1
        self._height = 1
        self._window_aspect = np.asarray([1., 1.])
コード例 #38
0
ファイル: panzoom.py プロジェクト: WhiteSymmetry/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        code = library.get("transforms/panzoom.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or None
        self._pan = np.array(Transform._get_kwarg("pan", kwargs) or (0.,0.))
        self._zoom_min = Transform._get_kwarg("zoom_min", kwargs) or 0.01
        self._zoom_max = Transform._get_kwarg("zoom_max", kwargs) or 1000
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 1
        self._width = 1
        self._height = 1
        self._window_aspect = np.asarray([1.,1.])
コード例 #39
0
    def __init__(self, *args, **kwargs):
        """
        Orthographic projection transform.

        Paremeters
        ----------

        aspect : float (default: None)
            Aspect ratio (width/height) to be enforced

        xinvert: bool (default: False)
            Whether to invert X axis

        yinvert: bool (default: False)
            Whether to invert Y axis

        normalize: bool (default: False)
            Whether to use normalized device coordinates
        """

        code = library.get("transforms/projection.glsl")

        kwargs["aspect"] = kwargs.get("aspect", None)
        self.aspect = kwargs["aspect"]
        del kwargs["aspect"]

        kwargs["xinvert"] = kwargs.get("xinvert", False)
        self.xinvert = kwargs["xinvert"]
        del kwargs["xinvert"]

        kwargs["yinvert"] = kwargs.get("yinvert", False)
        self.yinvert = kwargs["yinvert"]
        del kwargs["yinvert"]

        kwargs["znear"] = kwargs.get("xinvert", -1000)
        self.znear = kwargs["znear"]
        del kwargs["znear"]

        kwargs["zfar"] = kwargs.get("xinvert", +1000)
        self.zfar = kwargs["zfar"]
        del kwargs["zfar"]

        kwargs["normalize"] = kwargs.get("normalize", False)
        self.normalize = kwargs["normalize"]
        del kwargs["normalize"]

        Transform.__init__(self, code, *args, **kwargs)
コード例 #40
0
    def __init__(self, *args, **kwargs):
        """
        Orthographic projection transform.

        Paremeters
        ----------

        aspect : float (default: None)
            Aspect ratio (width/height) to be enforced

        xinvert: bool (default: False)
            Whether to invert X axis

        yinvert: bool (default: False)
            Whether to invert Y axis

        normalize: bool (default: False)
            Whether to use normalized device coordinates
        """

        code = library.get("transforms/projection.glsl")

        kwargs["aspect"] = kwargs.get("aspect", None)
        self.aspect = kwargs["aspect"]
        del kwargs["aspect"]

        kwargs["xinvert"] = kwargs.get("xinvert", False)
        self.xinvert = kwargs["xinvert"]
        del kwargs["xinvert"]

        kwargs["yinvert"] = kwargs.get("yinvert", False)
        self.yinvert = kwargs["yinvert"]
        del kwargs["yinvert"]

        kwargs["znear"] = kwargs.get("xinvert", -1000)
        self.znear = kwargs["znear"]
        del kwargs["znear"]

        kwargs["zfar"] = kwargs.get("xinvert", +1000)
        self.zfar = kwargs["zfar"]
        del kwargs["zfar"]

        kwargs["normalize"] = kwargs.get("normalize", False)
        self.normalize = kwargs["normalize"]
        del kwargs["normalize"]

        Transform.__init__(self, code, *args, **kwargs)
コード例 #41
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------


        clip : tuple of 4 floats


        scale : float
            Scale factor applied to normalized Cartesian coordinates

        center : float, float
            Center of the projection as (longitude,latitude)

        rotate : float, float, [float]
            Rotation as yaw, pitch and roll.

        translate : float, float
            Translation (in scaled coordinates)

        parallels : float, float
            Parallels as define in conic equal area projection.
        """

        self._clip = Transform._get_kwarg("clip", kwargs, (-180,180,-90,90))
        self._scale = Transform._get_kwarg("scale", kwargs, 1.0)
        self._center = Transform._get_kwarg("center", kwargs, (0,0))
        self._rotate = Transform._get_kwarg("rotate", kwargs, (0,0))
        self._translate = Transform._get_kwarg("translate", kwargs, (0,0))
        self._parallels = Transform._get_kwarg("parallels", kwargs, (0,90))
        code = library.get("transforms/conic-equal-area.glsl")

        # Make sure to call the forward function
        kwargs["call"] = "forward"

        Transform.__init__(self, code, *args, **kwargs)
コード例 #42
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------


        clip : tuple of 4 floats


        scale : float
            Scale factor applied to normalized Cartesian coordinates

        center : float, float
            Center of the projection as (longitude,latitude)

        rotate : float, float, [float]
            Rotation as yaw, pitch and roll.

        translate : float, float
            Translation (in scaled coordinates)

        parallels : float, float
            Parallels as define in conic equal area projection.
        """

        self._clip = Transform._get_kwarg("clip", kwargs, (-180, 180, -90, 90))
        self._scale = Transform._get_kwarg("scale", kwargs, 1.0)
        self._center = Transform._get_kwarg("center", kwargs, (0, 0))
        self._rotate = Transform._get_kwarg("rotate", kwargs, (0, 0))
        self._translate = Transform._get_kwarg("translate", kwargs, (0, 0))
        self._parallels = Transform._get_kwarg("parallels", kwargs, (0, 90))
        code = library.get("transforms/conic-equal-area.glsl")

        # Make sure to call the forward function
        kwargs["call"] = "forward"

        Transform.__init__(self, code, *args, **kwargs)
コード例 #43
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        domain : tuple of 2 floats (default is (-1,1))
            Input domain

        range : tuple of 2 floats (default is (-1,1))
            Output range

        clamp : bool (default is False)
           Clamping test

        discard : bool (default is False)
           Discard test
        """
        code = library.get("transforms/linear-scale.glsl")
        QuantitativeScale.__init__(self, code, *args, **kwargs)
コード例 #44
0
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        aspect : float (default is None)
           Indicate what is the aspect ratio of the object displayed. This is
           necessary to convert pixel drag move in oject space coordinates.

        pan : float, float (default is 0,0)
           Initial translation

        zoom : float, float (default is 1)
           Initial zoom level

        zoom_min : float (default is 0.01)
           Minimal zoom level

        zoom_max : float (default is 1000)
           Maximal zoom level
        """

        code = library.get("transforms/panzoom.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or None
        self._pan = np.array(Transform._get_kwarg("pan", kwargs) or (0., 0.))
        self._zoom_min = Transform._get_kwarg("zoom_min", kwargs) or 0.01
        self._zoom_max = Transform._get_kwarg("zoom_max", kwargs) or 1000
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 1
        self._width = 1
        self._height = 1
        self._window_aspect = np.asarray([1., 1.])
コード例 #45
0
ファイル: panzoom.py プロジェクト: jk34/glumpy
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        Note that parameters must be passed by name (param=value).

        Kwargs parameters
        -----------------

        aspect : float (default is None)
           Indicate what is the aspect ratio of the object displayed. This is
           necessary to convert pixel drag move in oject space coordinates.

        pan : float, float (default is 0,0)
           Initial translation

        zoom : float, float (default is 1)
           Initial zoom level

        zoom_min : float (default is 0.01)
           Minimal zoom level

        zoom_max : float (default is 1000)
           Maximal zoom level
        """

        code = library.get("transforms/panzoom.glsl")
        Transform.__init__(self, code, *args, **kwargs)

        self._aspect = Transform._get_kwarg("aspect", kwargs) or None
        self._pan = np.array(Transform._get_kwarg("pan", kwargs) or (0.,0.))
        self._zoom_min = Transform._get_kwarg("zoom_min", kwargs) or 0.01
        self._zoom_max = Transform._get_kwarg("zoom_max", kwargs) or 1000
        self._zoom = Transform._get_kwarg("zoom", kwargs) or 1
        self._width = 1
        self._height = 1
        self._window_aspect = np.asarray([1.,1.])
コード例 #46
0
ファイル: dwtrackball.py プロジェクト: BYU-PCCL/Quixotic
    def __init__(self, *args, **kwargs):
        """
        Initialize the transform.
        """

        code = library.get("transforms/trackball.glsl")
        Transform.__init__( self, code, *args, **kwargs )

        self._width = 1
        self._height = 1

#        self.view_xyz = np.asarray( [ 2, 2, 0.5 ] )  # camera xyz
#        self.view_hpr = np.asarray( [ 187, 0, 0 ] )  # camera heading, pitch, roll (degrees)
#        self.view_xyz = np.asarray( [ 0.5, 0.25, 6.0 ] )  # camera xyz
#        self.view_hpr = np.asarray( [ 270, -22.5, 0 ] )  # camera heading, pitch, roll (degrees)

        self.view_xyz = np.asarray( [ 0.0, 0.0, 1.0 ] )  # camera xyz
        self.view_hpr = np.asarray( [ 0.0, 0.0, 0.0 ] )  # camera heading, pitch, roll (degrees)

        self._model = np.eye( 4, dtype=np.float32 )
        self._projection = np.eye( 4, dtype=np.float32 )
        self._view = np.eye( 4, dtype=np.float32 )

        glm.translate( self._model, 0, 0, -1 )
コード例 #47
0
# program['u_minor_grid_step'] = np.array([ 0.25, np.pi/60])
# program['u_limits1'] = -5.1, +5.1, -5.1, +5.1
# program['u_limits2'] = 1.0, 5.0, 0*np.pi, 2*np.pi

# Cartesian domains
program['u_major_grid_step'] = np.array([1.00, 1.00])
program['u_minor_grid_step'] = np.array([0.10, 0.10])
program['u_limits1'] = -5.1, +5.1, -5.1, +5.1
program['u_limits2'] = -5.0, +5.0, -5.0, +5.0

# Hammer domains
# program['u_major_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/ 6.0
# program['u_minor_grid_step'] = np.array([ 1.00, 0.50]) * np.pi/30.0
# program['u_limits1'] = -3.0, +3.0, -1.5, +1.5
# program['u_limits2'] = -np.pi, +np.pi, -np.pi/3, +np.pi/3

# program['transform'] = shaders.get("transforms/polar.glsl")
# program['transform'] = shaders.get("transforms/hammer.glsl")
program['transform_forward'] = gloo.Snippet(
    library.get("transforms/identity_forward.glsl"))
program['transform_inverse'] = gloo.Snippet(
    library.get("transforms/identity_inverse.glsl"))
program['trackball'] = Trackball(Position("texcoord"))
program['trackball'].theta = 0
program['trackball'].phi = 0
program['trackball'].zoom = 7.5

window.attach(program['trackball'])

app.run()
コード例 #48
0
    def __init__(self, user_dtype=None, transform=None, viewport=None,
                 vertex=None, fragment=None, **kwargs):
        """
        Initialize the collection.

        Parameters
        ----------

        user_dtype: list
            The base dtype can be completed (appended) by the used_dtype. It
            only make sense if user also provide vertex and/or fragment shaders

        viewport: glumpy.Transforms
            The viewport to use to render the collection

        transform: glumpy.Tranforms
            The default vertex shader apply the supplied transform to the
            vertices positions before computing the actual vertices positions
            for path thickness.

        vertex: string
            Vertex shader code

        fragment: string
            Fragment  shader code

        color : string
            'local', 'shared' or 'global'
        """
        base_dtype = [ ('position', (np.float32, 3), "!local", (0,0,0)),
                       ('size',     (np.float32, 1), "global", 3.0),
                       ('color',    (np.float32, 4), "global", (0,0,0,1) ) ]

        dtype = base_dtype
        if user_dtype:
            dtype.extend(user_dtype)

        if vertex is None:
            vertex = library.get("collections/raw-point.vert")
        if fragment is None:
            fragment= library.get("collections/raw-point.frag")

        Collection.__init__(self, dtype=dtype, itype=None, mode=gl.GL_POINTS,
                            vertex=vertex, fragment=fragment, **kwargs)

        # Set hooks if necessary
        program = self._programs[0]

        if "transform" in program.hooks:
            if transform is not None:
                # FIXME: this line break things because snippet code will be included
                #        and it messes with new snippet code
                # program["transform"] = Position()
                program["transform"] = transform
            else:
                program["transform"] = Position()

        if "viewport" in program.hooks:
            if viewport is not None:
                # FIXME: this line break things because snippet code will be included
                #        and it messes with new snippet code
                # program["viewport"] = Viewport()
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()
コード例 #49
0
 def __init__(self, *args, **kwargs):
     code = library.get("transforms/translate.glsl")
     Transform.__init__(self, code, *args, **kwargs)
     self.translate = Transform._get_kwarg("translate", kwargs) or (0, 0, 0)
コード例 #50
0
ファイル: translate.py プロジェクト: jk34/glumpy
 def __init__(self, *args, **kwargs):
     code = library.get("transforms/translate.glsl")
     Transform.__init__(self, code, *args, **kwargs)
     self.translate = Transform._get_kwarg("translate", kwargs) or (0,0,0)
コード例 #51
0
 def __init__(self, *args, **kwargs):
     code = library.get("transforms/position.glsl")
     Transform.__init__(self, code, *args, **kwargs)
コード例 #52
0
    def __init__(self, user_dtype=None, transform=None, viewport=None, vertex=None, fragment=None, **kwargs):
        """
        Initialize the collection.

        Parameters
        ----------

        user_dtype: list
            The base dtype can be completed (appended) by the used_dtype. It
            only make sense if user also provide vertex and/or fragment shaders

        viewport: glumpy.Transforms
            The viewport to use to rende the collection

        transform: glumpy.Tranforms
            The default vertex shader apply the supplied transform to the
            vertices positions before computing the actual vertices positions
            for path thickness. Note that it is necessary to add the
            glumpy.transforms.Viewport transform at the end of the supplied transform.

        vertex: string
            Vertex shader code

        fragment: string
            Fragment  shader code

        caps : string
            'local', 'shared' or 'global'

        join : string
            'local', 'shared' or 'global'

        color : string
            'local', 'shared' or 'global'

        miter_limit : string
            'local', 'shared' or 'global'

        linewidth : string
            'local', 'shared' or 'global'

        antialias : string
            'local', 'shared' or 'global'
        """

        base_dtype = [
            ("p0", (np.float32, 3), "!local", (0, 0, 0)),
            ("p1", (np.float32, 3), "!local", (0, 0, 0)),
            ("p2", (np.float32, 3), "!local", (0, 0, 0)),
            ("p3", (np.float32, 3), "!local", (0, 0, 0)),
            ("uv", (np.float32, 2), "!local", (0, 0)),
            ("caps", (np.float32, 2), "global", (0, 0)),
            ("join", (np.float32, 1), "global", 0),
            ("color", (np.float32, 4), "global", (0, 0, 0, 1)),
            ("miter_limit", (np.float32, 1), "global", 4),
            ("linewidth", (np.float32, 1), "global", 1),
            ("antialias", (np.float32, 1), "global", 1),
        ]

        dtype = base_dtype
        if user_dtype:
            dtype.extend(user_dtype)

        if vertex is None:
            vertex = library.get("collections/agg-path.vert")
        if fragment is None:
            fragment = library.get("collections/agg-path.frag")

        Collection.__init__(
            self, dtype=dtype, itype=np.uint32, mode=gl.GL_TRIANGLES, vertex=vertex, fragment=fragment, **kwargs
        )

        # Set hooks if necessary
        program = self._programs[0]
        if "transform" in program.hooks:
            if transform is not None:
                program["transform"] = transform
            else:
                program["transform"] = Position() + Viewport()

        if "viewport" in program.hooks:
            if viewport is not None:
                program["viewport"] = viewport
            else:
                program["viewport"] = Viewport()
コード例 #53
0
ファイル: gloo-regular-grids.py プロジェクト: drufat/glumpy
    (rows, cols, 4), dtype=[("row", np.float32, 1), ("col", np.float32, 1), ("texcoord", np.float32, 2)]
)
vertices = vertices.view(gloo.VertexBuffer)

C, R = np.meshgrid(np.arange(cols), np.arange(rows))
vertices[:, :]["texcoord"] = (-0.5, -0.5), (-0.5, +0.5), (+0.5, +0.5), (+0.5, -0.5)
vertices[:, :]["row"] = R.reshape(rows, cols, 1)
vertices[:, :]["col"] = C.reshape(rows, cols, 1)

indices = np.zeros((rows, cols, 6), dtype=np.uint32)
indices[:, :] = 0, 1, 2, 0, 2, 3
indices[:, :] += 4 * np.arange(rows * cols, dtype=np.uint32).reshape(rows, cols, 1)
indices = indices.ravel()
indices = indices.view(gloo.IndexBuffer)

program = gloo.Program(vertex, library.get("misc/regular-grid.frag"))
program.bind(vertices)

program["rows"] = rows
program["cols"] = cols
program["u_major_grid_width"] = 1.5
program["u_minor_grid_width"] = 1.0
program["u_major_grid_color"] = 0, 0, 0, 1.0
program["u_minor_grid_color"] = 0, 0, 0, 0.5

# Polar projection example
if 0:
    limits1 = -5.1, +5.1, -5.1, +5.1
    limits2 = 1.0, 5.0, 0, 2 * np.pi
    major_grid_step = np.array([1.00, np.pi / 6])
    minor_grid_step = np.array([0.25, np.pi / 60])
コード例 #54
0
ファイル: position.py プロジェクト: glumpy/glumpy
 def __init__(self, *args, **kwargs):
     code = library.get("transforms/position.glsl")
     Transform.__init__(self, code, *args, **kwargs)