Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's invalid to setBackground with a picture,the result is always a rectangle background picture #81

Open
panglei1984 opened this issue Jan 21, 2019 · 2 comments

Comments

@panglei1984
Copy link

panglei1984 commented Jan 21, 2019

the code is ,

public static void gen() throws IOException {
final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer();
frequencyAnalyzer.setWordFrequenciesToReturn(70);
frequencyAnalyzer.setMinWordLength(3);
File f = new File("F:/temp/text.txt");
final List wordFrequencies = frequencyAnalyzer.load(new FileInputStream(f));
final Dimension dimension = new Dimension(500, 312);
final WordCloud wordCloud = new WordCloud(dimension, CollisionMode.PIXEL_PERFECT);
wordCloud.setPadding(2);
wordCloud.setBackground(new PixelBoundryBackground("F:/temp/whale.jpg"));
wordCloud.setColorPalette(new ColorPalette(new Color(0x4055F1), new Color(0x408DF1), new Color(0x40AAF1), new Color(0x40C5F1), new Color(0x40D3F1), new Color(0xFFFFFF)));
wordCloud.setFontScalar(new LinearFontScalar(10, 40));
wordCloud.build(wordFrequencies);
wordCloud.writeToFile("whale_wordcloud_small.png");
}

but,the background of whale_wordcloud_small.png is a rectangle ,not a whale.
could anyone know how to resolve it?thanks

@kennycason
Copy link
Owner

Hi, do you know if "whale.jpg" has transparent pixels or if the bg is just white? Kumo works by placing text where ever it finds transparent pixels. A future feature request may be supporting a TRANSPARENT_COLOR, so that we can say "white or some other color is considered transparent"

@clover2024
Copy link

clover2024 commented Apr 24, 2021

Hi! @kennycason , I want to involve in this issue by adding the feature offering user the option to transparentize the background of the picture without a transparent background. I have wrote some code to provide the feature and will do the PR later.
The PR: #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants