Beispiel #1
0
    def test_clip_between_boundaries_value_too_dark(self):
        clipped = clip_between_boundaries(dark_red_hsl, black_hsl, white_hsl,
                                          4.5, 1)[0]
        clipped_contrast_black = contrast_between(clipped, black_hsl)
        clipped_contrast_white = contrast_between(clipped, white_hsl)

        self.assertEqual(clipped[0], 0)
        self.assertEqual(clipped[1], 1)
        self.assertTrue(0.4 < clipped[2] < 0.6)
        self.assertTrue(4.5 <= clipped_contrast_black <= 5)
        self.assertTrue(clipped_contrast_white >= 1)
Beispiel #2
0
    def test_clip_between_boundaries_value_too_light(self):
        clipped = clip_between_boundaries(light_red_hsl, black_hsl, white_hsl,
                                          4.5, 4.5)[0]
        clipped_contrast_black = contrast_between(clipped, black_hsl)
        clipped_contrast_white = contrast_between(clipped, white_hsl)

        self.assertEqual(clipped[0], 0)
        self.assertEqual(clipped[1], 1)
        self.assertTrue(0.4 < clipped[2])
        self.assertTrue(4.5 <= clipped_contrast_black)
        self.assertTrue(4.5 <= clipped_contrast_white <= 5)
Beispiel #3
0
    # dark theme settings
    min_dark_contrast = 0.4
    min_light_contrast = 0.1

    # light theme settings
    if (bg_color[0][2] > 0.5):
        min_dark_contrast = 0.1
        min_light_contrast = 0.4

    ansi_colors_unconstrained = pick_n_best_colors(8, improved_centers,
                                                   dominant_dark,
                                                   dominant_light,
                                                   min_dark_contrast,
                                                   min_light_contrast)
    ansi_colors_normal = clip_between_boundaries(ansi_colors_unconstrained,
                                                 dominant_dark, dominant_light)
    ansi_colors_normal_and_bright = generate_complementary(ansi_colors_normal)
    ansi_colors = ansi_colors_normal_and_bright  # shorthand
    # ansi_colors, bg_color = custom_filter_and_sort_complements(improved_centers, bg_fg_colors[0])

    html_contents += get_html_contents(ansi_colors,
                                       np.vstack((bg_color, fg_color)),
                                       img_file_path)
    html = "<body style='background: #000'>\n"
    html += "<div>"
    html += html_contents
    html += "</div>"
    html += "</body>\n"

    result_file = open("examples.html", "w")
    result_file.write(html)
Beispiel #4
0
 def test_clip_between_boundaries_good_value(self):
     clipped = clip_between_boundaries(red_hsl, black_hsl, white_hsl, 1,
                                       1)[0]
     self.assertEqual(clipped[0], red_hsl[0])
     self.assertEqual(clipped[1], red_hsl[1])
     self.assertEqual(clipped[2], red_hsl[2])