Skip to content

Commit

Permalink
add logo
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyongzhi authored and guo-yong-zhi committed Jul 21, 2021
1 parent c4f6807 commit 27a2907
Show file tree
Hide file tree
Showing 9 changed files with 208 additions and 45 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [WordCloud.jl](https://github.com/guo-yong-zhi/WordCloud.jl)
# <div><img src="docs/src/assets/logo.svg" height="25px"><span> [WordCloud.jl](https://github.com/guo-yong-zhi/WordCloud.jl)</span></div>
![juliadoc](res/juliadoc.png)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://guo-yong-zhi.github.io/WordCloud.jl/dev) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/guo-yong-zhi/WordCloud.jl/master?filepath=examples.ipynb) [![CI](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci.yml) [![CI-nightly](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci-nightly.yml/badge.svg)](https://github.com/guo-yong-zhi/WordCloud.jl/actions/workflows/ci-nightly.yml) [![codecov](https://codecov.io/gh/guo-yong-zhi/WordCloud.jl/branch/master/graph/badge.svg?token=2U0X769Z51)](https://codecov.io/gh/guo-yong-zhi/WordCloud.jl)
Word cloud (tag cloud or wordle) is a novelty visual representation of text data. The importance of each word is shown with font size or color. Our generator has the following highlights:
Expand Down Expand Up @@ -51,7 +51,7 @@ paint(wc, "alice.png", ratio=0.5, background=outline(wc.mask, color="purple", li
*Run the command `runexample(:recolor)` or `showexample(:recolor)` to get the result.*
## Semantic
[![semantic](res/semantic.png)](./examples/semantic.jl)
*Run the command `runexample(:semantic)` or `showexample(:semantic)` to get the result.*
*Run the command `runexample(:semantic)` or `showexample(:semantic)` to get the result.*
*The variable `WordCloud.examples` holds all available examples.*
You can also [**see more examples**](https://github.com/guo-yong-zhi/WordCloud-Gallery) or [**try it online**](https://mybinder.org/v2/gh/guo-yong-zhi/WordCloud.jl/master?filepath=examples.ipynb).
# Algorithm Description
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Documenter.makedocs(
modules = Module[WordCloud],
repo = "",
highlightsig = true,
sitename = "WordCloud Documentation",
sitename = "WordCloud.jl",
expandfirst = [],
pages = [
"Index" => "index.md",
Expand Down
135 changes: 135 additions & 0 deletions docs/src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ Pkg.add("WordCloud")
Modules = [WordCloud]
```

## Index
## Gallery
* [WordCloud-Gallery](https://github.com/guo-yong-zhi/WordCloud-Gallery)

## Index
```@index
```
36 changes: 36 additions & 0 deletions examples/logo.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#md# It is the code to draw this repo's logo
using WordCloud
Luxor = WordCloud.Render.Luxor

function cloudshape(height, args...; backgroundcolor=(0,0,0,0))
height = ceil(height)
r = height / 2
d = Luxor.Drawing((2height, height)..., :svg)
Luxor.origin()
Luxor.background(parsecolor(backgroundcolor))
Luxor.setcolor(parsecolor((0.22,0.596,0.149)))
Luxor.pie(0, 0, r, 0, 2π, :fill)
Luxor.setcolor(parsecolor((0.584,0.345,0.698)))
Luxor.pie(r, r, r, -π, 0, :fill)
Luxor.setcolor(parsecolor((0.796,0.235,0.20)))
Luxor.Luxor.pie(-r, r, r, -π, 0, :fill)
Luxor.finish()
d
end
wc = wordcloud(
repeat(string.('a':'z'), 5),
repeat([1], 26*5),
mask = cloudshape(500),
transparent = (0,0,0,0),
colors = 1,
angles = -90:0,
font = "JuliaMono Black",
density=0.77,
)
generate!(wc, 2000, retry=1)
recolor!(wc, style=:main)
println("results are saved to logo.svg")
paint(wc, "logo.svg", background=false)
wc
#eval# runexample(:logo)
#md# ![](logo.svg)
2 changes: 1 addition & 1 deletion src/artist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function randomellipse(w, h; kargs...)
return shape(ellipse, w, h; kargs...)
end
function randomangles()
a = rand((-1, 1)) .* rand((0, (0,90), (0,90,45), (0,90,45,-45), (0,45,-45), (45,-45), -90:90))
a = rand((-1, 1)) .* rand((0, (0,90), (0,90,45), (0,90,45,-45), (0,45,-45), (45,-45), -90:90, 0:90))
println("angles = ", a)
a
end
Expand Down
4 changes: 2 additions & 2 deletions src/textprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ function countwords(words::AbstractVector{<:AbstractString};
m = match(regexp, w)
if m !== nothing
w = m.match
counter[w] = get!(counter, w, 0) + 1
counter[w] = get(counter, w, 0) + 1
end
else
counter[w] = get!(counter, w, 0) + 1
counter[w] = get(counter, w, 0) + 1
end
end
counter
Expand Down
33 changes: 28 additions & 5 deletions src/wc-method.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,29 @@ end

recolor_reset!(wc, i::Integer) = initword!(wc, i)
recolor_reset!(wc, w=:; kargs...) = recolor_reset!.(wc, index(wc, w); kargs...)

function counter(iter; C = Dict{eltype(iter), Int}())
for e in iter
C[e] = get(C, e, 0) + 1
end
C
end
function mostfrequent(iter; C = Dict{eltype(iter), Int}())
C = counter(iter; C = C)
argmax(C)
end
function recolor_main!(wc, i::Integer; background=getmask(wc))
bg = ARGB.(background)
img = getimages(wc, i)
x,y = getpositions(wc, i)
bg, img = Render.overlappingarea(bg, img, x, y)
m = wordmask(img, (0,0,0,0),0)
bkv = @view bg[m]
c = mostfrequent(bkv)
initword!(wc, i, color=c)
end
recolor_main!(wc, w=:; kargs...) = recolor_main!.(wc, index(wc, w); kargs...)
function recolor_average!(wc, i::Integer; background=getmask(wc))
bg = background
bg = ARGB.(background)
img = getimages(wc, i)
x,y = getpositions(wc, i)
bg, img = Render.overlappingarea(bg, img, x, y)
Expand Down Expand Up @@ -157,19 +177,22 @@ end
recolor_clipping!(wc, w=:; kargs...) = recolor_clipping!.(wc, index(wc, w); kargs...)
"""
recolor the words in `wc` in different styles with the background picture.
The styles supported are `:average`, `:clipping`, `:blending`, and :reset (to undo all effects of others).
The styles supported are `:average`, `:main`, `:clipping`, `:blending`, and :reset (to undo all effects of others).
e.g.
* recolor!(wc, style=:average) # `background` is optional
* recolor!(wc, style=:average)
* recolor!(wc, style=:mian)
* recolor!(wc, style=:clipping, background=blur(getmask(wc))) # `background` is optional
* recolor!(wc, style=:blending, alpha=0.3) # `background` and `alpha` are optional
* recolor!(wc, style=:reset)
The effects of `:average` and `:clipping` are only determined by the `background`. But the effect of `:blending` is also affected by the previous word color. Therefore, `:blending` can also be used in combination with others
The effects of `:average`, `:main` and `:clipping` are only determined by the `background`. But the effect of `:blending` is also affected by the previous word color. Therefore, `:blending` can also be used in combination with others
The results of `clipping` and `blending` can not be exported as SVG files, use PNG instead.
"""
function recolor!(wc, args...; style=:average, kargs...)
if style == :average
recolor_average!(wc, args...; kargs...)
elseif style == :main
recolor_main!(wc, args...; kargs...)
elseif style == :blending
recolor_blending!(wc, args...; kargs...)
elseif style == :clipping
Expand Down
33 changes: 0 additions & 33 deletions test/Manifest.toml

This file was deleted.

2 comments on commit 27a2907

@guo-yong-zhi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/41265

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.7.3 -m "<description of version>" 27a2907629509ca506550ab5c7414c79c3a2281f
git push origin v0.7.3

Please sign in to comment.