{"summary":"Efeitos ASCII e de pontilhado para imagens e vídeos em páginas de login, sites e cards, com uma intensidade que pode ser ajustada a qualquer momento.","notes":"<p>O ASCII e o pontilhado redesenham a imagem com caracteres ou com uma textura de pixels de acordo com o brilho: mantêm a estrutura de claro e escuro e eliminam os detalhes da foto. Todos os parâmetros podem ser ajustados, então a mesma imagem pode ser o destaque principal ou recuar para o fundo como textura. São cinco pontos principais:</p>\n        <ol>\n        <li><strong>ASCII</strong>: para um ar de terminal ou de código, como a página de login de uma ferramenta para desenvolvedores. A imagem é dividida em uma grade, e cada célula é trocada por um caractere conforme o brilho, de “.” a “@”, cada vez mais denso; o tamanho é o tamanho da fonte, o espaçamento é a densidade da grade e a intensidade da amostragem é o contraste.</li>\n        <li><strong>Pontilhado</strong>: para um ar de retícula de impressão ou de grão de pixel. A imagem é dividida em blocos de pixels, e uma matriz de Bayer 4×4 serve de limiar para reduzir cada cor a poucos níveis, que de longe se misturam em tons intermediários; o tamanho é o do bloco, o espaçamento é a escala da textura, e quanto maior a intensidade da amostragem, menos níveis de cor e mais granulado.</li>\n        <li><strong>Máscara</strong>: vale para os dois efeitos. Um degradê vertical sobreposto faz a imagem recuar, e o efeito parece mais uma textura do que ruído; se o efeito atrapalhar o texto por cima, aumente primeiro a máscara.</li>\n        <li><strong>Tons amostrados</strong>: só para o ASCII; define se os caracteres são desenhados nas sombras ou nas luzes, conforme o tom em que está o assunto principal. Numa cidade à noite, o assunto são as luzes, então se amostram as luzes; na foto de um produto escuro sobre fundo branco, as sombras.</li>\n        <li><strong>Cor</strong>: dá para manter a cor original ou escolher uma de cinco paletas; primeiro o claro e escuro da imagem é mapeado para essa paleta e depois o efeito é gerado, para que imagens diferentes mantenham o mesmo estilo.</li>\n        </ol>\n        <h2>Parâmetros</h2>\n        <dl class=\"params\">\n        <dt>ASCII</dt><dd>Máscara 90; tons amostrados Sombras; intensidade da amostragem 100; tamanho 37; espaçamento 0</dd>\n        <dt>Pontilhado</dt><dd>Máscara 88; intensidade da amostragem 100; tamanho 15; espaçamento 0</dd>\n        </dl>\n        <p>O prompt que acompanha esta dica confirma primeiro qual imagem ou vídeo deve ser tratado, depois gera o efeito e acrescenta ao lado um painel para ajustar os parâmetros em tempo real.</p>","prompt":"Add an ASCII / ordered-dither effect to one specific image or video in\nthis project, with a live control panel next to it. Use the asset and the\nplace I name (an <img>, a <video>, or a file path or URL, and the page or\nsection it sits in); ask me if I have not named them. Apply the effect to\nthat asset only, in place: keep its size, position, rounded corners and\nanything layered on top of it. If the project already has an image or\ncanvas effect pipeline, or slider, segmented-control and panel components,\nbuild on them; otherwise create a reusable EffectLayer and EffectPanel.\n\nSettings, one object shared by the layer and the panel:\n{ filter: 'ascii' | 'dither', mask, palette, inkTone, strength, size,\n  spacing }\nKeep separate values per filter, so switching filters brings back that\nfilter's own settings.\n\nWhat each control does in each filter, its range, and the recommended\nvalue (ASCII / Dither):\n- Mask effect, 0-100 (90 / 88): a vertical veil over the picture so the\n  effect reads as texture rather than noise. Same in both filters.\n- Color, Original or one of five palettes (Original): gradient-maps the\n  asset's luminance into one color family before filtering.\n- Sample tones, Shadows | Highlights (Shadows; ASCII only, hidden for\n  Dither): which end of the tonal range becomes dense characters.\n- Sampling strength, 0-100 (100 / 100). ASCII: contrast of the tone curve\n  and how bright and opaque the characters are. Dither: how few levels\n  each color channel keeps (8 at 0, 2 at 100) and how fully the quantized\n  color replaces the original.\n- Size, 0-100 (37 / 15). ASCII: font size, 7-24px. Dither: pixel block,\n  2-9px.\n- Spacing, 0-100 (0 / 0). ASCII: grid step, 8-24px across and 9-26px\n  down, never tighter than the glyphs. Dither: scale of the Bayer\n  pattern, 1-4 blocks per matrix cell.\n\nHelpers used throughout:\n- range(v, a, b) = a + (b - a) * v / 100\n- luminance L = (0.299 R + 0.587 G + 0.114 B) / 255\n- s = strength / 100\n- \"The box\" is the asset's rendered size on the page.\n\nSampling:\n- Cover-fit the asset into the box and draw it into a small sampling\n  canvas (about 480px on the long side), then read it with getImageData.\n  A sample is the pixel under a point in the box, composited over white.\n- With a palette, recolor that canvas first: map each pixel's L through a\n  256-entry lookup built from the palette's four stops.\n- Per image or video frame, take about 12,000 evenly spaced samples:\n  low = 8th percentile of L, high = 92nd percentile.\n- Shadows means dark ink, Highlights light ink.\n\nASCII:\n- Characters, from empty to full: \"  .,:;-=+xX08S#&@\" (starts with two\n  spaces).\n- Font: round(range(size, 7, 24))px monospace (22 instead of 24 when the\n  box is under 720px wide), centered in each cell.\n- Grid: x step = max(range(spacing, 8, 24), widest glyph * 1.08); line\n  height = max(range(spacing, 9, 26), height of \"@\" * 1.12, font * 1.04).\n  The first cell sits half a step in from the edge.\n- Tone of a cell: raw = dark ink ? 1 - L : L; normalized = dark ink ?\n  (high - L) / (high - low) : (L - low) / (high - low), clamped 0-1 (use\n  raw alone when high - low < 0.025); mix = 0.72 + 0.14 s;\n  t = raw (1 - mix) + normalized mix. Then a tone curve: black = 0.22 s,\n  white = 1 - 0.08 s, lev = clamp((t - black) / (white - black), 0, 1),\n  tone = lev (1 - s) + smoothstep(lev) s.\n- Skip cells with tone <= 0.02. Character = chars[round(tone * 16)]; skip\n  spaces.\n- Ink: the sampled color lifted in HSV: value += (1 - value) *\n  (0.24 + 0.18 s + 0.24 tone); saturation *= 1 + 0.16 + 0.2 s (clamped).\n  Alpha = clamp((0.12 + 0.7 tone) (0.72 + 0.28 s), 0.06, 0.94).\n\nDither (ordered, Bayer 4x4):\n- pixel size = max(2, round(range(size, 2, 9))) (7 instead of 9 under\n  720px); pattern scale = max(1, round(range(spacing, 1, 4))); levels =\n  max(2, round(range(strength, 8, 2))) per channel; blend =\n  range(strength, 0.32, 1).\n- Matrix [[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]]; threshold =\n  (m + 0.5) / 16, indexed by floor(x / pattern scale), floor(y / pattern\n  scale).\n- For each block sample its center, push saturation away from luma by\n  1 + 0.06 + 0.18 s, then per channel: scaled = c / 255 * (levels - 1);\n  q = floor(scaled) + (fraction > threshold ? 1 : 0);\n  out = c + (q / (levels - 1) * 255 - c) * blend.\n- Write the blocks into a canvas of box / pixel size and draw it scaled up\n  with image smoothing off.\n\nMask and layering:\n- The mask is a vertical gradient with stops at the top, 42% and the\n  bottom. Base opacities: on a light page white 54/20/38%, on a dark page\n  black 44/20/50%. For a mask value v: stop = v <= 50 ? base *\n  (v / 50)^1.08 : base + (100 - base) * ((v - 50) / 50)^1.08.\n- ASCII: draw the (recolored) picture, the mask, then the characters.\n  Dither: draw the dithered picture, then the mask on top.\n- Changing filter or palette cross-fades from the last frame over 150ms.\n\nPalettes (four stops at 0, 0.4, 0.74, 1):\n- meadow: #2B361F, #677D45, #AEBA78, #E5E1BD\n- blue: #192A4D, #326AC5, #A2C2F1, #EDF3FC\n- amber: #3C200F, #A74C15, #EF9A46, #F7E7CA\n- lavender: #292144, #6552AB, #B3A5E4, #F0ECFB\n- mono: #151515, #575757, #A6A6A6, #ECECEC\n\nRendering:\n- Draw into a canvas laid over the asset with the same size and corner\n  radius, at devicePixelRatio capped at 1.6x and about 2048 x 2048.\n- Image: redraw when a setting changes (debounced 72ms).\n- Video: redraw on every new frame (requestVideoFrameCallback, falling\n  back to requestAnimationFrame) while it plays and is on screen; keep\n  the video element underneath as the source.\n\nControl panel:\n- Place it next to the asset, below it when there is room, otherwise\n  beside it, never covering it. About 420px wide, centered on the asset.\n- Rows, in order: Mask effect, Filter (two tabs: ASCII | Dither), Color\n  (round swatches), Sample tones (ASCII only), Sampling strength, Size,\n  Spacing (shown with %).\n- Each row 46px tall: a 136px label column, then the control. Slider: a\n  22px track with 8px radius and a filled part, a 9x30 rounded-rectangle\n  thumb (3px radius), a number box with the value centered, and a snap\n  mark at 50. Swatches: 22px circles, each filled with its palette's two\n  middle stops at 135deg (Original: a tiny crop of the asset); the\n  selected one gets a ring with a small gap.\n- Every change applies live while dragging. Add a \"Reset to recommended\"\n  action that restores the values above for the current filter.\n- Follow the page's light or dark theme and the project's tokens.","skill":"/skills/kubai-ascii-dither/SKILL.md","skillText":"# ASCII与像素抖色效果\n\n《999 个小技巧，让你 Vibe 的产品更有质感》第 003 期 · @kubai087\n\n在用户的项目里按下面的要求改造。要求以用户的口吻写成：文中的 I、me、my 指用户；写着要先问的地方，先停下来问用户再继续。\n\n## 改造要求\n\nAdd an ASCII / ordered-dither effect to one specific image or video in\nthis project, with a live control panel next to it. Use the asset and the\nplace I name (an <img>, a <video>, or a file path or URL, and the page or\nsection it sits in); ask me if I have not named them. Apply the effect to\nthat asset only, in place: keep its size, position, rounded corners and\nanything layered on top of it. If the project already has an image or\ncanvas effect pipeline, or slider, segmented-control and panel components,\nbuild on them; otherwise create a reusable EffectLayer and EffectPanel.\n\nSettings, one object shared by the layer and the panel:\n{ filter: 'ascii' | 'dither', mask, palette, inkTone, strength, size,\n  spacing }\nKeep separate values per filter, so switching filters brings back that\nfilter's own settings.\n\nWhat each control does in each filter, its range, and the recommended\nvalue (ASCII / Dither):\n- Mask effect, 0-100 (90 / 88): a vertical veil over the picture so the\n  effect reads as texture rather than noise. Same in both filters.\n- Color, Original or one of five palettes (Original): gradient-maps the\n  asset's luminance into one color family before filtering.\n- Sample tones, Shadows | Highlights (Shadows; ASCII only, hidden for\n  Dither): which end of the tonal range becomes dense characters.\n- Sampling strength, 0-100 (100 / 100). ASCII: contrast of the tone curve\n  and how bright and opaque the characters are. Dither: how few levels\n  each color channel keeps (8 at 0, 2 at 100) and how fully the quantized\n  color replaces the original.\n- Size, 0-100 (37 / 15). ASCII: font size, 7-24px. Dither: pixel block,\n  2-9px.\n- Spacing, 0-100 (0 / 0). ASCII: grid step, 8-24px across and 9-26px\n  down, never tighter than the glyphs. Dither: scale of the Bayer\n  pattern, 1-4 blocks per matrix cell.\n\nHelpers used throughout:\n- range(v, a, b) = a + (b - a) * v / 100\n- luminance L = (0.299 R + 0.587 G + 0.114 B) / 255\n- s = strength / 100\n- \"The box\" is the asset's rendered size on the page.\n\nSampling:\n- Cover-fit the asset into the box and draw it into a small sampling\n  canvas (about 480px on the long side), then read it with getImageData.\n  A sample is the pixel under a point in the box, composited over white.\n- With a palette, recolor that canvas first: map each pixel's L through a\n  256-entry lookup built from the palette's four stops.\n- Per image or video frame, take about 12,000 evenly spaced samples:\n  low = 8th percentile of L, high = 92nd percentile.\n- Shadows means dark ink, Highlights light ink.\n\nASCII:\n- Characters, from empty to full: \"  .,:;-=+xX08S#&@\" (starts with two\n  spaces).\n- Font: round(range(size, 7, 24))px monospace (22 instead of 24 when the\n  box is under 720px wide), centered in each cell.\n- Grid: x step = max(range(spacing, 8, 24), widest glyph * 1.08); line\n  height = max(range(spacing, 9, 26), height of \"@\" * 1.12, font * 1.04).\n  The first cell sits half a step in from the edge.\n- Tone of a cell: raw = dark ink ? 1 - L : L; normalized = dark ink ?\n  (high - L) / (high - low) : (L - low) / (high - low), clamped 0-1 (use\n  raw alone when high - low < 0.025); mix = 0.72 + 0.14 s;\n  t = raw (1 - mix) + normalized mix. Then a tone curve: black = 0.22 s,\n  white = 1 - 0.08 s, lev = clamp((t - black) / (white - black), 0, 1),\n  tone = lev (1 - s) + smoothstep(lev) s.\n- Skip cells with tone <= 0.02. Character = chars[round(tone * 16)]; skip\n  spaces.\n- Ink: the sampled color lifted in HSV: value += (1 - value) *\n  (0.24 + 0.18 s + 0.24 tone); saturation *= 1 + 0.16 + 0.2 s (clamped).\n  Alpha = clamp((0.12 + 0.7 tone) (0.72 + 0.28 s), 0.06, 0.94).\n\nDither (ordered, Bayer 4x4):\n- pixel size = max(2, round(range(size, 2, 9))) (7 instead of 9 under\n  720px); pattern scale = max(1, round(range(spacing, 1, 4))); levels =\n  max(2, round(range(strength, 8, 2))) per channel; blend =\n  range(strength, 0.32, 1).\n- Matrix [[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]]; threshold =\n  (m + 0.5) / 16, indexed by floor(x / pattern scale), floor(y / pattern\n  scale).\n- For each block sample its center, push saturation away from luma by\n  1 + 0.06 + 0.18 s, then per channel: scaled = c / 255 * (levels - 1);\n  q = floor(scaled) + (fraction > threshold ? 1 : 0);\n  out = c + (q / (levels - 1) * 255 - c) * blend.\n- Write the blocks into a canvas of box / pixel size and draw it scaled up\n  with image smoothing off.\n\nMask and layering:\n- The mask is a vertical gradient with stops at the top, 42% and the\n  bottom. Base opacities: on a light page white 54/20/38%, on a dark page\n  black 44/20/50%. For a mask value v: stop = v <= 50 ? base *\n  (v / 50)^1.08 : base + (100 - base) * ((v - 50) / 50)^1.08.\n- ASCII: draw the (recolored) picture, the mask, then the characters.\n  Dither: draw the dithered picture, then the mask on top.\n- Changing filter or palette cross-fades from the last frame over 150ms.\n\nPalettes (four stops at 0, 0.4, 0.74, 1):\n- meadow: #2B361F, #677D45, #AEBA78, #E5E1BD\n- blue: #192A4D, #326AC5, #A2C2F1, #EDF3FC\n- amber: #3C200F, #A74C15, #EF9A46, #F7E7CA\n- lavender: #292144, #6552AB, #B3A5E4, #F0ECFB\n- mono: #151515, #575757, #A6A6A6, #ECECEC\n\nRendering:\n- Draw into a canvas laid over the asset with the same size and corner\n  radius, at devicePixelRatio capped at 1.6x and about 2048 x 2048.\n- Image: redraw when a setting changes (debounced 72ms).\n- Video: redraw on every new frame (requestVideoFrameCallback, falling\n  back to requestAnimationFrame) while it plays and is on screen; keep\n  the video element underneath as the source.\n\nControl panel:\n- Place it next to the asset, below it when there is room, otherwise\n  beside it, never covering it. About 420px wide, centered on the asset.\n- Rows, in order: Mask effect, Filter (two tabs: ASCII | Dither), Color\n  (round swatches), Sample tones (ASCII only), Sampling strength, Size,\n  Spacing (shown with %).\n- Each row 46px tall: a 136px label column, then the control. Slider: a\n  22px track with 8px radius and a filled part, a 9x30 rounded-rectangle\n  thumb (3px radius), a number box with the value centered, and a snap\n  mark at 50. Swatches: 22px circles, each filled with its palette's two\n  middle stops at 135deg (Original: a tiny crop of the asset); the\n  selected one gets a ring with a small gap.\n- Every change applies live while dragging. Add a \"Reset to recommended\"\n  action that restores the values above for the current filter.\n- Follow the page's light or dark theme and the project's tokens.\n"}