Skip to content

Commit

Permalink
Test for drawing mask contour on a transparent background.
Browse files Browse the repository at this point in the history
  • Loading branch information
m000 committed Jun 6, 2018
1 parent b58eae9 commit 127dd7f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/test_wordcloud.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from wordcloud import WordCloud, get_single_color_func, ImageColorGenerator
import os
import numpy as np
from random import Random
from nose.tools import (assert_equal, assert_greater, assert_true, assert_false,
Expand Down Expand Up @@ -229,6 +230,18 @@ def test_mask_contour():
assert_true(all(sm_array[100, 300] == [0, 0, 255]))


def test_test_mask_contour_transparent():
# test if mask contour can be drawn on a transparent background
# https://github.com/amueller/word_cloud/pull/389
examples_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'examples'))
mask_file = os.path.join(examples_dir, 'alice_mask.png')
mask = np.array(Image.open(mask_file))
w = WordCloud(mode='RGBA', background_color=None, contour_color='blue', contour_width=2, mask=mask,
max_words=50, width=800, height=800)
w.generate(THIS)
w.to_file(NamedTemporaryFile(suffix=".png").name)


def test_single_color_func():
# test single color function for different color formats
random = Random(42)
Expand Down

0 comments on commit 127dd7f

Please sign in to comment.