https://github.com/zjzmisaka/tagcloudgenerator
TagCloudGenerator is a C# library that allows you to generate a tag cloud bitmap image from a given set of strings and their corresponding weights. You can customize the appearance of the tag cloud by specifying various options, such as font size, font color, background color, and more.
https://github.com/zjzmisaka/tagcloudgenerator
bitmap csharp image tag-cloud tagcloud word-cloud wordcloud
Last synced: 5 months ago
JSON representation
TagCloudGenerator is a C# library that allows you to generate a tag cloud bitmap image from a given set of strings and their corresponding weights. You can customize the appearance of the tag cloud by specifying various options, such as font size, font color, background color, and more.
- Host: GitHub
- URL: https://github.com/zjzmisaka/tagcloudgenerator
- Owner: ZjzMisaka
- License: other
- Created: 2023-02-26T04:47:08.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-27T02:49:42.000Z (about 2 years ago)
- Last Synced: 2023-07-27T03:35:52.636Z (about 2 years ago)
- Topics: bitmap, csharp, image, tag-cloud, tagcloud, word-cloud, wordcloud
- Language: C#
- Homepage:
- Size: 113 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TagCloudGenerator
Generates a tag cloud bitmap using weighted strings and customizable options for font size, color, background, and more.
### Download
TagCloudGenerator is available as [Nuget Package](https://www.nuget.org/packages/TagCloudGenerator/) now.## Sample Images
Below are some sample images showing the output of the TagCloudGenerator:
![]()
![]()
## Getting Started
You can use the TagCloudGenerator library by following these steps:
1. Create a dictionary of strings and their corresponding weights. The weights can be set to the number of occurrences of each string.
```csharp
Dictionary tagDic = new Dictionary();
tagDic["J.C.STAFF"] = 32;
```2. Create a `TagCloudOption` object, and set its properties as needed.
```csharp
TagCloudOption tagCloudOption = new TagCloudOption();
// Set tagCloudOption properties
// tagCloudOption.Xxx = xxx;
```3. If you want to specify special settings for individual characters, create a dictionary of `TagOption` objects.
```csharp
Dictionary tagOptionDic = new Dictionary();
// Set option for single text
// tagOptionDic["J.C.STAFF"] = new TagOption() { Rotate = new Rotate(0) };
```4. Create a `TagCloud` object using the dictionaries and the `TagCloudOption` object, and then call the `Get()` method to generate the bitmap image.
```csharp
Bitmap bmp = new TagCloud(tagDic, tagCloudOption, tagOptionDic).Get();
```If you don't need to specify special settings for individual characters, you can omit the `tagOptionDic` parameter:
```csharp
Bitmap bmp = new TagCloud(tagDic, tagCloudOption).Get();
```## TagCloudOption Properties
The `TagCloudOption` object allows you to customize various aspects of the tag cloud. Below is a list of its properties and their descriptions:
|Property|Description|
|--|--|
|Range RandomRotateRange|If not null, take random values from RandomRotateRange|
|List\ RotateList|If RandomRotateRange is null, take rotate randomly from RotateList|
|int TagSpacing|Minimum pixel spacing between adjacent tags|
|int HorizontalOuterMargin|Minimum horizontal outer margin|
|int VerticalOuterMargin|Minimum vertical outer margin|
|List\ FontColorList|Set possible font colors for bitmap tags|
|ColorOption BackgroundColor|Set background color for bitmap tags|
|FontFamily FontFamily|Set font family for bitmap tags|
|Range FontSizeRange|Set minimum and maximum font sizes|
|double AngleStep|Set angle step for spiral algorithm|
|double RadiusStep|Set radius step for spiral algorithm|
|double AngleDecreaseFactor|Angle step decreasing factor|
|double RadiusDecreaseFactor|Radius step decreasing factor|
|bool IsRandomInitAngle|Set if is random init angle or not for spiral algorithm|
|int HorizontalCanvasGrowthStep|Horizontal canvas growth step|
|int VerticalCanvasGrowthStep|Vertical canvas growth step|
|ImgSize OutputSize|Output bitmap image size|
|ImgSize InitSize|Init bitmap image size, the canvas will grow when the canvas is filled|
|string MaskPath|If you need to generate a tag cloud through masking, set the path for the masking image|
|bool ShowMask|Set whether to display mask image in generated bitmap image|
|bool StretchMask|Set whether to stretch the mask to match the canvas|
|int Accuracy|Accuracy of TagSpacing check, default = 1, if =0 then check all pixel. It is used to increase operating efficiency|## TagOption Properties
The `TagOption` object allows you to specify special settings for individual charactersin the tag cloud. Below is a list of its properties and their descriptions:
|Property|Description|
|--|--|
|Rotate Rotate|Rotate of tag|
|FontColor FontColor|FontColor of tag|
|FontFamily FontFamily|FontFamily of tag|## License
This project is licensed under the [OMSPL](https://github.com/ZjzMisaka/TagCloudGenerator/blob/main/LICENSE).