Logo maker: the JavaScript library
Logo editor engine on Fabric.js: text, curved text, shapes, 200 000+ icons, templates, gradients and patterns, layers, undo, export to SVG, PNG, PDF and ZIP with all sizes.
@openlibsdev/logo-maker- v1.0.0
- ES module
- MIT
Installation
With a bundler or Node-style imports:
npm install @openlibsdev/logo-makerimport LogoMaker from "@openlibsdev/logo-maker";Or straight in a page, without a build step (jsDelivr resolves the dependencies):
<script type="module">
import LogoMaker from "https://cdn.jsdelivr.net/npm/@openlibsdev/logo-maker@1.0.0/+esm";
</script>Usage
import LogoMaker from "@openlibsdev/logo-maker";
const canvas = document.body.appendChild(document.createElement("canvas"));
LogoMaker.init({ canvas });
LogoMaker.setCanvasSize(512, 512);
LogoMaker.addHeading();
LogoMaker.setText("ACME");
const svg = LogoMaker.exportSVG(512);API
LogoMaker.init(opts)
Starts the editor on a <canvas>: {canvas, container, localeBase}.
LogoMaker.setCanvasSize(w, h)
Sets the logo size.
LogoMaker.addText()
Adds text.
LogoMaker.addHeading()
Adds a heading.
LogoMaker.addCurvedText()
Adds text along an arc.
LogoMaker.addShape(type)
Adds a shape.
LogoMaker.addIcon(opts)
Adds an icon.
LogoMaker.applyTemplate(id)
Applies a template.
LogoMaker.templates()
Lists the templates.
LogoMaker.setText(val)
Changes the text of the selected object.
LogoMaker.setFillColor(color)
Fill color of the selection.
LogoMaker.setFont(fam)
Font of the selected text.
LogoMaker.setBackground(config)
Background: color, gradient, pattern.
LogoMaker.getLayers()
Lists the layers.
LogoMaker.undo()
Undo.
LogoMaker.redo()
Redo.
LogoMaker.exportSVG(size)
Logo as SVG.
LogoMaker.exportPNG(size, transparent)
Logo as a PNG data URL.
LogoMaker.exportBlob(size, transparent, mime, quality)
Logo as a file in any format.
LogoMaker.exportZipBlob()
ZIP with all sizes and formats.
LogoMaker.projectJSON()
Project as JSON.
LogoMaker.loadProject(obj)
Opens a project.
LogoMaker.on(ev, cb)
Subscribes to an event (selection, change, …).
LogoMaker.addFont(file)
Adds a font from a file (TTF, OTF, WOFF, WOFF2) and puts it on the selected text; resolves to the family name.
LogoMaker.addImageFromDataURL(dataUrl)
Adds a picture from a data URL in the middle of the logo; resolves to the new object.
LogoMaker.addStyledIcon(o)
Adds an icon on a background shape (circle, square, …) as one badge: {name, lib, ic, bg, bgColor, size, …}.
LogoMaker.alignCanvas(dir)
Aligns the selected object to the logo: left, right, top, bottom, center horizontally or vertically.
LogoMaker.bringForward()
Moves the selected object one layer up.
LogoMaker.centerH()
Centers the selected object horizontally on the logo.
LogoMaker.centerV()
Centers the selected object vertically on the logo.
LogoMaker.clearCanvas()
Removes everything from the logo and resets the background.
LogoMaker.composeVariant(kind)
Preview picture of the logo as current, transparent, on white, on dark or as a round avatar; resolves to an image URL.
LogoMaker.copyStyle()
Remembers the look of the selected object (fill, stroke, opacity, shadow, font); false when nothing is selected.
LogoMaker.deleteActive()
Deletes the selected objects.
LogoMaker.deleteLayer(id)
Deletes the layer with this id.
LogoMaker.duplicate()
Adds a copy of the selected object, slightly moved.
LogoMaker.ensureIconData(prefix)
Loads the names and drawings of an icon set (or of every set without an argument); resolves when they are there.
LogoMaker.exportPDFBlob()
The logo as a PDF of its own size; resolves to a Blob.
LogoMaker.findNamedColor(text, lang)
Finds a named color by its name in the given language ("dark blue" → #00008b).
LogoMaker.fit()
Zooms so the whole logo fits in the editor.
LogoMaker.fitToScreen()
Resizes the editor to its box and fits the logo again.
LogoMaker.flipH()
Mirrors the selected objects left to right.
LogoMaker.flipV()
Mirrors the selected objects top to bottom.
LogoMaker.fonts()
Font families that can be used: the built-in ones and those added.
LogoMaker.getSelection()
What is selected and how it looks (text, font, fill, stroke, shadow, badge colors, …), for filling in the panels; {has:false} when nothing is.
LogoMaker.getSize()
Size of the logo in pixels: {w, h}.
LogoMaker.getView()
Zoom and position of the view: {zoom, baseZoom, vpt, W, H, percent}.
LogoMaker.gradTypes()
Gradient types: linear, radial, conic, mesh.
LogoMaker.group()
Groups the selected objects into one.
LogoMaker.has(k)
Whether the loaded interface language has a text for this key.
LogoMaker.iconCategories()
Ids of the icon categories (for the category filter).
LogoMaker.iconList({ lib, faStyle, category, filter })
Names of the icons of a set, filtered by category and search text: {lib, faStyle, category, filter}.
LogoMaker.iconPrefix(lib, style)
Icon set prefix for a library and style (Font Awesome solid, regular, brands).
LogoMaker.iconSvg(prefix, name, color)
An icon of a loaded set as SVG markup in a color; null when it is not there.
LogoMaker.iconsLoaded(prefix)
Whether an icon set (or every set without an argument) is loaded.
LogoMaker.isEditing()
Whether a text is being typed in right now.
LogoMaker.langs()
Codes of the interface languages there are.
LogoMaker.layerBackward(id)
Moves the layer with this id one step down.
LogoMaker.layerForward(id)
Moves the layer with this id one step up.
LogoMaker.listExportFormats()
Image formats the logo can be saved in.
LogoMaker.listNamedColors(lang)
Lists the named colors with their names in the given language.
LogoMaker.locale()
Code of the interface language loaded now.
LogoMaker.log(msg, type)
Adds a line to the log (type "err" for an error) and sends it with the "log" event.
LogoMaker.logs()
Lines of the log (the last 500).
LogoMaker.makeStylish(opts)
Puts the selected object on a background shape as a badge ({bgType, bgColor, strokeW, strokeColor}); false when there is no single object.
LogoMaker.mimeFor(format)
MIME type of an image format ("PNG" → "image/png").
LogoMaker.mirror()
Adds a mirrored copy of the selected object to its right.
LogoMaker.namedColorTexts(lang)
Labels of the color field in the given language (the texts of the color picker), English for a missing language.
LogoMaker.namedGrads()
Ready gradients with their names.
LogoMaker.off(ev, cb)
Stops calling a function for an event.
LogoMaker.pasteStyle()
Gives the selected objects the look remembered with copyStyle.
LogoMaker.patterns()
Ids of the background patterns.
LogoMaker.previewKinds()
Preview variants for composeVariant, with the text key of each name.
LogoMaker.renameLayer(id, name)
Renames the layer with this id.
LogoMaker.rtl()
Interface languages written right to left.
LogoMaker.selectLayer(id)
Selects the layer with this id.
LogoMaker.sendBackwards()
Moves the selected object one layer down.
LogoMaker.setAngle(deg)
Rotates the selected objects to an angle in degrees.
LogoMaker.setBadgeBgColor(color)
Color of the background shape of the selected badge.
LogoMaker.setBadgeBgPaint(def)
Gradient or pattern of the background shape of the selected badge.
LogoMaker.setBadgeIconColor(color)
Color of the icon of the selected badge.
LogoMaker.setBadgeIconPaint(def)
Gradient or pattern of the icon of the selected badge.
LogoMaker.setCharSpacing(v)
Letter spacing of the selected texts (thousandths of the font size).
LogoMaker.setDark(dark)
Dark or light editor background around the logo.
LogoMaker.setFillPaint(def)
Fills the selected objects with a gradient or pattern.
LogoMaker.setFontSize(v)
Font size of the selected texts.
LogoMaker.setLineHeight(v)
Line height of the selected texts.
LogoMaker.setLocale(code)
Loads an interface language; the page re-applies its texts on the "locale" event.
LogoMaker.setOpacity(pct)
Opacity of the selected objects in percent.
LogoMaker.setShadow(s)
Shadow of the selected objects ({on, color, blur, x, y}); without it the shadow is removed.
LogoMaker.setStrokeColor(color)
Outline color of the selected objects.
LogoMaker.setStrokePaint(def)
Outline of the selected objects with a gradient or pattern.
LogoMaker.setStrokeWidth(v)
Outline width of the selected objects.
LogoMaker.setTextAlign(align)
Text alignment of the selected texts: left, center, right, justify.
LogoMaker.setUrls(o)
Sets where icon sets are loaded from: {iconSets, iconify}.
LogoMaker.styledIcons()
Ready icon badges for addStyledIcon.
LogoMaker.templateThumb(id)
Small picture of a template for the template menu; resolves to an image URL.
LogoMaker.textFontData
Data for a text and font block: the font list, loading a font style, adding a font file, the block's labels in a language and the default values.
LogoMaker.toggleBold()
Switches bold on or off for the selected texts.
LogoMaker.toggleItalic()
Switches italic on or off for the selected texts.
LogoMaker.toggleLayerLock(id)
Locks or unlocks the layer with this id (a locked one cannot be moved or selected on the logo).
LogoMaker.toggleUnderline()
Switches underline on or off for the selected texts.
LogoMaker.tr(key, vars)
Text of a key in the loaded interface language, with {name} placeholders filled in.
LogoMaker.ungroup()
Splits the selected group back into its objects.
LogoMaker.zoomIn()
Zooms in by a quarter.
LogoMaker.zoomOut()
Zooms out by a quarter.
LogoMaker.APP
Name and version of the library: {name, version}.
Dependencies
What the library loads, with the licenses (all are listed on the Licenses page).
| Name | Version | License | Files |
|---|---|---|---|
| @openlibsdev/font-forge | 1.0.0 | MIT | GitHub |
| @openlibsdev/image-forge | 1.0.0 | MIT | GitHub |
| @imagemagick/magick-wasm | 0.0.35 | Apache-2.0 | License · Source code |
| @imagemagick/magick-wasm | 0.0.35 | Apache-2.0 | License · Source code |
| @simonwep/pickr | 1.10.2 | MIT | License · Source code |
| @simonwep/pickr | 1.10.2 | MIT | License · Source code |
| bootstrap | 5.3.3 | MIT | License · Source code |
| dejavu-fonts-ttf | 2.37.3 | Bitstream Vera Fonts License (free, redistributable); DejaVu changes are public domain | License · Source code |
| fabric | 5.3.0 | MIT | License · Source code |
| https: | |||
| iconify-icon | 2.1.0 | MIT | License · Source code |
| imagetracerjs | 1.2.6 | Unlicense | License · Source code |
| jspdf | 2.5.2 | MIT | License · Source code |
| jszip | 3.10.1 | (MIT OR GPL-3.0-or-later) | License · Source code |