Public
Like
logoWorkshopOpenMoji
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data β all from the browser, and deployed in milliseconds.
This SDK provides direct programmatic access to the LogoWorkshopOpenMoji logo generation engine. Rather than making HTTP API calls, you can use this SDK to generate logos directly in your code.
Import the SDK directly from Val Town:
// Import the default SDK constructor
import LogoWorkshopSDK from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// Or import the pre-configured instance
import { logoWorkshopSDK } from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// Or import everything
import LogoWorkshopSDK, { logoWorkshopSDK, LogoGeneratorOptions } from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// Use the pre-configured instance
import { logoWorkshopSDK } from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// Generate a simple logo
const result = await logoWorkshopSDK.generateLogo({
words: "Developer Hub",
emoji: "π¨βπ»"
});
// The SVG string is available in result.svg
console.log(result.svg);
// Metadata about the logo is available in result.meta
console.log(`Font sizes: ${result.meta.topFontSize}px and ${result.meta.bottomFontSize}px`);
If you only need the SVG output:
const svgString = await logoWorkshopSDK.generateLogoSvg({
words: "Developer Hub",
emoji: "π¨βπ»"
});
console.log(svgString);
You can create your own instance with custom settings:
import LogoWorkshopSDK from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// Create instance with custom emoji service URL
const mySDK = new LogoWorkshopSDK("https://my-custom-emoji-service.example.com");
const result = await mySDK.generateLogo({
// options
});
The SDK accepts the same options as the HTTP API:
type LogoGeneratorOptions = {
// Required parameters (at least one of these)
firstPart?: string; // Text for top line or full text in single line mode
lastPart?: string; // Text for bottom line (ignored in single line mode)
words?: string; // All text (will be split automatically)
// Display options
auto?: boolean; // Auto determine mode based on length (default: true)
singleLine?: boolean; // Force single line mode (default: auto-determined)
// Text styling
fontFamily?: string; // Font family (default: "Arial, sans-serif")
textColor?: string; // Hex color for text (default: "#000000")
accentColor?: string; // Hex color for accents (default: "#ea5a47")
secondaryColor?: string; // Hex color for bottom strip (default: "#781e32")
bgColor?: string; // Hex color for background (default: "#ffffff")
boldTop?: boolean; // Bold for top line (default: true)
italicTop?: boolean; // Italic for top line (default: false)
boldBottom?: boolean; // Bold for bottom line (default: true)
italicBottom?: boolean; // Italic for bottom line (default: false)
// Layout and positioning
emojiX?: number; // X position for emoji (default: 140)
emojiY?: number; // Y position for emoji (default: 13.5)
emojiScale?: number; // Scale factor for emoji (default: 0.71)
verticalSpacingFactor?: number; // Line spacing (default: -0.25)
// Special features
emoji?: string; // Emoji character to use
debug?: boolean; // Show guide lines (default: false)
// Emoji auto-generation
useEmojiSdk?: boolean; // Use emoji generator if none specified (default: true)
emojiSdkUrl?: string; // Custom emoji service URL
};
The generateLogo() method returns a promise that resolves to:
type LogoGeneratorResult = {
svg: string; // The complete SVG string
meta: {
// Font sizes
topFontSize: number;
bottomFontSize: number;
// Positioning
topY: number;
bottomY: number;
textXPosition: number;
maxWidth: number;
actualWidth: number;
// Mode settings
singleLineMode: boolean;
autoMode: boolean;
// Text content
originalWords: string;
firstPart: string;
lastPart: string;
totalCharCount: number;
characterThreshold: number;
// Text styling
isBoldTop: boolean;
isItalicTop: boolean;
isBoldBottom: boolean;
isItalicBottom: boolean;
// Emoji details
emoji: string;
emojiCodepoint: string;
emojiX: number;
emojiY: number;
emojiScale: number;
// Spacing details
spacing: number;
verticalSpacingFactor: number;
yOffset: number;
// Colors
extractedColors: string[];
colors: {
textColor: string;
accentColor: string;
secondaryColor: string;
bgColor: string;
};
// Additional info
usedEmojiSdk: boolean;
};
};
const result = await logoWorkshopSDK.generateLogo({
firstPart: "CLOUD",
lastPart: "COMPUTING",
emoji: "βοΈ"
});
const result = await logoWorkshopSDK.generateLogo({
words: "DevHub",
emoji: "π¨βπ»",
singleLine: true
});
const result = await logoWorkshopSDK.generateLogo({
words: "Ocean Life",
emoji: "π¬",
textColor: "#003366",
accentColor: "#0099cc",
secondaryColor: "#006699",
bgColor: "#f0f8ff"
});
const result = await logoWorkshopSDK.generateLogo({
words: "AI Assistant",
// No emoji specified, will use EmojiSummarizer to generate one
useEmojiSdk: true
});
const result = await logoWorkshopSDK.generateLogo({
words: "Test Logo",
debug: true // Shows guide lines for positioning
});
import { logoWorkshopSDK } from "https://esm.town/v/dcm31/logoWorkshopOpenMoji/sdk.tsx";
// In a browser environment:
async function updateLogo() {
const words = document.getElementById("logoText").value;
const svgString = await logoWorkshopSDK.generateLogoSvg({ words });
document.getElementById("logoContainer").innerHTML = svgString;
}
- The SDK does not support custom sizing of the overall logo (fixed at 301x113.266)
- Only OpenMoji emoji set is supported
- Text X position is fixed at 112px and cannot be changed
- Single-line mode requires at least one space in the text to trigger the color split effect