コード例 #1
0
    def transform(self, offset=0, length=None):
        domain_data = self.domain.pull_data(offset, length)
        self._transformed = True
        self._transformed_data = self.transformation(domain_data)

        if self._vbo is None:
            self._vbo = VertexBuffer.from_numpy(self._transformed_data)

        self._vbo.buffer_data(self._transformed_data)
コード例 #2
0
    def scale(self, top_left, bottom_right):
        """
        scales to field to a rectangle with top_left
        and bottom_right corner
        """
        if self.domain is None:
            self._coord_top_left = top_left or (0, 1)
            self._coord_bottom_right = bottom_right or (1, 0)
        else:
            dimensions = (self.domain.dimensions[0] - 1, self.domain.dimensions[1] - 1)
            unit_size_x = 0.5 * float(bottom_right[0] - top_left[0]) / dimensions[1]
            unit_size_y = 0.5 * float(top_left[1] - bottom_right[1]) / dimensions[0]
            self._coord_top_left = (top_left[0] - unit_size_x, top_left[1] + unit_size_y)
            self._coord_bottom_right = (bottom_right[0] + unit_size_x, bottom_right[1] - unit_size_y)

        self._np_vertex_data = np.array(
            [
                self._coord_top_left[0],
                self._coord_top_left[1],
                self._coord_top_left[0],
                self._coord_bottom_right[1],
                self._coord_bottom_right[0],
                self._coord_bottom_right[1],
                self._coord_bottom_right[0],
                self._coord_bottom_right[1],
                self._coord_bottom_right[0],
                self._coord_top_left[1],
                self._coord_top_left[0],
                self._coord_top_left[1],
            ],
            dtype=np.float32,
        ).reshape(6, 2)

        self.vertex_array = VertexArray(
            {
                "vertex_position": VertexBuffer.from_numpy(self._np_vertex_data),
                "texture_position": VertexBuffer.from_numpy(self._np_texture_data),
            },
            self.program.attributes,
        )

        self.top_left = top_left
        self.bottom_right = bottom_right
コード例 #3
0
    def init_shader(self):
        self.program = Program()
        self.program.shaders.append(Shader(GL_VERTEX_SHADER, load_lib_file('glsl/plot2d/axis/marker_y.vert.glsl')))
        self.program.shaders.append(Shader(GL_GEOMETRY_SHADER, load_lib_file('glsl/plot2d/axis/marker_y.geom.glsl')))
        self.program.shaders.append(Shader(GL_FRAGMENT_SHADER, load_lib_file('glsl/plot2d/axis/marker.frag.glsl')))
        self.program.link()

        self.program.uniform('color', self.linecolor)

        self.vao = VertexArray({
            'vertex_position': VertexBuffer.from_numpy(self.measurements)
        }, self.program.attributes)
コード例 #4
0
 def _init_vbo(self):
     self._vbo = VertexBuffer.from_numpy(self._data)
コード例 #5
0
 def _init_vbo(self):
     """
     initialized vbo
     """
     self._vbo = VertexBuffer.from_numpy(self._data)