Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
package com.codename1.art
Layered artwork: vector shapes, text and raster layers that can be loaded, rendered, changed and saved.
An ArtDocument holds a tree of ArtNodes. Each node has its own transform, opacity,
BlendMode and effects. SVG, Photoshop PSD, Sketch and Figma (REST API JSON) documents
are read into the same tree. SVG and PSD can also be written back, and NativeFormat
saves everything losslessly.
byte[] data = "<svg xmlns='http://www.w3.org/2000/svg' width='80' height='80'><rect width='80' height='80' fill='#43a047'/></svg>".getBytes("UTF-8");
ArtDocument doc = ArtFormats.read(data); // SVG, PSD, Sketch, Figma or .cn1gfx
Image preview = ArtRenderer.toImage(doc, 2); // two pixels per document unit
ArtEditor editor = new ArtEditor(new ArtModel(doc));Rendering is done in software by ArtRenderer, so a document looks the same on every
platform. Every effect a supported format defines is rendered: layer styles, blurs,
adjustment layers, masks, clipping and all blend modes. What a reader cannot represent is
recorded as an ImportNote on the document rather than dropped silently.
ArtModel makes a document editable with undo, ArtView shows one with pan, zoom and hit
testing, and ArtEditor is a ready-made drawing editor over both. ArtImages.renderSvg is what
Image.createSVG answers on platforms with no native SVG support.
Types
class AdjustmentNode | An adjustment layer: changes the colors of everything painted below it in the same group, as Photoshop’s levels, curves or hue/saturation layers do. |
class ArtDocument | An artwork: a canvas size and a tree of nodes. |
class ArtEditor | A simple vector and raster editor: an ArtView with a tool bar, a layers panel and an inspector. |
class ArtFonts | Maps the font families an artwork names to Codename One fonts. |
class ArtFormats | Opens a graphics document in whichever format it is: PSD or PSB, SVG, Sketch, .cn1gfx, or Figma REST API JSON. |
class ArtImages | Encodes rasters as PNG and decodes PNG, JPEG and other image bytes into rasters. |
interface ArtListener | Notified when an ArtModel changes: an edit, an undo, a redo or a new selection. |
class ArtModel | An editable, undoable ArtDocument with a selection. |
class ArtNode | One element of an artwork: a group, shape, text, image or adjustment layer. |
class ArtPaint | What fills a shape, a stroke or text: a color, a gradient or an image. |
class ArtRenderer | Paints an ArtDocument into pixels. |
class ArtView | Shows an ArtModel’s document, with panning, pinch zoom, hit testing and the selection drawn over it. |
enum BlendMode | How a layer’s colors combine with what is already painted below it. |
class Colors | Parses and formats CSS colors. |
class Compositor | Software compositing of ARGB pixel arrays. |
class FigmaClient | Fetches a file from Figma’s REST API and reads it into an ArtDocument. |
class FigmaReader | Reads a Figma file from the JSON of Figma’s REST API (GET /v1/files/:key) into an ArtDocument. |
class GradientPaint | A linear, radial or conic gradient. |
class GroupNode | A node that holds other nodes, painted first to last. |
class ImagePaint | Fills with an image, stretched or tiled. |
class ImportNote | Something a reader met that it could not represent exactly, such as an SVG animation. |
class Matrix | An immutable 2D affine transform, in SVG’s matrix(a b c d e f) order. |
class NativeFormat | The .cn1gfx container: a ZIP holding document.json and every raster as a PNG under images/. |
class PathData | Parses SVG path data (the d attribute) into a GeneralPath. |
class PsdReader | Reads Photoshop PSD and PSB files into an ArtDocument. |
class PsdWriter | Writes an ArtDocument as a layered Photoshop PSD: RGB, 8 bits per channel, RLE. |
class Raster | A rectangle of non-premultiplied 0xAARRGGBB pixels with a position. |
class RasterNode | A bitmap layer. |
class ShapeNode | A vector shape: a path with any number of fills and strokes, painted in order. |
class Shapes | Paths for the basic shapes. |
class SketchReader | Reads Sketch files (Sketch 43 and later: a ZIP of JSON) into an ArtDocument. |
class SolidPaint | A single color. |
class StrokeStyle | How a shape’s outline is drawn: paint, width, caps, joins, dashes and alignment. |
class SvgReader | Reads SVG 1.1 and SVG 2 static documents into an ArtDocument. |
class SvgWriter | Writes an ArtDocument as SVG. |
class TextNode | Styled text. |
class TextRun | A stretch of text with one style. |