


























@@ -200,6 +200,49 @@ function fillTriangle(params: {
200200}
201201}
202202203+function drawBlockCatLabel(params: {
204+buf: Buffer;
205+width: number;
206+height: number;
207+x: number;
208+y: number;
209+color: { r: number; g: number; b: number; a?: number };
210+}) {
211+const t = 12;
212+const h = 78;
213+const w = 58;
214+const gap = 20;
215+const cX = params.x;
216+const aX = cX + w + gap;
217+const tX = aX + w + gap;
218+219+fillRect({ ...params, x: cX, y: params.y, w, h: t, color: params.color });
220+fillRect({ ...params, x: cX, y: params.y, w: t, h, color: params.color });
221+fillRect({ ...params, x: cX, y: params.y + h - t, w, h: t, color: params.color });
222+223+fillRect({ ...params, x: aX, y: params.y, w, h: t, color: params.color });
224+fillRect({ ...params, x: aX, y: params.y, w: t, h, color: params.color });
225+fillRect({ ...params, x: aX + w - t, y: params.y, w: t, h, color: params.color });
226+fillRect({
227+ ...params,
228+x: aX,
229+y: params.y + Math.floor((h - t) / 2),
230+ w,
231+h: t,
232+color: params.color,
233+});
234+235+fillRect({ ...params, x: tX, y: params.y, w, h: t, color: params.color });
236+fillRect({
237+ ...params,
238+x: tX + Math.floor((w - t) / 2),
239+y: params.y,
240+w: t,
241+ h,
242+color: params.color,
243+});
244+}
245+203246export function renderCatNoncePngBase64(nonce: string): string {
204247const top = "CAT";
205248const bottom = nonce.toUpperCase();
@@ -242,7 +285,7 @@ export function renderCatNoncePngBase64(nonce: string): string {
242285243286export function renderCatFacePngBase64(): string {
244287const width = 256;
245-const height = 256;
288+const height = 288;
246289const buf = Buffer.alloc(width * height * 4, 255);
247290const outline = { r: 40, g: 40, b: 40 };
248291const innerEar = { r: 245, g: 182, b: 193 };
@@ -253,54 +296,54 @@ export function renderCatFacePngBase64(): string {
253296 buf,
254297 width,
255298 height,
256-a: { x: 62, y: 86 },
257-b: { x: 106, y: 18 },
258-c: { x: 136, y: 104 },
299+a: { x: 62, y: 74 },
300+b: { x: 106, y: 12 },
301+c: { x: 134, y: 88 },
259302color: outline,
260303});
261304fillTriangle({
262305 buf,
263306 width,
264307 height,
265-a: { x: 194, y: 86 },
266-b: { x: 150, y: 18 },
267-c: { x: 120, y: 104 },
308+a: { x: 194, y: 74 },
309+b: { x: 150, y: 12 },
310+c: { x: 122, y: 88 },
268311color: outline,
269312});
270313fillTriangle({
271314 buf,
272315 width,
273316 height,
274-a: { x: 78, y: 82 },
275-b: { x: 106, y: 38 },
276-c: { x: 122, y: 92 },
317+a: { x: 80, y: 70 },
318+b: { x: 106, y: 34 },
319+c: { x: 122, y: 80 },
277320color: innerEar,
278321});
279322fillTriangle({
280323 buf,
281324 width,
282325 height,
283-a: { x: 178, y: 82 },
284-b: { x: 150, y: 38 },
285-c: { x: 134, y: 92 },
326+a: { x: 176, y: 70 },
327+b: { x: 150, y: 34 },
328+c: { x: 134, y: 80 },
286329color: innerEar,
287330});
288331fillEllipse({
289332 buf,
290333 width,
291334 height,
292335cx: 128,
293-cy: 142,
294-rx: 82,
295-ry: 78,
336+cy: 112,
337+rx: 78,
338+ry: 66,
296339color: outline,
297340});
298341fillEllipse({
299342 buf,
300343 width,
301344 height,
302345cx: 98,
303-cy: 126,
346+cy: 100,
304347rx: 9,
305348ry: 12,
306349color: { r: 255, g: 255, b: 255 },
@@ -310,7 +353,7 @@ export function renderCatFacePngBase64(): string {
310353 width,
311354 height,
312355cx: 158,
313-cy: 126,
356+cy: 100,
314357rx: 9,
315358ry: 12,
316359color: { r: 255, g: 255, b: 255 },
@@ -320,34 +363,31 @@ export function renderCatFacePngBase64(): string {
320363 width,
321364 height,
322365cx: 128,
323-cy: 158,
366+cy: 130,
324367rx: 22,
325-ry: 18,
368+ry: 17,
326369color: { r: 255, g: 255, b: 255 },
327370});
328371fillTriangle({
329372 buf,
330373 width,
331374 height,
332-a: { x: 128, y: 150 },
333-b: { x: 118, y: 164 },
334-c: { x: 138, y: 164 },
375+a: { x: 128, y: 122 },
376+b: { x: 118, y: 136 },
377+c: { x: 138, y: 136 },
335378color: nose,
336379});
337-fillRect({ buf, width, height, x: 127, y: 164, w: 2, h: 16, color: whisker });
338-fillRect({ buf, width, height, x: 74, y: 161, w: 42, h: 2, color: whisker });
339-fillRect({ buf, width, height, x: 140, y: 161, w: 42, h: 2, color: whisker });
340-fillRect({ buf, width, height, x: 76, y: 173, w: 38, h: 2, color: whisker });
341-fillRect({ buf, width, height, x: 142, y: 173, w: 38, h: 2, color: whisker });
342-fillRect({ buf, width, height, x: 85, y: 185, w: 30, h: 2, color: whisker });
343-fillRect({ buf, width, height, x: 141, y: 185, w: 30, h: 2, color: whisker });
344-drawText({
380+fillRect({ buf, width, height, x: 127, y: 136, w: 2, h: 15, color: whisker });
381+fillRect({ buf, width, height, x: 74, y: 134, w: 42, h: 2, color: whisker });
382+fillRect({ buf, width, height, x: 140, y: 134, w: 42, h: 2, color: whisker });
383+fillRect({ buf, width, height, x: 80, y: 146, w: 34, h: 2, color: whisker });
384+fillRect({ buf, width, height, x: 142, y: 146, w: 34, h: 2, color: whisker });
385+drawBlockCatLabel({
345386 buf,
346387 width,
347-x: Math.floor((width - measureTextWidthPx("CAT", 10)) / 2),
348-y: 212,
349-text: "CAT",
350-scale: 10,
388+ height,
389+x: 21,
390+y: 190,
351391color: outline,
352392});
353393此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。