@shopify/klint 0.3.0 → 0.4.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/README.md +86 -62
- package/dist/{Klint-CsVzll4n.d.cts → Klint-DqYL-aGU.d.cts} +204 -332
- package/dist/{Klint-CsVzll4n.d.ts → Klint-DqYL-aGU.d.ts} +204 -332
- package/dist/index.cjs +872 -1184
- package/dist/index.d.cts +3 -29
- package/dist/index.d.ts +3 -29
- package/dist/index.js +868 -1184
- package/dist/plugins/index.cjs +606 -466
- package/dist/plugins/index.d.cts +440 -154
- package/dist/plugins/index.d.ts +440 -154
- package/dist/plugins/index.js +593 -466
- package/package.json +1 -1
- package/dist/chunk-3RG5ZIWI.js +0 -10
package/README.md
CHANGED
|
@@ -1,89 +1,113 @@
|
|
|
1
|
-
# Klint
|
|
1
|
+
# 🎨 Klint
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Klint is a modern 2D canvas library for React, inspired by p5.js and Processing. It makes creative coding in React intuitive and powerful, perfect for generative art, data visualization, interactive graphics, and creative web experiences.
|
|
4
4
|
|
|
5
|
-
## Features
|
|
5
|
+
## ✨ Features
|
|
6
6
|
|
|
7
|
-
- React
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- 🎯 **React-first**: Built specifically for React with hooks and component patterns
|
|
8
|
+
- 🎨 **Creative coding**: p5.js-like API with modern JavaScript/TypeScript
|
|
9
|
+
- 🚀 **Performance**: Direct canvas access with minimal overhead
|
|
10
|
+
- 🛠️ **Developer friendly**: Full TypeScript support and great tooling
|
|
11
|
+
- 🔧 **Extensible**: Plugin system and easy customization
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 🚀 Quick Start
|
|
14
|
+
|
|
15
|
+
### Install Klint
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @shopify/klint
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Basic Usage
|
|
14
22
|
|
|
15
23
|
```jsx
|
|
16
|
-
import {
|
|
24
|
+
import { useKlint, Klint } from '@shopify/klint';
|
|
17
25
|
|
|
18
|
-
function
|
|
26
|
+
function MySketch() {
|
|
19
27
|
const { context } = useKlint();
|
|
20
|
-
|
|
21
|
-
const draw = (K
|
|
22
|
-
K.background(
|
|
23
|
-
K.fillColor(
|
|
24
|
-
|
|
25
|
-
// Draw a pulsing circle at the center of the canvas
|
|
26
|
-
const size = 50 + Math.sin(K.frame * 0.05) * 25;
|
|
27
|
-
K.circle(K.width/2, K.height/2, size);
|
|
28
|
+
|
|
29
|
+
const draw = (K) => {
|
|
30
|
+
K.background('#000');
|
|
31
|
+
K.fillColor('#ff6b6b');
|
|
32
|
+
K.circle(K.width/2, K.height/2, 50);
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
return <Klint context={context} draw={draw} />;
|
|
31
36
|
}
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
##
|
|
39
|
+
## 🎮 Try the Editor
|
|
35
40
|
|
|
36
|
-
|
|
41
|
+
Want to experiment with Klint interactively? Create a live editor environment:
|
|
37
42
|
|
|
38
|
-
|
|
43
|
+
```bash
|
|
44
|
+
npx @shopify/klint klint-create-editor my-klint-project
|
|
45
|
+
cd my-klint-project
|
|
46
|
+
npm install
|
|
47
|
+
npm run dev
|
|
48
|
+
```
|
|
39
49
|
|
|
40
|
-
|
|
50
|
+
This creates a Monaco-based editor with live preview - perfect for learning and prototyping!
|
|
41
51
|
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
git clone https://github.com/Shopify/klint.git
|
|
45
|
-
cd klint
|
|
46
|
-
```
|
|
52
|
+
## 📚 Documentation
|
|
47
53
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
```
|
|
54
|
+
- **[Getting Started Guide](https://shopify.github.io/Klint/)** - Learn the basics
|
|
55
|
+
- **[API Reference](https://shopify.github.io/Klint/docs/Functions/introduction)** - Complete function reference
|
|
56
|
+
- **[Examples](https://shopify.github.io/Klint/experiments)** - See Klint in action
|
|
57
|
+
- **[Lifecycle](https://shopify.github.io/Klint/docs/klint-introduction)** - Understand how Klint works with React
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
cd your-project
|
|
57
|
-
npm link klint
|
|
58
|
-
```
|
|
59
|
+
## 🌟 Examples
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
### Animated Circle
|
|
62
|
+
```jsx
|
|
63
|
+
function AnimatedCircle() {
|
|
64
|
+
const { context } = useKlint();
|
|
65
|
+
|
|
66
|
+
const draw = (K) => {
|
|
67
|
+
K.background('rgba(0, 0, 0, 0.1)');
|
|
68
|
+
K.fillColor('#4ecdc4');
|
|
69
|
+
const x = K.width/2 + Math.cos(K.frame * 0.02) * 100;
|
|
70
|
+
const y = K.height/2 + Math.sin(K.frame * 0.02) * 100;
|
|
71
|
+
K.circle(x, y, 20);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return <Klint context={context} draw={draw} />;
|
|
75
|
+
}
|
|
76
|
+
```
|
|
64
77
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
### Interactive Drawing
|
|
79
|
+
```jsx
|
|
80
|
+
function InteractiveDrawing() {
|
|
81
|
+
const { context, KlintMouse } = useKlint();
|
|
82
|
+
const { mouse } = KlintMouse();
|
|
83
|
+
|
|
84
|
+
const draw = (K) => {
|
|
85
|
+
if (mouse.pressed) {
|
|
86
|
+
K.fillColor('red');
|
|
87
|
+
K.circle(mouse.x, mouse.y, 10);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return <Klint context={context} draw={draw} />;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
73
94
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
## 🛠️ Development
|
|
96
|
+
|
|
97
|
+
**For contributors** who want to work on Klint itself:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
git clone https://github.com/Shopify/klint.git
|
|
101
|
+
cd klint
|
|
102
|
+
npm install
|
|
103
|
+
npm run build
|
|
104
|
+
```
|
|
105
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
80
106
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
npm test
|
|
84
|
-
```
|
|
107
|
+
## 📄 License
|
|
108
|
+
MIT
|
|
85
109
|
|
|
86
|
-
|
|
110
|
+
---
|
|
87
111
|
|
|
112
|
+
**Ready to create?** Start with `npx @shopify/klint klint-create-editor my-project` 🎨
|
|
88
113
|
|
|
89
|
-
Made with love at Shopify, 2025
|