@popcraft/kit 1.2.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{agent-5ZVVUKVL.js → agent-FBOFA4L2.js} +1 -1
- package/dist/chunks/{builtin-ZWF5I77H.js → builtin-UNS7IRTZ.js} +4 -4
- package/dist/chunks/{buy-credits-T7C577LV.js → buy-credits-37KIF2FX.js} +2 -2
- package/dist/chunks/{check-template-MWOIYAGA.js → check-template-NTW22VNY.js} +6 -6
- package/dist/chunks/{chunk-HOWSSUN7.js → chunk-2CMHDBFD.js} +49 -49
- package/dist/chunks/{chunk-URH563AK.js → chunk-2ISMXQZH.js} +1 -1
- package/dist/chunks/{chunk-IKGV64X7.js → chunk-4WOODRGC.js} +4 -4
- package/dist/chunks/{chunk-4CGNSTLN.js → chunk-5OKROQS5.js} +2 -2
- package/dist/chunks/{chunk-JZM5HWEX.js → chunk-6QIOHC6D.js} +1 -1
- package/dist/chunks/{chunk-HW6KW3X3.js → chunk-7ETSVZDD.js} +5 -5
- package/dist/chunks/{chunk-6RIRRH4P.js → chunk-7KJGH5DA.js} +3 -3
- package/dist/chunks/{chunk-JY7KJGXS.js → chunk-AIF72RXH.js} +8 -10
- package/dist/chunks/{chunk-JCV2E7HJ.js → chunk-BOJUI3OG.js} +20 -17
- package/dist/chunks/{chunk-BBBKLNSW.js → chunk-EA7WPVPB.js} +11 -11
- package/dist/chunks/{chunk-AMCNGXZF.js → chunk-EOER2JCK.js} +9 -9
- package/dist/chunks/{chunk-CVZA6HPL.js → chunk-FSM6RE22.js} +139 -4
- package/dist/chunks/{chunk-7CEUBEEL.js → chunk-GJXUDC7M.js} +40 -24
- package/dist/chunks/{chunk-MJVFENH4.js → chunk-HCFZGHJQ.js} +3 -3
- package/dist/chunks/{chunk-EUKKWV3G.js → chunk-IO6ER43U.js} +1 -1
- package/dist/chunks/{chunk-A72CYF2R.js → chunk-J3BR4XR7.js} +1 -1
- package/dist/chunks/{chunk-TEDUOEHA.js → chunk-JKYYRNHA.js} +6 -6
- package/dist/chunks/{chunk-DVJ3JIXV.js → chunk-KVPGK3AI.js} +1 -1
- package/dist/chunks/{chunk-7PINHPNT.js → chunk-LEUINJWK.js} +1 -1
- package/dist/chunks/{chunk-6LCVEEGJ.js → chunk-LP7KEPZV.js} +3 -3
- package/dist/chunks/{chunk-SGBWEISH.js → chunk-MBNDFL52.js} +2 -2
- package/dist/chunks/{chunk-GZJHMFPW.js → chunk-MRYCR76X.js} +7 -7
- package/dist/chunks/{chunk-FRDEKTX2.js → chunk-O2IDQSID.js} +1 -1
- package/dist/chunks/{chunk-MEHR2GJ4.js → chunk-OACNFDDE.js} +5 -0
- package/dist/chunks/{chunk-NAZQXDXX.js → chunk-ORSEXNAN.js} +2 -2
- package/dist/chunks/{chunk-LZJRXAUA.js → chunk-OZDD4X2Z.js} +2 -2
- package/dist/chunks/{chunk-Z53B7NL7.js → chunk-QLMN2B6V.js} +2 -2
- package/dist/chunks/{chunk-NLXZIY6X.js → chunk-RUTPUYED.js} +7 -5
- package/dist/chunks/{chunk-D266WUDD.js → chunk-SYM2BMBO.js} +5 -5
- package/dist/chunks/{chunk-QTBLWSUJ.js → chunk-TEJDLWJQ.js} +1 -1
- package/dist/chunks/{chunk-NRPLKJWD.js → chunk-TJGTNEYL.js} +2 -2
- package/dist/chunks/{chunk-WP272KYV.js → chunk-TMSCTWTK.js} +1 -1
- package/dist/chunks/{chunk-HSBUM7AM.js → chunk-TR73N5K3.js} +2 -2
- package/dist/chunks/{chunk-GZN3CWWE.js → chunk-UVHQ6OC6.js} +5 -5
- package/dist/chunks/{chunk-FW3EG2VB.js → chunk-VH7BAQHO.js} +1 -1
- package/dist/chunks/{chunk-RPKBOARY.js → chunk-VUNR4TA5.js} +2 -2
- package/dist/chunks/{chunk-TXEKFUEK.js → chunk-WLNCMP4R.js} +4 -4
- package/dist/chunks/{chunk-47BCHVLO.js → chunk-XPXDYITB.js} +1 -1
- package/dist/chunks/{client-N5HTFSII.js → client-3O4IP7IV.js} +2 -2
- package/dist/chunks/{client-72ZFWAFV.js → client-MGVU6BYH.js} +1 -1
- package/dist/chunks/{client-QV5XYYCT.js → client-NN7D5KOY.js} +3 -3
- package/dist/chunks/{client-actions-3X7PCEC6.js → client-actions-EGFPGDRF.js} +5 -5
- package/dist/chunks/{components-XPBO2ZM5.js → components-JJJ6NOV7.js} +3 -3
- package/dist/chunks/{dangerous-LD5YGW2I.js → dangerous-KA4XBNPQ.js} +4 -4
- package/dist/chunks/{delete-current-file-DBXJ3X5W.js → delete-current-file-JWRQEJD7.js} +5 -5
- package/dist/chunks/{editor-seams-TOAYXI2M.js → editor-seams-SVNNJYML.js} +13 -13
- package/dist/chunks/{editor-store-LZFNEHYB.js → editor-store-F55ZEWJH.js} +1 -1
- package/dist/chunks/{export-watermark-M3URLKD7.js → export-watermark-2JR3IBVA.js} +5 -5
- package/dist/chunks/{eyedropper-4DFRX5AG.js → eyedropper-6GKVVVEE.js} +1 -1
- package/dist/chunks/{generate-media-APYNWFHP.js → generate-media-XPID2HER.js} +3 -3
- package/dist/chunks/{host-KJT6LWVX.js → host-I6KIHIVJ.js} +6 -6
- package/dist/chunks/{host-HE3UQKE3.js → host-JSYAWYNV.js} +4 -4
- package/dist/chunks/{integrations-SGZBIQUU.js → integrations-QLSOUP5Z.js} +1 -1
- package/dist/chunks/{libraries-7AF3R3GJ.js → libraries-AS5KS6VS.js} +5 -5
- package/dist/chunks/{live-K2YZRNKK.js → live-ZQRP46FK.js} +1 -1
- package/dist/chunks/{media-tool-VBUUZZIH.js → media-tool-M33SALHX.js} +1 -1
- package/dist/chunks/{new-file-QSMLBVRU.js → new-file-J7EH3YKS.js} +3 -3
- package/dist/chunks/{next-commerce-V2QELI45.js → next-commerce-7KAFFBWA.js} +5 -5
- package/dist/chunks/{plugin-WKKOD3IW.js → plugin-IQEMDPM3.js} +3 -3
- package/dist/chunks/{plugin-import-GALNL6SB.js → plugin-import-EILLZJLX.js} +17 -17
- package/dist/chunks/{presence-MSRD4SIK.js → presence-IJN6TO2U.js} +2 -2
- package/dist/chunks/{project-JTHWH3VF.js → project-GOALAIWW.js} +5 -5
- package/dist/chunks/{publish-site-25MGB4QH.js → publish-site-I5BQK7VR.js} +6 -6
- package/dist/chunks/{publish-store-2JZEJLSB.js → publish-store-WDLIOS5E.js} +7 -7
- package/dist/chunks/{raster-actions-2LTYHHOZ.js → raster-actions-7CCO2RS5.js} +1 -1
- package/dist/chunks/{runner-6GHGTHVR.js → runner-535UPLGO.js} +19 -19
- package/dist/chunks/{store-BEDJRBIQ.js → store-J33GD3OK.js} +6 -6
- package/dist/chunks/{storefront-QQTNLF3Q.js → storefront-VZ5JGP6Q.js} +6 -6
- package/dist/chunks/{storefront-prepare-QARBKWYY.js → storefront-prepare-DN64DLCR.js} +2 -2
- package/dist/chunks/{sync-A2YT72KR.js → sync-LN254R24.js} +5 -5
- package/dist/chunks/{tabs-JICBGZ27.js → tabs-SRMAPWDX.js} +8 -8
- package/dist/chunks/{team-6ZMFTJZK.js → team-P7EP6HAH.js} +1 -1
- package/dist/chunks/{team-client-TFMDDV25.js → team-client-ATTL4BUG.js} +1 -1
- package/dist/chunks/{tools-5AQKFJ2D.js → tools-F566WZLK.js} +2 -2
- package/dist/chunks/{tree-5DKDQLDR.js → tree-3MXMJZ2P.js} +1 -1
- package/dist/chunks/{ui-commands-YL4Q5VWA.js → ui-commands-2E6YO3G7.js} +13 -13
- package/dist/chunks/{versions-WFHFBJP2.js → versions-ZSGH7ZJN.js} +5 -5
- package/dist/chunks/{web-BQWY6BIF.js → web-22TCUPNQ.js} +4 -4
- package/dist/index.js +1 -1
- package/dist/templates/count.js +1 -1
- package/dist/templates/index.js +12 -12
- package/dist/templates/motion/landing-hero/index.js +4 -4
- package/dist/templates/motion/launch-trailer/document.js +12 -12
- package/dist/templates/motion/launch-trailer/index.js +4 -4
- package/dist/templates/motion/launch-trailer/scenes.js +3 -3
- package/dist/templates/motion/template-wall.js +2 -2
- package/dist/templates/print/knit-christmas-tree-sweater.js +2 -2
- package/dist/templates/print/knit-nordic-snowflake-sweater.js +2 -2
- package/dist/templates/print/knit-shared.js +3 -1
- package/dist/templates/print/knit-snowflake-beanie.js +2 -2
- package/dist/templates/themes/holidays.js +5 -5
- package/dist/templates/themes/index.js +6 -6
- package/package.json +1 -1
- package/src/templates/print/knit-christmas-tree-sweater.ts +21 -17
- package/src/templates/print/knit-nordic-snowflake-sweater.ts +45 -26
- package/src/templates/print/knit-shared.ts +118 -7
- package/src/templates/print/knit-snowflake-beanie.ts +9 -9
- package/types/templates/src/print/knit-shared.d.ts +49 -3
|
@@ -6,7 +6,7 @@ const __filename = __popcraftPath(import.meta.url);
|
|
|
6
6
|
const __dirname = __popcraftDirname(__filename);
|
|
7
7
|
import {
|
|
8
8
|
THEME_PACKS
|
|
9
|
-
} from "../../chunks/chunk-
|
|
9
|
+
} from "../../chunks/chunk-TEJDLWJQ.js";
|
|
10
10
|
import "../../chunks/chunk-7AYGPNDC.js";
|
|
11
11
|
import "../../chunks/chunk-ZRMCCN7M.js";
|
|
12
12
|
import "../../chunks/chunk-EZN4ZLJ4.js";
|
|
@@ -53,7 +53,7 @@ import "../../chunks/chunk-ANHGNY5Y.js";
|
|
|
53
53
|
import "../../chunks/chunk-FB35DOHJ.js";
|
|
54
54
|
import "../../chunks/chunk-MUEVSSOO.js";
|
|
55
55
|
import "../../chunks/chunk-NLOKKG5C.js";
|
|
56
|
-
import "../../chunks/chunk-
|
|
56
|
+
import "../../chunks/chunk-7KJGH5DA.js";
|
|
57
57
|
import "../../chunks/chunk-OGSIFN5S.js";
|
|
58
58
|
import "../../chunks/chunk-WZZV2ZRQ.js";
|
|
59
59
|
import "../../chunks/chunk-YHUBXLWS.js";
|
|
@@ -242,8 +242,8 @@ import "../../chunks/chunk-IB4GDTLR.js";
|
|
|
242
242
|
import "../../chunks/chunk-VDMJBQ6V.js";
|
|
243
243
|
import "../../chunks/chunk-MPNUZWOI.js";
|
|
244
244
|
import "../../chunks/chunk-6D452CFK.js";
|
|
245
|
-
import "../../chunks/chunk-
|
|
246
|
-
import "../../chunks/chunk-
|
|
245
|
+
import "../../chunks/chunk-GJXUDC7M.js";
|
|
246
|
+
import "../../chunks/chunk-AIF72RXH.js";
|
|
247
247
|
import "../../chunks/chunk-HQ7GVAPL.js";
|
|
248
248
|
import "../../chunks/chunk-XIYKYCOJ.js";
|
|
249
249
|
import "../../chunks/chunk-CUXD2345.js";
|
|
@@ -257,8 +257,8 @@ import "../../chunks/chunk-YWDYEBNY.js";
|
|
|
257
257
|
import "../../chunks/chunk-CSR7PK7G.js";
|
|
258
258
|
import "../../chunks/chunk-HVZSUESI.js";
|
|
259
259
|
import "../../chunks/chunk-HO7NTFM6.js";
|
|
260
|
-
import "../../chunks/chunk-
|
|
261
|
-
import "../../chunks/chunk-
|
|
260
|
+
import "../../chunks/chunk-BOJUI3OG.js";
|
|
261
|
+
import "../../chunks/chunk-FSM6RE22.js";
|
|
262
262
|
import "../../chunks/chunk-JXBXISRI.js";
|
|
263
263
|
import "../../chunks/chunk-ZGYXIUEX.js";
|
|
264
264
|
import "../../chunks/chunk-3IJQOFTZ.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@popcraft/kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The PopCraft design kit: everything PopCraft's own templates are made with — the Kit, every helper, style system and theme kit, every official template source to read and remix, the build and every check the official templates pass — plus the design-script runner and .popcraft output.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://popcraft.app/docs/api/design-reference",
|
|
@@ -7,18 +7,20 @@
|
|
|
7
7
|
|
|
8
8
|
import { Kit } from '../kit'
|
|
9
9
|
import { defineTemplate } from '../build'
|
|
10
|
-
import { KnitLayers, SWEATER_3XL, Stitches, YARN, between, clear, heart, knitPanel, knitPreset, lice, linear, radial, snowflake, tree, zigzag } from './knit-shared'
|
|
10
|
+
import { KnitLayers, SWEATER_3XL, Stitches, YARN, between, clear, solid, heart, knitPanel, knitPreset, lice, linear, radial, snowflake, tree, zigzag } from './knit-shared'
|
|
11
11
|
|
|
12
12
|
const NAME = 'Christmas tree knit sweater'
|
|
13
13
|
const PINE = 1, BLEACH = 2, MUSTARD = 3
|
|
14
14
|
const YARNS = [YARN.chili, YARN.pine, YARN.bleach, YARN.mustard]
|
|
15
15
|
|
|
16
16
|
function topBand(s: Stitches, top: number) {
|
|
17
|
+
s.motif('Collar zigzags')
|
|
17
18
|
zigzag(s, top, 20, 7, 3, BLEACH)
|
|
18
19
|
zigzag(s, top + 14, 20, 7, 3, PINE)
|
|
19
20
|
}
|
|
20
21
|
/** Little trees between two pine rules, above the hem. */
|
|
21
22
|
function forest(s: Stitches, bottom: number) {
|
|
23
|
+
s.motif('Forest band')
|
|
22
24
|
s.rows(bottom - 70, bottom - 67, PINE)
|
|
23
25
|
for (let x = 26; x < s.width; x += 52) tree(s, x, bottom - 60, 46, PINE, MUSTARD)
|
|
24
26
|
s.rows(bottom - 8, bottom - 5, PINE)
|
|
@@ -42,14 +44,12 @@ function starPts(cx: number, cy: number, r: number) {
|
|
|
42
44
|
* glowing star, shaded baubles. The canvas knits each blend as a halftone of the two yarns.
|
|
43
45
|
*/
|
|
44
46
|
function litTree(L: KnitLayers, cx: number, top: number, h: number) {
|
|
45
|
-
L.halo(cx, top + h * 0.45, h * 0.62, h * 0.6, Y.mustard, 0.6, 0.66, 'Tree glow')
|
|
46
47
|
const lit = linear(0, [[0, between(Y.pine, Y.mustard, 0.5)], [0.42, Y.pine], [1, Y.pine]])
|
|
47
48
|
tiers(cx, top, h).forEach((t, i) => L.poly(t, lit, `Tier ${i + 1}`))
|
|
48
49
|
const tw = Math.max(2, Math.round(h * 0.045))
|
|
49
50
|
L.rect(cx - tw, top + h * 0.86 - 1, tw * 2, h * 0.14 + 1, linear(0, [[0, between(Y.pine, Y.mustard, 0.3)], [1, Y.pine]]), 'Trunk')
|
|
50
51
|
const spots: [number, number][] = [[-22, 0.38], [26, 0.4], [-60, 0.6], [6, 0.63], [64, 0.61]]
|
|
51
52
|
spots.forEach(([dx, at], i) => L.bauble(cx + dx, top + h * at, 10, Y.bleach, i % 2 ? Y.mustard : Y.chili, between(i % 2 ? Y.mustard : Y.chili, Y.pine, 0.6)))
|
|
52
|
-
L.halo(cx, top - 6, 46, 46, Y.mustard, 0.8, 0.55, 'Star glow')
|
|
53
53
|
L.poly(starPts(cx, top - 6, 30), radial([[0, Y.bleach], [0.45, Y.mustard], [1, between(Y.mustard, Y.chili, 0.5)]], 0.45, 0.4, 0.6), 'Star')
|
|
54
54
|
}
|
|
55
55
|
/** A ribbon with the wordmark: a bleach band shaded at its lower edge, gold tails folding into shadow. */
|
|
@@ -61,7 +61,7 @@ function ribbon(L: KnitLayers, cx: number, cy: number, w: number, h: number, log
|
|
|
61
61
|
linear(side < 0 ? 0 : 180, [[0, Y.mustard], [1, between(Y.mustard, Y.chili, 0.65)]]), side < 0 ? 'Ribbon tail left' : 'Ribbon tail right')
|
|
62
62
|
}
|
|
63
63
|
L.rect(l, top, w, h, linear(90, [[0, Y.bleach], [0.62, Y.bleach], [1, between(Y.bleach, Y.mustard, 0.7)]]), 'Ribbon')
|
|
64
|
-
L.
|
|
64
|
+
L.badge(cx, cy, logo, Y.chili)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export default defineTemplate({
|
|
@@ -81,10 +81,12 @@ export default defineTemplate({
|
|
|
81
81
|
|
|
82
82
|
const f = new Stitches(front.width, front.height)
|
|
83
83
|
topBand(f, 54)
|
|
84
|
-
for (const [x, y, r] of [[78, 170, 34], [436, 170, 34], [62, 370, 26], [450, 370, 26], [120, 270, 18], [392, 270, 18]] as const) snowflake(f, x, y, r, BLEACH)
|
|
84
|
+
for (const [x, y, r, name] of [[78, 170, 34, 'top left'], [436, 170, 34, 'top right'], [62, 370, 26, 'lower left'], [450, 370, 26, 'lower right'], [120, 270, 18, 'small left'], [392, 270, 18, 'small right']] as const) snowflake(f.motif(`Snowflake ${name}`), x, y, r, BLEACH)
|
|
85
85
|
forest(f, 628)
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
knitPanel(k, k.sheet, front, YARNS, f, PINE, { blend: 'HALFTONE', dot: 5, under: L => {
|
|
87
|
+
// Pop-art light behind the tree: gold rays screened out from the star into the red.
|
|
88
|
+
L.sunburst(255, 150, 420, 28, [[0, Y.mustard, 0.95], [0.45, Y.mustard, 0.5], [1, Y.mustard, 0]], 'Sunburst', -Math.PI / 2)
|
|
89
|
+
}, layers: L => {
|
|
88
90
|
litTree(L, 255, 140, 380)
|
|
89
91
|
// A bleach ribbon wrapped round the tree, gold tails folded behind, with the PopCraft wordmark in red on it.
|
|
90
92
|
ribbon(L, 255, 476, 300, 104, 240)
|
|
@@ -92,29 +94,31 @@ export default defineTemplate({
|
|
|
92
94
|
|
|
93
95
|
const b = new Stitches(back.width, back.height)
|
|
94
96
|
topBand(b, 20)
|
|
97
|
+
b.motif('Snowflake row')
|
|
95
98
|
for (let x = 0; x < b.width; x += 128) snowflake(b, x, 120, 22, BLEACH)
|
|
96
99
|
forest(b, 628)
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
knitPanel(k, k.addSheet(knitPreset(back)), back, YARNS, b, PINE, { blend: 'HALFTONE', dot: 5, under: L => {
|
|
101
|
+
L.sunburst(255, 300, 420, 32, [[0, Y.mustard, 0.9], [0.5, Y.mustard, 0.45], [1, Y.mustard, 0]], 'Sunburst', -Math.PI / 2)
|
|
102
|
+
}, layers: L => {
|
|
99
103
|
// The wordmark across the shoulders: a pine drop shadow, then the letters in bleach warming to gold at their
|
|
100
104
|
// feet, in a gold glow; a lit tree either side under it.
|
|
101
|
-
L.
|
|
102
|
-
L.logo(259, 305, 420, linear(90, [[0, Y.pine]]), 'Logo shadow')
|
|
103
|
-
L.logo(255, 300, 420, linear(90, [[0, Y.bleach], [0.55, Y.bleach], [1, between(Y.bleach, Y.mustard, 0.75)]]))
|
|
105
|
+
L.badge(255, 300, 420, Y.bleach, { outline: Y.pine, ring: 3, shadow: Y.mustard, dx: 5, dy: 5 })
|
|
104
106
|
for (const x of [80, 431]) litTree(L, x, 420, 120)
|
|
105
107
|
} })
|
|
106
108
|
|
|
107
109
|
for (const sleeve of [right, left]) {
|
|
108
110
|
const s = new Stitches(sleeve.width, sleeve.height)
|
|
109
|
-
for (let y =
|
|
110
|
-
if (i % 2) snowflake(s, 255, y, 34, BLEACH)
|
|
111
|
-
else heart(s, 255, y, 30, BLEACH)
|
|
111
|
+
for (let y = 80, i = 0; y < 460; y += 100, i++) {
|
|
112
|
+
if (i % 2) snowflake(s.motif(`Snowflake ${i + 1}`), 255, y, 34, BLEACH)
|
|
113
|
+
else heart(s.motif(`Heart ${i + 1}`), 255, y, 30, BLEACH)
|
|
112
114
|
}
|
|
113
115
|
forest(s, 628)
|
|
114
|
-
lice(s, 30, 540, 30, BLEACH, clear(s, 7))
|
|
116
|
+
lice(s.motif('Sprinkles'), 30, 540, 30, BLEACH, clear(s, 7))
|
|
115
117
|
knitPanel(k, k.addSheet(knitPreset(sleeve)), sleeve, YARNS, s, PINE, { blend: 'HALFTONE', dot: 5, layers: L => {
|
|
116
118
|
// Dusk over the forest: the red ground screened into pine as it nears the hem.
|
|
117
|
-
|
|
119
|
+
// Candy-cane stripes between pine rules above the forest.
|
|
120
|
+
L.rect(0, 492, sleeve.width, 4, solid(Y.pine), 'Stripe rule')
|
|
121
|
+
L.stripes(496, 552, 18, 9, solid(Y.bleach))
|
|
118
122
|
} })
|
|
119
123
|
}
|
|
120
124
|
return k.doc
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { Kit } from '../kit'
|
|
8
8
|
import { defineTemplate } from '../build'
|
|
9
|
-
import { SWEATER_3XL, Stitches, YARN, clear, diamonds, knitPanel, knitPreset,
|
|
9
|
+
import { SWEATER_3XL, Stitches, YARN, clear, diamonds, knitPanel, knitPreset, lice, linear, solid, nordicStar, popcraftLogo, snowflake, zigzag } from './knit-shared'
|
|
10
10
|
|
|
11
11
|
const NAME = 'Nordic snowflake knit sweater'
|
|
12
12
|
// Palette slots: 0 base, 1 trim, then the design's.
|
|
@@ -15,12 +15,14 @@ const YARNS = [YARN.navy, YARN.bleach, YARN.chili]
|
|
|
15
15
|
|
|
16
16
|
/** The yoke: stars between zigzags, under the collar's trim rows. */
|
|
17
17
|
function yoke(s: Stitches, top: number) {
|
|
18
|
-
zigzag(s, top, 24, 8, 3, CHILI)
|
|
18
|
+
zigzag(s.motif('Yoke zigzags'), top, 24, 8, 3, CHILI)
|
|
19
|
+
s.motif('Yoke stars')
|
|
19
20
|
for (let x = 32; x < s.width; x += 64) nordicStar(s, x, top + 44, 26, BLEACH, NAVY)
|
|
20
|
-
zigzag(s, top + 78, 24, 8, 3, CHILI)
|
|
21
|
+
zigzag(s.motif('Yoke zigzags'), top + 78, 24, 8, 3, CHILI)
|
|
21
22
|
}
|
|
22
23
|
/** Diamonds between two bleach rules, above the hem. */
|
|
23
24
|
function hemBand(s: Stitches, bottom: number) {
|
|
25
|
+
s.motif('Hem band')
|
|
24
26
|
s.rows(bottom - 62, bottom - 59, BLEACH)
|
|
25
27
|
diamonds(s, bottom - 34, 40, 36, CHILI, BLEACH)
|
|
26
28
|
s.rows(bottom - 9, bottom - 6, BLEACH)
|
|
@@ -43,43 +45,60 @@ export default defineTemplate({
|
|
|
43
45
|
|
|
44
46
|
const f = new Stitches(front.width, front.height)
|
|
45
47
|
yoke(f, 52)
|
|
46
|
-
snowflake(f, 255, 282, 100, BLEACH)
|
|
47
|
-
snowflake(f, 84, 262, 44, BLEACH)
|
|
48
|
-
snowflake(f, 426, 262, 44, BLEACH)
|
|
49
|
-
for (const x of [44, 467]) snowflake(f, x, 466, 24, CHILI)
|
|
48
|
+
snowflake(f.motif('Big snowflake'), 255, 282, 100, BLEACH)
|
|
49
|
+
snowflake(f.motif('Snowflake left'), 84, 262, 44, BLEACH)
|
|
50
|
+
snowflake(f.motif('Snowflake right'), 426, 262, 44, BLEACH)
|
|
51
|
+
for (const x of [44, 467]) snowflake(f.motif(`Red snowflake ${x < 255 ? 'left' : 'right'}`), x, 466, 24, CHILI)
|
|
50
52
|
hemBand(f, 628)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
knitPanel(k, k.sheet, front, YARNS, f, BLEACH, { blend: 'HALFTONE', dot: 4, under: L => {
|
|
54
|
+
// Northern lights: two curtains, each a thin red crest with frost falling from it, screened into the navy.
|
|
55
|
+
for (const [y, ph] of [[190, 0.3], [330, 2.4]] as const) {
|
|
56
|
+
L.wave(y + 34, 30, 300, 70, ph, linear(90, [[0, YARN.bleach, 0.8], [0.35, YARN.bleach, 0.35], [1, YARN.bleach, 0]]), 'Aurora frost')
|
|
57
|
+
L.wave(y, 30, 300, 6, ph, solid(YARN.chili), 'Aurora crest')
|
|
58
|
+
}
|
|
59
|
+
// The medallion is a window of plain night round the big snowflake.
|
|
60
|
+
L.ellipse(255, 282, 126, 126, solid(YARN.navy), 'Medallion')
|
|
61
|
+
}, layers: L => {
|
|
53
62
|
// Frost: an icy ring round the big snowflake, and a frost rising from the hem band, navy dithered with bleach.
|
|
54
|
-
|
|
55
|
-
L.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
L.
|
|
63
|
+
// A medallion round the big snowflake: a solid red ring inside a ring of bleach dots.
|
|
64
|
+
L.ring(255, 282, 124, 5, solid(YARN.chili), 'Medallion ring')
|
|
65
|
+
L.dots(255, 282, 136, 9, solid(YARN.bleach), 'Medallion dots')
|
|
66
|
+
// Snowdrift: a ruled band above the hem, screened from navy to bleach.
|
|
67
|
+
L.rect(0, 524, f.width, 3, solid(YARN.bleach), 'Drift rule')
|
|
68
|
+
L.rect(0, 527, f.width, 39, linear(90, [[0, YARN.bleach, 0.1], [1, YARN.bleach, 0.65]]), 'Snowdrift')
|
|
69
|
+
// The wordmark under it, solid bleach on a red drop shadow.
|
|
70
|
+
L.badge(255, 462, 290, YARN.bleach, { shadow: YARN.chili, dx: 4, dy: 4 })
|
|
59
71
|
} })
|
|
60
72
|
|
|
61
73
|
const b = new Stitches(back.width, back.height)
|
|
62
74
|
yoke(b, 20)
|
|
63
75
|
// The wordmark across the back in red, ringed in bleach, over a row of little red snowflakes.
|
|
64
|
-
popcraftLogo(b, 255, 290, 410, CHILI, { c: BLEACH, ring: 4 })
|
|
76
|
+
popcraftLogo(b.motif('PopCraft logo'), 255, 290, 410, CHILI, { c: BLEACH, ring: 4 })
|
|
77
|
+
b.motif('Red snowflake row')
|
|
65
78
|
for (let x = 32; x < b.width; x += 64) snowflake(b, x, 470, 20, CHILI)
|
|
66
79
|
hemBand(b, 628)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
knitPanel(k, k.addSheet(knitPreset(back)), back, YARNS, b, BLEACH, { blend: 'HALFTONE', dot: 4, under: L => {
|
|
81
|
+
// Northern lights: two curtains, each a thin red crest with frost falling from it, screened into the navy.
|
|
82
|
+
for (const [y, ph] of [[140, 0.3], [370, 2.4]] as const) {
|
|
83
|
+
L.wave(y + 34, 30, 300, 70, ph, linear(90, [[0, YARN.bleach, 0.8], [0.35, YARN.bleach, 0.35], [1, YARN.bleach, 0]]), 'Aurora frost')
|
|
84
|
+
L.wave(y, 30, 300, 6, ph, solid(YARN.chili), 'Aurora crest')
|
|
85
|
+
}
|
|
86
|
+
}, layers: L => {
|
|
87
|
+
L.rect(0, 524, b.width, 3, solid(YARN.bleach), 'Drift rule')
|
|
88
|
+
L.rect(0, 527, b.width, 39, linear(90, [[0, YARN.bleach, 0.1], [1, YARN.bleach, 0.65]]), 'Snowdrift')
|
|
74
89
|
} })
|
|
75
90
|
|
|
76
91
|
for (const sleeve of [right, left]) {
|
|
77
92
|
const s = new Stitches(sleeve.width, sleeve.height)
|
|
78
|
-
for (let y =
|
|
93
|
+
for (let y = 100; y < 480; y += 125) snowflake(s.motif(`Snowflake ${(y - 100) / 125 + 1}`), 255, y, 44, BLEACH)
|
|
79
94
|
hemBand(s, 628)
|
|
80
|
-
lice(s, 40, 540, 32, BLEACH, clear(s, 6))
|
|
81
|
-
knitPanel(k, k.addSheet(knitPreset(sleeve)), sleeve, YARNS, s, BLEACH, {
|
|
82
|
-
|
|
95
|
+
lice(s.motif('Sprinkles'), 40, 540, 32, BLEACH, clear(s, 6))
|
|
96
|
+
knitPanel(k, k.addSheet(knitPreset(sleeve)), sleeve, YARNS, s, BLEACH, { blend: 'HALFTONE', dot: 4, under: L => {
|
|
97
|
+
L.wave(270 + 34, 30, 300, 70, 1.2, linear(90, [[0, YARN.bleach, 0.8], [0.35, YARN.bleach, 0.35], [1, YARN.bleach, 0]]), 'Aurora frost')
|
|
98
|
+
L.wave(270, 30, 300, 6, 1.2, solid(YARN.chili), 'Aurora crest')
|
|
99
|
+
}, layers: L => {
|
|
100
|
+
L.rect(0, 524, sleeve.width, 3, solid(YARN.bleach), 'Drift rule')
|
|
101
|
+
L.rect(0, 527, sleeve.width, 39, linear(90, [[0, YARN.bleach, 0.1], [1, YARN.bleach, 0.65]]), 'Snowdrift')
|
|
83
102
|
} })
|
|
84
103
|
}
|
|
85
104
|
return k.doc
|
|
@@ -53,9 +53,28 @@ export const knitPreset = (p: KnitPanel): PagePreset => ({ id: `knit-${p.width}x
|
|
|
53
53
|
/** A panel's stitches, as palette slots (0 = the base). Everything draws in stitch coordinates. */
|
|
54
54
|
export class Stitches {
|
|
55
55
|
readonly cells: Uint8Array
|
|
56
|
-
|
|
56
|
+
/** Which motif layer drew each stitch last (-1: painted, not a layer). */
|
|
57
|
+
readonly owner: Int32Array
|
|
58
|
+
/** The motif layers, in the order first drawn: a name and a palette slot each. */
|
|
59
|
+
readonly motifs: { name: string, c: number }[] = []
|
|
60
|
+
private current: string | null = null
|
|
61
|
+
constructor(readonly width: number, readonly height: number) {
|
|
62
|
+
this.cells = new Uint8Array(width * height)
|
|
63
|
+
this.owner = new Int32Array(width * height).fill(-1)
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* What is drawn from here on is the motif `name`: knitPanel makes it a vector layer inside the stitch canvas (one
|
|
67
|
+
* per yarn it uses), so it can be moved, recoloured or deleted like any shape. `null` paints stitches directly.
|
|
68
|
+
*/
|
|
69
|
+
motif(name: string | null) { this.current = name; return this }
|
|
57
70
|
set(x: number, y: number, c: number) {
|
|
58
|
-
if (x
|
|
71
|
+
if (x < 0 || y < 0 || x >= this.width || y >= this.height) return
|
|
72
|
+
const i = y * this.width + x
|
|
73
|
+
this.cells[i] = c
|
|
74
|
+
if (this.current === null) { this.owner[i] = -1; return }
|
|
75
|
+
let m = this.motifs.findIndex(l => l.name === this.current && l.c === c)
|
|
76
|
+
if (m < 0) { m = this.motifs.length; this.motifs.push({ name: this.current, c }) }
|
|
77
|
+
this.owner[i] = m
|
|
59
78
|
}
|
|
60
79
|
get(x: number, y: number) { return this.cells[y * this.width + x] }
|
|
61
80
|
/** Every stitch in the box for which `inside(x, y)` holds, tested at the stitch's centre. */
|
|
@@ -270,9 +289,19 @@ export const clear = (s: Stitches, pad: number) => (x: number, y: number) => {
|
|
|
270
289
|
* the locked trim bands (in the `trim` palette role the template defines). Trim rows are knitted in the trim yarn whatever is drawn there, so they are filled with it.
|
|
271
290
|
*/
|
|
272
291
|
export function knitPanel(k: Kit, sheet: string, panel: KnitPanel, yarns: readonly string[], s: Stitches, trimSlot: number,
|
|
273
|
-
o: { blend?: 'DITHER' | 'HALFTONE', dot?: number, layers?: (L: KnitLayers) => void } = {}) {
|
|
292
|
+
o: { blend?: 'DITHER' | 'HALFTONE', dot?: number, under?: (L: KnitLayers) => void, layers?: (L: KnitLayers) => void } = {}) {
|
|
274
293
|
s.removeStrays()
|
|
294
|
+
s.motif(null)
|
|
275
295
|
for (const [a, b] of panel.trim) s.rows(a, b, trimSlot)
|
|
296
|
+
// Motifs become layers: each motif layer takes the stitches it drew last that still knit in its yarn (stray
|
|
297
|
+
// clean-up may have changed a few); everything else stays painted. The painted stitches under a layer are the base.
|
|
298
|
+
const masks = s.motifs.map(() => new Uint8Array(s.width * s.height))
|
|
299
|
+
const painted = s.cells.slice()
|
|
300
|
+
for (let i = 0; i < s.cells.length; i++) {
|
|
301
|
+
const m = s.owner[i]
|
|
302
|
+
if (m >= 0 && s.motifs[m].c === s.cells[i]) { masks[m][i] = 1; painted[i] = 0 }
|
|
303
|
+
}
|
|
304
|
+
s.cells.set(painted)
|
|
276
305
|
const chars = 'abcdefgh'
|
|
277
306
|
const key: Record<string, string> = {}
|
|
278
307
|
yarns.forEach((hex, i) => { key[chars[i]] = hex })
|
|
@@ -288,10 +317,13 @@ export function knitPanel(k: Kit, sheet: string, panel: KnitPanel, yarns: readon
|
|
|
288
317
|
const grid = k.pixels(area, [rows], key, { cell: CELL, name: 'Stitches', palette: [...yarns], absolute: { x: 0, y: 0 } })
|
|
289
318
|
// Art dropped on the stitches snaps to the yarns, as on a knit Popprint builds.
|
|
290
319
|
k.patch(grid, { layerPaletteSnap: true, layerBlend: o.blend ?? 'DITHER', ...(o.dot ? { layerHalftoneSize: o.dot } : {}) })
|
|
291
|
-
|
|
320
|
+
const L = new KnitLayers(k, grid, s.width, s.height)
|
|
321
|
+
o.under?.(L)
|
|
322
|
+
s.motifs.forEach((m, i) => L.mask(masks[i], s.width, s.height, solid(yarns[m.c]), s.motifs.filter(n => n.name === m.name).length > 1 ? `${m.name} · ${yarnName(yarns[m.c])}` : m.name))
|
|
323
|
+
o.layers?.(L)
|
|
292
324
|
// The trim yarn is knitted over whatever is drawn in the trim rows, so the layers are kept out of them too: a
|
|
293
325
|
// band of the trim yarn on top, at the grid's own level.
|
|
294
|
-
|
|
326
|
+
for (const [a, b] of panel.trim) L.rect(0, a, panel.width, b - a + 1, [{ ...k.paint('trim')[0] }], 'Trim yarn')
|
|
295
327
|
for (const [a, b] of panel.trim) {
|
|
296
328
|
const id = k.rect(sheet, panel.width * CELL, (b - a + 1) * CELL, 'trim', { name: 'Trim', absolute: { x: 0, y: a * CELL } })
|
|
297
329
|
k.patch(id, { locked: true })
|
|
@@ -324,10 +356,14 @@ export function between(a: string, b: string, t = 0.5) {
|
|
|
324
356
|
return '#' + [0, 1, 2].map(i => Math.round(p(a, i) + (p(b, i) - p(a, i)) * t).toString(16).padStart(2, '0')).join('')
|
|
325
357
|
}
|
|
326
358
|
|
|
359
|
+
/** A flat fill in one yarn. */
|
|
360
|
+
export const solid = (h: string): Paint[] => [{ type: 'SOLID', color: hex(h), opacity: 1, visible: true } as Paint]
|
|
361
|
+
const yarnName = (h: string) => (Object.entries(YARN).find(([, v]) => v === h)?.[0] ?? h).replace(/^./, c => c.toUpperCase())
|
|
362
|
+
|
|
327
363
|
/** Shapes added to a stitch canvas, in stitch coordinates; each is a layer the canvas blends into yarns. */
|
|
328
364
|
export class KnitLayers {
|
|
329
|
-
constructor(private k: Kit, private grid: string) {}
|
|
330
|
-
|
|
365
|
+
constructor(private k: Kit, private grid: string, readonly width = 0, readonly height = 0) {}
|
|
366
|
+
add(x0: number, y0: number, w: number, h: number, paths: VectorPath[], fill: Paint[], name: string) {
|
|
331
367
|
return this.k.vector(this.grid, w * CELL, h * CELL, paths, fill, { name, absolute: { x: x0 * CELL, y: y0 * CELL } })
|
|
332
368
|
}
|
|
333
369
|
/** A closed shape through `pts` (stitches). */
|
|
@@ -353,6 +389,81 @@ export class KnitLayers {
|
|
|
353
389
|
bauble(cx: number, cy: number, r: number, light: string, body: string, shadow: string, name = 'Bauble') {
|
|
354
390
|
return this.ellipse(cx, cy, r, r, radial([[0, light], [0.35, body], [1, shadow]], 0.36, 0.32, 0.75), name)
|
|
355
391
|
}
|
|
392
|
+
/** A vector layer covering exactly the stitches set in `mask` (row runs), cropped to their box. */
|
|
393
|
+
mask(bits: Uint8Array, w: number, h: number, fill: Paint[], name: string) {
|
|
394
|
+
let x0 = w, y0 = h, x1 = -1, y1 = -1
|
|
395
|
+
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) if (bits[y * w + x]) { x0 = Math.min(x0, x); y0 = Math.min(y0, y); x1 = Math.max(x1, x); y1 = Math.max(y1, y) }
|
|
396
|
+
if (x1 < 0) return null
|
|
397
|
+
const paths: VectorPath[] = []
|
|
398
|
+
for (let y = y0; y <= y1; y++) for (let x = x0; x <= x1; x++) {
|
|
399
|
+
if (!bits[y * w + x]) continue
|
|
400
|
+
let e = x
|
|
401
|
+
while (e + 1 <= x1 && bits[y * w + e + 1]) e++
|
|
402
|
+
const a = (x - x0) * CELL, b = (e + 1 - x0) * CELL, t = (y - y0) * CELL, u = (y + 1 - y0) * CELL
|
|
403
|
+
paths.push({ points: [{ x: a, y: t }, { x: b, y: t }, { x: b, y: u }, { x: a, y: u }], closed: true })
|
|
404
|
+
x = e
|
|
405
|
+
}
|
|
406
|
+
return this.add(x0, y0, x1 - x0 + 1, y1 - y0 + 1, paths, fill, name)
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Pop-art sunburst: `rays` wedges round (cx, cy) out to `r`, every other one filled, each with `fill` (a radial
|
|
410
|
+
* gradient fading outward reads as light). Hard-edged wedges, so the screen inside them looks designed.
|
|
411
|
+
*/
|
|
412
|
+
sunburst(cx: number, cy: number, r: number, rays: number, light: readonly Stop[], name = 'Sunburst', turn = 0) {
|
|
413
|
+
const ids: string[] = []
|
|
414
|
+
for (let i = 0; i < rays; i += 2) {
|
|
415
|
+
const a0 = turn + (i / rays) * Math.PI * 2, a1 = turn + ((i + 1) / rays) * Math.PI * 2
|
|
416
|
+
const pts: [number, number][] = [[cx, cy]]
|
|
417
|
+
for (let s = 0; s <= 6; s++) { const a = a0 + ((a1 - a0) * s) / 6; pts.push([cx + Math.cos(a) * r, cy + Math.sin(a) * r]) }
|
|
418
|
+
// The light is centred on the burst, not on each ray's own box.
|
|
419
|
+
const xs = pts.map(p => p[0]), ys = pts.map(p => p[1]), x0 = Math.min(...xs), y0 = Math.min(...ys), bw = Math.max(...xs) - x0 || 1, bh = Math.max(...ys) - y0 || 1
|
|
420
|
+
const fill = [{ type: 'GRADIENT_RADIAL', gradientStops: stops(light), gradientHandlePositions: [{ x: (cx - x0) / bw, y: (cy - y0) / bh }, { x: (cx - x0 + r) / bw, y: (cy - y0) / bh }, { x: (cx - x0) / bw, y: (cy - y0 + r) / bh }], opacity: 1, visible: true } as Paint]
|
|
421
|
+
ids.push(this.poly(pts, fill, `${name} ray ${i / 2 + 1}`))
|
|
422
|
+
}
|
|
423
|
+
return ids
|
|
424
|
+
}
|
|
425
|
+
/** A ribbon of light across the panel: a band `thick` stitches deep riding a sine wave. */
|
|
426
|
+
wave(yc: number, amp: number, period: number, thick: number, phase: number, fill: Paint[], name = 'Aurora') {
|
|
427
|
+
const top: [number, number][] = [], bot: [number, number][] = []
|
|
428
|
+
for (let x = -4; x <= this.width + 4; x += 4) {
|
|
429
|
+
const y = yc + amp * Math.sin((x / period) * Math.PI * 2 + phase), t = thick
|
|
430
|
+
top.push([x, y - t / 2]); bot.push([x, y + t / 2])
|
|
431
|
+
}
|
|
432
|
+
return this.poly([...top, ...bot.reverse()], fill, name)
|
|
433
|
+
}
|
|
434
|
+
/** Diagonal candy stripes between rows y0 and y1: bands `w` wide every `period`, slanting by the band's height. */
|
|
435
|
+
stripes(y0: number, y1: number, period: number, w: number, fill: Paint[], name = 'Candy stripes') {
|
|
436
|
+
return this.mask(this.bits((x, y) => y >= y0 && y < y1 && (((x + (y - y0)) % period) + period) % period < w), this.width, this.height, fill, name)
|
|
437
|
+
}
|
|
438
|
+
/** A panel-sized stitch mask from a test on each stitch. */
|
|
439
|
+
private bits(inside: (x: number, y: number) => boolean) {
|
|
440
|
+
const b = new Uint8Array(this.width * this.height)
|
|
441
|
+
for (let y = 0; y < this.height; y++) for (let x = 0; x < this.width; x++) if (inside(x, y)) b[y * this.width + x] = 1
|
|
442
|
+
return b
|
|
443
|
+
}
|
|
444
|
+
/** A ring of stitches `w` thick at radius `r` round (cx, cy): a medallion frame. */
|
|
445
|
+
ring(cx: number, cy: number, r: number, w: number, fill: Paint[], name = 'Ring') {
|
|
446
|
+
return this.mask(this.bits((x, y) => { const d = Math.hypot(x - cx, y - cy); return d >= r && d < r + w }), this.width, this.height, fill, name)
|
|
447
|
+
}
|
|
448
|
+
/** A dotted ring: single dots `gap` stitches apart round a circle, each a 2×2 stitch block (never a lone stitch). */
|
|
449
|
+
dots(cx: number, cy: number, r: number, gap: number, fill: Paint[], name = 'Dotted ring') {
|
|
450
|
+
const n = Math.round((2 * Math.PI * r) / gap), pts = Array.from({ length: n }, (_, i) => [Math.round(cx + Math.cos((i / n) * 2 * Math.PI) * r), Math.round(cy + Math.sin((i / n) * 2 * Math.PI) * r)])
|
|
451
|
+
return this.mask(this.bits((x, y) => pts.some(([px, py]) => x >= px && x <= px + 1 && y >= py && y <= py + 1)), this.width, this.height, fill, name)
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* The wordmark, solid, with what makes knit lettering read from across a room: an outline `ring` stitches thick
|
|
455
|
+
* and/or a drop shadow offset (dx, dy), each a solid yarn — never a blend inside the letters.
|
|
456
|
+
*/
|
|
457
|
+
badge(cx: number, cy: number, width: number, letters: string, o: { outline?: string, ring?: number, shadow?: string, dx?: number, dy?: number } = {}) {
|
|
458
|
+
const L = logoStitches(width), x0 = Math.round(cx - width / 2), y0 = Math.round(cy - L.height / 2)
|
|
459
|
+
const at = (x: number, y: number) => L.at(x - x0, y - y0)
|
|
460
|
+
if (o.shadow) { const dx = o.dx ?? 3, dy = o.dy ?? 3; this.mask(this.bits((x, y) => at(x - dx, y - dy)), this.width, this.height, solid(o.shadow), 'Logo shadow') }
|
|
461
|
+
if (o.outline) {
|
|
462
|
+
const r = o.ring ?? 2
|
|
463
|
+
this.mask(this.bits((x, y) => { for (let dy = -r; dy <= r; dy++) for (let dx = -r; dx <= r; dx++) if (dx * dx + dy * dy <= r * r + r && at(x + dx, y + dy)) return true; return false }), this.width, this.height, solid(o.outline), 'Logo outline')
|
|
464
|
+
}
|
|
465
|
+
return this.mask(this.bits(at), this.width, this.height, solid(letters), 'PopCraft logo')
|
|
466
|
+
}
|
|
356
467
|
/** The PopCraft wordmark as one vector layer, `width` stitches wide, centred on (cx, cy), filled with `fill`. */
|
|
357
468
|
logo(cx: number, cy: number, width: number, fill: Paint[], name = 'PopCraft logo') {
|
|
358
469
|
const L = logoStitches(width), x0 = Math.round(cx - width / 2), y0 = Math.round(cy - L.height / 2)
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { Kit } from '../kit'
|
|
7
7
|
import { defineTemplate } from '../build'
|
|
8
|
-
import { BEANIE, Stitches, YARN, clear, heart, knitPanel, knitPreset, lice,
|
|
8
|
+
import { BEANIE, Stitches, YARN, clear, heart, knitPanel, knitPreset, lice, logoStitches, nordicStar, snowflake, zigzag } from './knit-shared'
|
|
9
9
|
|
|
10
10
|
const NAME = 'Snowflake knit beanie'
|
|
11
11
|
// No trim: the palette is the base, then the design's yarns (Popprint reads the base from the first).
|
|
@@ -27,22 +27,22 @@ export default defineTemplate({
|
|
|
27
27
|
const k = new Kit(NAME, knitPreset(panel))
|
|
28
28
|
k.palette({ trim: YARN.pine })
|
|
29
29
|
const s = new Stitches(panel.width, panel.height)
|
|
30
|
+
s.motif('Snowflake row')
|
|
30
31
|
for (let x = 0; x < s.width; x += 82) snowflake(s, x + 41, 40, 24, BLEACH)
|
|
31
|
-
zigzag(s, 80, 20, 7, 3, CHILI)
|
|
32
|
+
zigzag(s.motif('Zigzag top'), 80, 20, 7, 3, CHILI)
|
|
32
33
|
// The PopCraft wordmark at the centre of the star band, a star either side of it.
|
|
33
34
|
const half = logoStitches(150).width / 2
|
|
35
|
+
s.motif('Nordic stars')
|
|
34
36
|
for (let x = 0; x < s.width; x += 58) if (x + 29 + 27 < 205 - half || x + 29 - 27 > 205 + half) nordicStar(s, x + 29, 124, 24, BLEACH, PINE)
|
|
35
|
-
zigzag(s, 160, 20, 7, 3, CHILI)
|
|
37
|
+
zigzag(s.motif('Zigzag bottom'), 160, 20, 7, 3, CHILI)
|
|
38
|
+
s.motif('Hearts')
|
|
36
39
|
for (let x = 0; x < s.width; x += 41) heart(s, x + 20, 198, 11, BLEACH)
|
|
37
|
-
lice(s, 6, 70, 26, BLEACH, clear(s, 6))
|
|
40
|
+
lice(s.motif('Sprinkles'), 6, 70, 26, BLEACH, clear(s, 6))
|
|
38
41
|
knitPanel(k, k.sheet, panel, YARNS, s, PINE, { layers: L => {
|
|
39
42
|
// A glow behind the wordmark and the wordmark itself as layers, dithered: bleach letters warming toward red at
|
|
40
43
|
// their feet, in a soft bleach halo.
|
|
41
|
-
|
|
42
|
-
L.
|
|
43
|
-
L.logo(205, 121, 150, linear(90, [[0, YARN.bleach], [0.55, YARN.bleach], [1, between(YARN.bleach, YARN.chili, 0.45)]]))
|
|
44
|
-
// Ombré at the crown: the snowflake band dithered from bleach-frosted to plain pine.
|
|
45
|
-
L.rect(0, 0, s.width, 18, linear(90, [[0, YARN.bleach, 0.55], [1, YARN.bleach, 0]]), 'Crown frost')
|
|
44
|
+
// The wordmark as a knitted badge: solid bleach letters, a red outline two stitches thick.
|
|
45
|
+
L.badge(205, 121, 150, YARN.bleach, { outline: YARN.chili, ring: 2 })
|
|
46
46
|
} })
|
|
47
47
|
return k.doc
|
|
48
48
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Kit } from '../kit.js';
|
|
2
|
-
import type { Paint } from '../../../lib/document/types.js';
|
|
2
|
+
import type { Paint, VectorPath } from '../../../lib/document/types.js';
|
|
3
3
|
import type { PagePreset } from '../../../lib/presets/page-presets.js';
|
|
4
4
|
/** Printful's yarns used here (the 36 are in Popprint's catalog). */
|
|
5
5
|
export declare const YARN: {
|
|
@@ -30,7 +30,20 @@ export declare class Stitches {
|
|
|
30
30
|
readonly width: number;
|
|
31
31
|
readonly height: number;
|
|
32
32
|
readonly cells: Uint8Array;
|
|
33
|
+
/** Which motif layer drew each stitch last (-1: painted, not a layer). */
|
|
34
|
+
readonly owner: Int32Array;
|
|
35
|
+
/** The motif layers, in the order first drawn: a name and a palette slot each. */
|
|
36
|
+
readonly motifs: {
|
|
37
|
+
name: string;
|
|
38
|
+
c: number;
|
|
39
|
+
}[];
|
|
40
|
+
private current;
|
|
33
41
|
constructor(width: number, height: number);
|
|
42
|
+
/**
|
|
43
|
+
* What is drawn from here on is the motif `name`: knitPanel makes it a vector layer inside the stitch canvas (one
|
|
44
|
+
* per yarn it uses), so it can be moved, recoloured or deleted like any shape. `null` paints stitches directly.
|
|
45
|
+
*/
|
|
46
|
+
motif(name: string | null): this;
|
|
34
47
|
set(x: number, y: number, c: number): void;
|
|
35
48
|
get(x: number, y: number): number;
|
|
36
49
|
/** Every stitch in the box for which `inside(x, y)` holds, tested at the stitch's centre. */
|
|
@@ -99,6 +112,7 @@ export declare const clear: (s: Stitches, pad: number) => (x: number, y: number)
|
|
|
99
112
|
export declare function knitPanel(k: Kit, sheet: string, panel: KnitPanel, yarns: readonly string[], s: Stitches, trimSlot: number, o?: {
|
|
100
113
|
blend?: 'DITHER' | 'HALFTONE';
|
|
101
114
|
dot?: number;
|
|
115
|
+
under?: (L: KnitLayers) => void;
|
|
102
116
|
layers?: (L: KnitLayers) => void;
|
|
103
117
|
}): void;
|
|
104
118
|
/** A gradient stop: position 0–1, a yarn hex (or any colour between yarns), and an alpha. */
|
|
@@ -109,12 +123,16 @@ export declare function linear(angle: number, s: readonly Stop[]): Paint[];
|
|
|
109
123
|
export declare function radial(s: readonly Stop[], cx?: number, cy?: number, r?: number): Paint[];
|
|
110
124
|
/** The colour halfway (or `t` of the way) between two yarns: what the canvas knits as a mix of them. */
|
|
111
125
|
export declare function between(a: string, b: string, t?: number): string;
|
|
126
|
+
/** A flat fill in one yarn. */
|
|
127
|
+
export declare const solid: (h: string) => Paint[];
|
|
112
128
|
/** Shapes added to a stitch canvas, in stitch coordinates; each is a layer the canvas blends into yarns. */
|
|
113
129
|
export declare class KnitLayers {
|
|
114
130
|
private k;
|
|
115
131
|
private grid;
|
|
116
|
-
|
|
117
|
-
|
|
132
|
+
readonly width: number;
|
|
133
|
+
readonly height: number;
|
|
134
|
+
constructor(k: Kit, grid: string, width?: number, height?: number);
|
|
135
|
+
add(x0: number, y0: number, w: number, h: number, paths: VectorPath[], fill: Paint[], name: string): string;
|
|
118
136
|
/** A closed shape through `pts` (stitches). */
|
|
119
137
|
poly(pts: readonly (readonly [number, number])[], fill: Paint[], name: string): string;
|
|
120
138
|
/** An ellipse round (cx, cy), `rx` by `ry` stitches. */
|
|
@@ -124,6 +142,34 @@ export declare class KnitLayers {
|
|
|
124
142
|
halo(cx: number, cy: number, rx: number, ry: number, h: string, peak: number, at?: number, name?: string): string;
|
|
125
143
|
/** A shaded ball: lit from the upper left, `light` → `body` → `shadow`. */
|
|
126
144
|
bauble(cx: number, cy: number, r: number, light: string, body: string, shadow: string, name?: string): string;
|
|
145
|
+
/** A vector layer covering exactly the stitches set in `mask` (row runs), cropped to their box. */
|
|
146
|
+
mask(bits: Uint8Array, w: number, h: number, fill: Paint[], name: string): string | null;
|
|
147
|
+
/**
|
|
148
|
+
* Pop-art sunburst: `rays` wedges round (cx, cy) out to `r`, every other one filled, each with `fill` (a radial
|
|
149
|
+
* gradient fading outward reads as light). Hard-edged wedges, so the screen inside them looks designed.
|
|
150
|
+
*/
|
|
151
|
+
sunburst(cx: number, cy: number, r: number, rays: number, light: readonly Stop[], name?: string, turn?: number): string[];
|
|
152
|
+
/** A ribbon of light across the panel: a band `thick` stitches deep riding a sine wave. */
|
|
153
|
+
wave(yc: number, amp: number, period: number, thick: number, phase: number, fill: Paint[], name?: string): string;
|
|
154
|
+
/** Diagonal candy stripes between rows y0 and y1: bands `w` wide every `period`, slanting by the band's height. */
|
|
155
|
+
stripes(y0: number, y1: number, period: number, w: number, fill: Paint[], name?: string): string | null;
|
|
156
|
+
/** A panel-sized stitch mask from a test on each stitch. */
|
|
157
|
+
private bits;
|
|
158
|
+
/** A ring of stitches `w` thick at radius `r` round (cx, cy): a medallion frame. */
|
|
159
|
+
ring(cx: number, cy: number, r: number, w: number, fill: Paint[], name?: string): string | null;
|
|
160
|
+
/** A dotted ring: single dots `gap` stitches apart round a circle, each a 2×2 stitch block (never a lone stitch). */
|
|
161
|
+
dots(cx: number, cy: number, r: number, gap: number, fill: Paint[], name?: string): string | null;
|
|
162
|
+
/**
|
|
163
|
+
* The wordmark, solid, with what makes knit lettering read from across a room: an outline `ring` stitches thick
|
|
164
|
+
* and/or a drop shadow offset (dx, dy), each a solid yarn — never a blend inside the letters.
|
|
165
|
+
*/
|
|
166
|
+
badge(cx: number, cy: number, width: number, letters: string, o?: {
|
|
167
|
+
outline?: string;
|
|
168
|
+
ring?: number;
|
|
169
|
+
shadow?: string;
|
|
170
|
+
dx?: number;
|
|
171
|
+
dy?: number;
|
|
172
|
+
}): string | null;
|
|
127
173
|
/** The PopCraft wordmark as one vector layer, `width` stitches wide, centred on (cx, cy), filled with `fill`. */
|
|
128
174
|
logo(cx: number, cy: number, width: number, fill: Paint[], name?: string): {
|
|
129
175
|
id: string;
|