kumo icon indicating copy to clipboard operation
kumo copied to clipboard

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

Open panglei1984 opened this issue 5 years ago • 2 comments

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<WordFrequency> 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

panglei1984 avatar Jan 21 '19 12:01 panglei1984

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"

kennycason avatar May 12 '20 00:05 kennycason

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

clover2024 avatar Apr 24 '21 11:04 clover2024