Giter Club home page Giter Club logo

carbon-api's Introduction

Carbon API


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.

Contents

How It Works

  1. Creates a URI from the specified arguments.
  2. Uses Microsoft Playwright to visit the created URI.
  3. Screenshots the created image.

Using Carbon API

Java versions 11 and up are supported.

Latest stable release:

Gradle

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'
}

Documentation

The latest Javadoc is available here.

Dependencies

  • Playwright
    • GitHub
    • Playwright requires various dependencies to install browsers, see the docs.

Style

The IntelliJ code style files, which are a fork of the Google Java Style Guide, are stored in the .idea/codeStyles directory.

carbon-api's People

Contributors

jacobmstein avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

gishankrishka2

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.