Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
word_cloud_est
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
keeleliin
word_cloud_est
Commits
ccdb542c
Commit
ccdb542c
authored
Dec 05, 2015
by
Raphael Boidol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove PIL deprecation warnings by using new API
parent
bef83e5a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
8 deletions
+6
-8
examples/a_new_hope.py
examples/a_new_hope.py
+1
-1
examples/colored.py
examples/colored.py
+1
-1
examples/masked.py
examples/masked.py
+1
-1
wordcloud/wordcloud.py
wordcloud/wordcloud.py
+3
-5
No files found.
examples/a_new_hope.py
View file @
ccdb542c
...
...
@@ -6,7 +6,7 @@ Using the recolor method and custom coloring functions.
"""
import
numpy
as
np
import
Image
from
PIL
import
Image
from
os
import
path
import
matplotlib.pyplot
as
plt
import
random
...
...
examples/colored.py
View file @
ccdb542c
...
...
@@ -11,7 +11,7 @@ but make sure the image shapes line up.
"""
from
os
import
path
import
Image
from
PIL
import
Image
import
numpy
as
np
import
matplotlib.pyplot
as
plt
...
...
examples/masked.py
View file @
ccdb542c
...
...
@@ -6,7 +6,7 @@ Using a mask you can generate wordclouds in arbitrary shapes.
"""
from
os
import
path
import
Image
from
PIL
import
Image
import
numpy
as
np
import
matplotlib.pyplot
as
plt
...
...
wordcloud/wordcloud.py
View file @
ccdb542c
...
...
@@ -289,9 +289,8 @@ class WordCloud(object):
orientation
=
Image
.
ROTATE_90
transposed_font
=
ImageFont
.
TransposedFont
(
font
,
orientation
=
orientation
)
draw
.
setfont
(
transposed_font
)
# get size of resulting text
box_size
=
draw
.
textsize
(
word
)
box_size
=
draw
.
textsize
(
word
,
font
=
transposed_font
)
# find possible places using integral image:
result
=
occupancy
.
sample_position
(
box_size
[
1
]
+
self
.
margin
,
box_size
[
0
]
+
self
.
margin
,
...
...
@@ -307,7 +306,7 @@ class WordCloud(object):
x
,
y
=
np
.
array
(
result
)
+
self
.
margin
//
2
# actually draw the text
draw
.
text
((
y
,
x
),
word
,
fill
=
"white"
)
draw
.
text
((
y
,
x
),
word
,
fill
=
"white"
,
font
=
transposed_font
)
positions
.
append
((
x
,
y
))
orientations
.
append
(
orientation
)
font_sizes
.
append
(
font_size
)
...
...
@@ -433,9 +432,8 @@ class WordCloud(object):
font
=
ImageFont
.
truetype
(
self
.
font_path
,
font_size
*
self
.
scale
)
transposed_font
=
ImageFont
.
TransposedFont
(
font
,
orientation
=
orientation
)
draw
.
setfont
(
transposed_font
)
pos
=
(
position
[
1
]
*
self
.
scale
,
position
[
0
]
*
self
.
scale
)
draw
.
text
(
pos
,
word
,
fill
=
color
)
draw
.
text
(
pos
,
word
,
fill
=
color
,
font
=
transposed_font
)
return
img
def
recolor
(
self
,
random_state
=
None
,
color_func
=
None
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment