Coverage for tatlin/lib/gl/util.py: 100%
16 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 05:56 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 05:56 +0000
1# -*- coding: utf-8 -*-
2# Copyright (C) 2011 Denis Kobozev
3#
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software Foundation,
16# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19from OpenGL.GL import * # type:ignore
20from OpenGL.GLE import * # type:ignore
23def compile_display_list(func, *options):
24 display_list = glGenLists(1)
25 glNewList(display_list, GL_COMPILE)
26 func(*options)
27 glEndList()
28 return display_list
31def paginate(sequence, n):
32 """
33 Yield n-sized pieces of sequence.
34 """
35 for i in range(0, len(sequence), n):
36 yield sequence[i : i + n]
39def html_color(color):
40 if color.startswith("#"):
41 color = color[1:]
42 parsed = [int(c, 16) / 255 for c in paginate(color, 2)]
43 return parsed