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.
-
ClassDescriptionAn 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
ArtViewwith 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 anArtModelchanges: an edit, an undo, a redo or a new selection.An editable, undoableArtDocumentwith 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 anArtDocumentinto pixels.Shows anArtModel'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 anArtDocument.Reads a Figma file from the JSON of Figma's REST API (GET /v1/files/:key) into anArtDocument.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'smatrix(a b c d e f)order.The.cn1gfxcontainer: a ZIP holdingdocument.jsonand every raster as a PNG underimages/.Parses SVG path data (thedattribute) into aGeneralPath.Reads Photoshop PSD and PSB files into anArtDocument.Writes anArtDocumentas a layered Photoshop PSD: RGB, 8 bits per channel, RLE.A rectangle of non-premultiplied0xAARRGGBBpixels 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 anArtDocument.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 anArtDocument.Loads what anhrefnames.Writes anArtDocumentas SVG.Styled text.A stretch of text with one style.