当前位置: 首页>>代码示例>>Python>>正文


Python Color.get_hex_l方法代码示例

本文整理汇总了Python中colour.Color.get_hex_l方法的典型用法代码示例。如果您正苦于以下问题:Python Color.get_hex_l方法的具体用法?Python Color.get_hex_l怎么用?Python Color.get_hex_l使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在colour.Color的用法示例。


在下文中一共展示了Color.get_hex_l方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _marks_to_excel

# 需要导入模块: from colour import Color [as 别名]
# 或者: from colour.Color import get_hex_l [as 别名]
    def _marks_to_excel(data):
        """
        :type discipline: students.models.Discipline
        :type group: students.models.Group
        """
        from students.models.group import Group
        # data = json.loads(json.loads(DisciplineMarksCache.get(discipline.pk, group.pk)))

        lessons = data['lessons']
        students = data['students']
        mark_types = data['mark_types']
        lesson_types = data['lesson_types']

        group = None
        if len(students) > 0:
            group = Group.objects.filter(pk=students[0]['group']).first()
        else:
            return ''

        students.sort(key=lambda s: s['sum'], reverse=True)

        # Create an in-memory output file for the new workbook.
        output = io.BytesIO()
        workbook = xlsxwriter.Workbook(output, {'in_memory': True})
        frmt_student = workbook.add_format()
        frmt_student.set_border()
        frmt_student.set_align('center')
        frmt_student.set_align('vcenter')
        frmt_student.set_rotation(90)
        frmt_student.set_text_wrap()

        frmt_header = workbook.add_format()
        frmt_header.set_border()
        frmt_header.set_align('center')
        frmt_header.set_align('vcenter')
        frmt_header.set_text_wrap()

        worksheet = workbook.add_worksheet(u"{}".format(group.title if group else u'студенты'))

        bg_colors = {
            # Mark.MARK_ABSENT: "#ffeeee",
            Mark.MARK_NORMAL: "#aef28c",
            Mark.MARK_GOOD: "#aef28c",
            Mark.MARK_EXCELLENT: "#4bb814",
            Mark.MARK_AWESOME: "#388a0f",
            Mark.MARK_FANTASTIC: "#255c0a",
            Mark.MARK_INCREDIBLE: "#3a4408",
            Mark.MARK_BLACK_HOLE: "black",
            Mark.MARK_SHINING: "yellow",
        }

        mark_formats = {}
        lesson_formts = {}

        # Подготовка стилей
        for lt in lesson_types:
            frmt = workbook.add_format()
            frmt.set_align('center')
            frmt.set_align('vcenter')
            frmt.set_text_wrap()
            frmt.set_border()

            if lt['id'] >= 2:
                bg_color = Color(bg_colors[Mark.MARK_NORMAL])
                bg_color.set_hue({
                                     2: 0.15,
                                     3: 0.5,
                                     4: 0.6,
                                     5: 0.8
                                 }.get(lt['id'], bg_color.get_hue()))

                frmt.set_bg_color(bg_color.get_hex_l())

            lesson_formts[lt['id']] = frmt

            for mt in mark_types:
                if mark_formats.get(lt['id']) is None:
                    mark_formats[lt['id']] = {}
                frmt = workbook.add_format()
                frmt.set_align('center')
                frmt.set_align('vcenter')
                frmt.set_border()

                bg_color = bg_colors.get(mt['k'], 'white')

                color = {
                    Mark.MARK_BLACK_HOLE: 'white',
                    Mark.MARK_AWESOME: 'white',
                    Mark.MARK_EXCELLENT: 'white',
                    Mark.MARK_FANTASTIC: 'white',
                    Mark.MARK_INCREDIBLE: 'white',
                }.get(mt['k'], 'black')

                bg_color = Color(bg_color)
                color = Color(color)

                if mt['k'] > 0:
                    if lt['id'] == 2:
                        bg_color.set_hue(0.15)
                        bg_color.set_luminance(min(bg_color.get_luminance() * 1.4, 0.9))
#.........这里部分代码省略.........
开发者ID:SevenLines,项目名称:django-tealeaf,代码行数:103,代码来源:discipline.py


注:本文中的colour.Color.get_hex_l方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。