mirror of
https://github.com/simon-brooke/clj-wordcloud.git
synced 2026-01-12 22:49:52 +00:00
Add support for custom bitmaps and docs
This commit is contained in:
parent
48f5ddc293
commit
8f76e1175a
10 changed files with 206 additions and 27 deletions
BIN
examples/backgrounds/haskell_1.bmp
Normal file
BIN
examples/backgrounds/haskell_1.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 994 KiB |
BIN
examples/backgrounds/haskell_2.bmp
Normal file
BIN
examples/backgrounds/haskell_2.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 994 KiB |
BIN
examples/example_circle.png
Normal file
BIN
examples/example_circle.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 173 KiB |
BIN
examples/example_haskell.png
Normal file
BIN
examples/example_haskell.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
|
|
@ -1,7 +1,47 @@
|
|||
(ns examples
|
||||
(:require '[clj-wordcloud.core :refer :all]))
|
||||
|
||||
(let [frequency-map (zipmap (range 100 130) (range 300))]
|
||||
(word-cloud frequency-map
|
||||
{:background {:type :circle :size 300}
|
||||
:filename "sample.png" :font-y 100 :padding 10}))
|
||||
|
||||
(defn random-words
|
||||
[n]
|
||||
(->> "/usr/share/dict/words"
|
||||
slurp
|
||||
clojure.string/lower-case
|
||||
clojure.string/split-lines
|
||||
shuffle
|
||||
(take n)))
|
||||
|
||||
|
||||
(let [frequency-map (zipmap (random-words 100) (shuffle (range 300)))
|
||||
word-cloud (word-cloud frequency-map
|
||||
{:dimension {:width 600
|
||||
:height 600}
|
||||
:background {:type :circle
|
||||
:size 300
|
||||
:color "0x000000"}
|
||||
:font {:type "Calibre"
|
||||
:weight :plain
|
||||
:scale-type :linear
|
||||
:x-scale 20
|
||||
:y-scale 20
|
||||
:padding 5}})]
|
||||
(write-to-file word-cloud "example_circle.png"))
|
||||
|
||||
|
||||
(let [frequency-map (zipmap (range 100 150) (shuffle (range 300)))
|
||||
word-cloud (word-cloud frequency-map
|
||||
{:dimension {:width 600
|
||||
:height 600}
|
||||
:background {:type :pixel
|
||||
:size 300
|
||||
:color "0x000000"
|
||||
:bitmap "examples/backgrounds/haskell_1.bmp"}
|
||||
:font {:type "Calibre"
|
||||
:weight :plain
|
||||
:scale-type :linear
|
||||
:x-scale 20
|
||||
:y-scale 20
|
||||
:padding 5
|
||||
:colors ["0x00FF00" "0x0000FF" "0xFFAFFF"
|
||||
"0xFFEEFF" "0xEEEEEE"]}})]
|
||||
(write-to-file word-cloud "example_haskell.png"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue