Package com.codename1.art


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.

  • Class
    Description
    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.
    An artwork: a canvas size and a tree of nodes.
    A simple vector and raster editor: an ArtView with a tool bar, a layers panel and an inspector.
    Maps the font families an artwork names to Codename One fonts.
    Opens a graphics document in whichever format it is: PSD or PSB, SVG, Sketch, .cn1gfx, or Figma REST API JSON.
    Encodes rasters as PNG and decodes PNG, JPEG and other image bytes into rasters.
    Notified when an ArtModel changes: an edit, an undo, a redo or a new selection.
    An editable, undoable ArtDocument with a selection.
    One element of an artwork: a group, shape, text, image or adjustment layer.
    What fills a shape, a stroke or text: a color, a gradient or an image.
    Paints an ArtDocument into pixels.
    Shows an ArtModel's document, with panning, pinch zoom, hit testing and the selection drawn over it.
    Receives pointer events in document coordinates.
    How a layer's colors combine with what is already painted below it.
    Parses and formats CSS colors.
    Software compositing of ARGB pixel arrays.
    Fetches a file from Figma's REST API and reads it into an ArtDocument.
    Reads a Figma file from the JSON of Figma's REST API (GET /v1/files/:key) into an ArtDocument.
    A linear, radial or conic gradient.
    A node that holds other nodes, painted first to last.
    Fills with an image, stretched or tiled.
    Something a reader met that it could not represent exactly, such as an SVG animation.
    An immutable 2D affine transform, in SVG's matrix(a b c d e f) order.
    The .cn1gfx container: a ZIP holding document.json and every raster as a PNG under images/.
    Parses SVG path data (the d attribute) into a GeneralPath.
    Reads Photoshop PSD and PSB files into an ArtDocument.
    Writes an ArtDocument as a layered Photoshop PSD: RGB, 8 bits per channel, RLE.
    A rectangle of non-premultiplied 0xAARRGGBB pixels with a position.
    A bitmap layer.
    A vector shape: a path with any number of fills and strokes, painted in order.
    Paths for the basic shapes.
    Reads Sketch files (Sketch 43 and later: a ZIP of JSON) into an ArtDocument.
    A single color.
    How a shape's outline is drawn: paint, width, caps, joins, dashes and alignment.
    Reads SVG 1.1 and SVG 2 static documents into an ArtDocument.
    Loads what an href names.
    Writes an ArtDocument as SVG.
    Styled text.
    A stretch of text with one style.