jtenniswood/espcontrol / .agents/skills/mock-feature-screens
mock-feature-screens
VerifiedCreate realistic EspControl feature screen mockups by fitting actual editor screenshots into the local device photo templates, with custom card colours, soft reflections and gentle blur. Use for device feature illustrations and requested configuration screenshots or documentation integration; not for generic image generation or changing firmware behaviour.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.9 KB |
| agents/openai.yaml | config | 257 B |
| assets/weather-example.json | config | 398 B |
| references/capture.md | markdown | 3.6 KB |
| scripts/capture-preview.cjs | script | 5.1 KB |
| scripts/compose-screen.cjs | script | 6.9 KB |
scripts/compose-screen.cjs
View on GitHub#!/usr/bin/env node
// Fit a UI screenshot to the transparent screen in the supplied device template.
// Requires sharp. First argument: original, template2, or a local image path.
const assert = require('node:assert/strict');
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
const sharp = require('sharp');
function resolveTemplate(input) {
const names = { original: 'device-template.webp', template2: 'device-template-2.webp' };
if (!Object.hasOwn(names, input)) return path.resolve(input);
const directory = process.env.ESPCONTROL_MOCK_TEMPLATE_DIR || path.join(
process.env.CODEX_HOME || path.join(os.homedir(), '.codex'),
'skills', 'mock-feature-screens', 'assets');
const filename = path.join(directory, names[input]);
assert(fs.existsSync(filename) && fs.statSync(filename).isFile(),
`Missing local template "${input}". Set ESPCONTROL_MOCK_TEMPLATE_DIR to the photo folder or pass an explicit image path. Source photos are not bundled with the repository skill.`);
return filename;
}
function solve(rows) {
const n = rows.length;
for (let col = 0; col < n; col++) {
let pivot = col;
for (let row = col + 1; row < n; row++) {
if (Math.abs(rows[row][col]) > Math.abs(rows[pivot][col])) pivot = row;
}
assert(Math.abs(rows[pivot][col]) > 1e-12, 'Screen corners must define a plane');
[rows[col], rows[pivot]] = [rows[pivot], rows[col]];
const divisor = rows[col][col];
for (let j = col; j <= n; j++) rows[col][j] /= divisor;
for (let row = 0; row < n; row++) {
if (row === col) continue;
const factor = rows[row][col];
for (let j = col; j <= n; j++) rows[row][j] -= factor * rows[col][j];
}
}
return rows.map(row => row[n]);
}
async function main() {
const [templateInput, screenPath, outputPath] = process.argv.slice(2);
const glass = process.argv.slice(5).includes('--glass');
assert(templateInput && screenPath && outputPath,
'Usage: node compose-screen.cjs original|template2|LOCAL_IMAGE screen.png output.webp [--glass]');
const templatePath = resolveTemplate(templateInput);
const { data: photo, info } = await sharp(templatePath).ensureAlpha().raw()
.toBuffer({ resolveWithObject: true });
const { width, height } = info;
assert.equal(info.channels, 4);
const isScreen = p => photo[p * 4 + 3] < 255;
// The template's screen contains the image centre. Flood fill avoids isolated
// pixels in the surrounding photograph affecting corner detection.
const start = Math.floor(height / 2) * width + Math.floor(width / 2);
assert(isScreen(start), 'Template centre must lie inside the transparent screen');
const mask = new Uint8Array(width * height);
const pixels = new Int32Array(width * height);
pixels[0] = start;
mask[start] = 1;
let count = 1;
let minSum = Infinity, maxSum = -Infinity, minDiff = Infinity, maxDiff = -Infinity;
let tl, tr, br, bl;
for (let index = 0; index < count; index++) {
const p = pixels[index], x = p % width, y = Math.floor(p / width);
if (x + y < minSum) { minSum = x + y; tl = [x, y]; }
if (x + y > maxSum) { maxSum = x + y; br = [x, y]; }
if (x - y < minDiff) { minDiff = x - y; bl = [x, y]; }
if (x - y > maxDiff) { maxDiff = x - y; tr = [x, y]; }
const neighbours = [];
if (x > 0) neighbours.push(p - 1);
if (x + 1 < width) neighbours.push(p + 1);
if (y > 0) neighbours.push(p - width);
if (y + 1 < height) neighbours.push(p + width);
for (const next of neighbours) {
if (!mask[next] && isScreen(next)) {
mask[next] = 1;
pixels[count++] = next;
}
}
}
assert(count > width * height * 0.1, 'Expected a substantial transparent screen mask');
const corners = [tl, tr, br, bl];
const uv = [[0, 0], [1, 0], [1, 1], [0, 1]];
const equations = [];
corners.forEach(([x, y], index) => {
const [u, v] = uv[index];
equations.push([x, y, 1, 0, 0, 0, -u * x, -u * y, u]);
equations.push([0, 0, 0, x, y, 1, -v * x, -v * y, v]);
});
const h = solve(equations);
function map(x, y) {
const denominator = h[6] * x + h[7] * y + 1;
return [(h[0] * x + h[1] * y + h[2]) / denominator,
(h[3] * x + h[4] * y + h[5]) / denominator];
}
corners.forEach(([x, y], index) => {
const point = map(x, y);
assert(Math.hypot(point[0] - uv[index][0], point[1] - uv[index][1]) < 1e-8,
'Projected screen corners must match the template');
});
const metadata = await sharp(screenPath).metadata();
// Remove the editor preview's four-pixel simulated enclosure outline.
const screenImage = sharp(screenPath)
.extract({ left: 4, top: 4, width: metadata.width - 8, height: metadata.height - 8 });
if (glass) screenImage.blur(0.8);
const { data: screen, info: screenInfo } = await screenImage
.removeAlpha().raw().toBuffer({ resolveWithObject: true });
const sw = screenInfo.width, sh = screenInfo.height;
const output = Buffer.alloc(width * height * 3);
for (let p = 0; p < mask.length; p++) {
for (let c = 0; c < 3; c++) output[p * 3 + c] = photo[p * 4 + c];
}
for (let index = 0; index < count; index++) {
const p = pixels[index];
const [u, v] = map(p % width, Math.floor(p / width));
const sx = Math.max(0, Math.min(sw - 1, u * (sw - 1)));
const sy = Math.max(0, Math.min(sh - 1, v * (sh - 1)));
const x0 = Math.floor(sx), y0 = Math.floor(sy);
const x1 = Math.min(sw - 1, x0 + 1), y1 = Math.min(sh - 1, y0 + 1);
const dx = sx - x0, dy = sy - y0;
// Diffuse room light and a soft window reflection share the screen plane.
// This changes only the inserted screen, never the surrounding photograph.
const reflection = glass ? 0.045 +
0.14 * Math.exp(-Math.pow((u - 0.12 - 0.10 * v) / 0.12, 2)) +
0.09 * Math.exp(-Math.pow((u - 0.37) / 0.42, 2) - Math.pow((v - 0.05) / 0.6, 2)) : 0;
const reflectedLight = [150, 175, 195];
for (let c = 0; c < 3; c++) {
const at = (x, y) => screen[(y * sw + x) * 3 + c];
const sample =
at(x0, y0) * (1 - dx) * (1 - dy) + at(x1, y0) * dx * (1 - dy) +
at(x0, y1) * (1 - dx) * dy + at(x1, y1) * dx * dy;
const opacity = photo[p * 4 + 3] / 255;
const throughGlass = glass
? sample * 0.96 * (1 - reflection) + reflectedLight[c] * reflection
: sample;
output[p * 3 + c] = Math.round(throughGlass * (1 - opacity) + photo[p * 4 + c] * opacity);
}
}
await sharp(output, { raw: { width, height, channels: 3 } })
.webp({ lossless: true }).toFile(outputPath);
const decoded = await sharp(outputPath).removeAlpha().raw().toBuffer();
let preserved = 0;
for (let p = 0; p < mask.length; p++) {
if (mask[p]) continue;
for (let c = 0; c < 3; c++) assert.equal(decoded[p * 3 + c], photo[p * 4 + c],
'Photograph outside the screen must remain pixel-identical');
preserved++;
}
console.log(JSON.stringify({ corners, screenPixels: count, preservedPhotoPixels: preserved, outputPath }));
}
main().catch(error => { console.error(error); process.exitCode = 1; });
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 198k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |