Coder Social home page Coder Social logo

gdinit / mask_word_cloud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from salvaeb/mask_word_cloud

0.0 0.0 0.0 2.58 MB

Word cloud cairo-based command line generator (png, pdf and svg) using a shape mask.

License: GNU Lesser General Public License v3.0

C++ 98.11% Makefile 1.89%

mask_word_cloud's Introduction

mask_word_cloud

Word cloud cairo-based command line generator (png, pdf and svg) using a shape mask.

A little word cloud generator in C++ using cairomm. For the moment the part related with word processing is very rudimentary (you should better produce the expected word file with another program).

Installation and Compiling

I have only tried on linux debian/ubuntu, you need first install:

sudo apt-get install libcairomm-1.0-dev

and try just

make

that will hopefully generate the maskwd executable:

$ make
g++ -std=c++11 -O3 -c mask_word_cloud.cc `pkg-config --cflags --libs cairomm-1.0`
g++ -std=c++11 -O3 -o maskwc maskwc.cc mask_word_cloud.o `pkg-config --cflags --libs cairomm-1.0`

Usage

There are several optional parameters:

$ ./maskwc -h
Usage: ./maskwc \
	[-h] \ (show this help)
	[-r red_background] \   (RGB of background, default 0 0 0 black
	[-g green_background] \  color components in scale 0-255
	[-b blue_background] \
	[-m mask_file] \ (determines also the size of image)
	[-R red_mask] \   (words can be painted where mask
	[-G green_mask] \  has this RGB color, default 0 0 0 black)
	[-B blue_mask] \
	[-c color_file] \ (must have the same size of mask, words colors are picked from here)
	[-f font_name] \  (e.g. Sans)
	[-s font_step] \  (default value 2, 1 is somewhat slower but more accurate)
	[-M min_font_size] \ (default value 4)
	[-o output_prefix] \ (default "output" generate "output.svg" "output.png" and "output.pdf") 
	[-d words_margin] \ (default value is 2)
	[-v vertical_preference] \ (value between 0 and 100, default is 50)
	words.txt (an ordered list of pairs word initial_size)

Try these parameter with the examples to better see how they work.

Examples

The following mask:

alice_mask.png

has been taken from this other word cloud repository.

The file peace.txt contains a sorted list of utf-8 encoded words accompanied with an initial size, this is very rudimentary and could be greatly improved:

$ cat peace.txt
peace 300
paz 300
pace 250
pau 100
paz 200
Frieden 100
...

The following output:

alice_peace.png

Is generated with the following command:

../maskwc -m alice_mask.png -r 30 -g 40 -b 30 -o alice_peace peace.txt

Although it is better to check the svg and pdf files.

You can also specify the color used as mask in order to generate, for instance, a word cloud for the background:

../maskwc -m alice_mask.png -R 255 -G 255 -B 255 -o background_alice peace.txt

background_alice.png

and the corresponding svg and pdf files.

mask_word_cloud's People

Contributors

salvaeb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.