An unofficial Java API for Carbon. Create and share beautiful images of your source code, dynamically, with Java!
CarbonService carbon = new PlaywrightCarbonService();
ImageOptions options = new ImageOptions.ImageOptionsBuilder()
.language(ImageOptions.Language.CSharp)
.fontFamily(ImageOptions.FontFamily.JetBrainsMono)
.theme(ImageOptions.Theme.Hopscotch)
.build();
String code = "Console.WriteLine(\"Hello, world!\");";
byte[] image = carbon.getImage(code, options);
// or, read code from a file
image = carbon.getImage(new File("README.md"), options);
Want to use Carbon with Discord? Check out Carbon Bot.
- Creates a URI from the specified arguments.
- Uses Microsoft Playwright to visit the created URI.
- Screenshots the created image.
Java versions 11 and up are supported.
Latest stable release:
Just include the following in your build.gradle
file:
Replace
VERSION
with a valid Maven release.
repositories {
mavenCentral()
}
dependencies {
implementation 'sh.stein:carbon-api:VERSION'
}
The latest Javadoc is available here.
The IntelliJ code style files, which are a fork of
the Google Java Style Guide, are stored in
the .idea/codeStyles
directory.