gradiente 1.0.1 → 2.0.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.
Files changed (4) hide show
  1. package/README.md +58 -122
  2. package/dist/index.d.mts +363 -291
  3. package/dist/index.mjs +1534 -1284
  4. package/package.json +8 -12
package/README.md CHANGED
@@ -1,175 +1,111 @@
1
- ![gradiente](https://raw.githubusercontent.com/Flowscape-UI/gradiente/378cf4dc85befd4d952a05a6bfde67c4be7c3bda/assets/logo.svg?token=AHBVSUSCAWP7PEXERSJABITJ4PKTS)
1
+ <div align="center">
2
2
 
3
- <a href="https://www.npmjs.com/package/gradiente">
3
+ <img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/fff32510afe7e3e1b7b2f73dbf7246843a06d859/assets/logo.svg" alt="gradiente logo" />
4
+
5
+ <h1>gradiente</h1>
6
+
7
+ <p>Minimalist & lightweight engine for sophisticated web gradients</p>
8
+
9
+ <img src="https://raw.githubusercontent.com/Flowscape-UI/gradiente/d8429051f700698f664d8d2392cfa58a604f8e83/assets/flowscape-badge.svg" alt="npm version" />
10
+ <br />
11
+
12
+ <a href="https://www.npmjs.com/package/gradiente">
4
13
  <img src="https://img.shields.io/npm/v/gradiente.svg?style=flat-square&labelColor=d84f4c&color=black" alt="npm version">
5
- </a>
6
- <a href="https://bundlephobia.com/result?p=gradiente">
7
- <img src="https://img.shields.io/bundlephobia/minzip/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="bundle size">
8
- </a>
9
- <a href="https://www.npmjs.com/package/gradiente">
10
- <img src="https://img.shields.io/npm/dw/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="weekly downloads">
11
- </a>
14
+ </a>
15
+ <a href="https://bundlephobia.com/result?p=gradiente">
16
+ <img src="https://img.shields.io/bundlephobia/minzip/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="bundle size"/>
17
+ </a>
18
+ <a href="https://github.com/Flowscape-UI/gradiente/blob/main/LICENSE">
19
+ <img src="https://img.shields.io/github/license/Flowscape-UI/gradiente?style=flat-square&labelColor=d84f4c&color=black" alt="license"/>
20
+ </a>
21
+ </div>
12
22
 
13
23
 
14
24
  # Gradiente
15
25
 
16
- **Gradiente** is a lightweight gradient engine for turning CSS gradients into clean, normalized data structures.
26
+ **Gradiente** is a lightweight gradient parser and transformer for modern rendering systems.
17
27
 
18
- It is built for rendering systems, visual editors, and developer tools where gradients need to be more than just strings.
28
+ Parse CSS gradients work with structured data render anywhere.
19
29
 
20
- > **Gradients as data, not strings.**
30
+ > Gradients as data, not strings.
21
31
 
22
32
  ---
23
33
 
24
- ## Installation
34
+ ## Install
25
35
 
26
36
  ```bash
27
37
  npm install gradiente
28
- bun add gradiente
29
- pnpm add gradiente
30
- yarn add gradiente
31
- ```
38
+ ````
32
39
 
33
40
  ---
34
41
 
35
- ## Quick Example
42
+ ## Example
36
43
 
37
44
  ```ts
38
- import { parse } from 'gradiente';
45
+ import { parse, transformTo } from "gradiente";
39
46
 
40
- const gradient = parse('linear-gradient(red, blue)');
41
- ```
47
+ const gradient = parse("linear-gradient(red, blue)");
42
48
 
43
- ## Result:
49
+ const css = transformTo("css", gradient);
50
+ const canvas = transformTo("canvas", gradient);
44
51
 
45
- ```ts
46
- {
47
- kind: 'linear',
48
- repeat: 'normal',
49
- direction: {
50
- kind: 'angle',
51
- value: { kind: 'dimension', value: 0, unit: 'deg' },
52
- valueRaw: { kind: 'dimension', value: 0, unit: 'rad' },
53
- keywords: ['to', 'top']
54
- },
55
- stops: [
56
- {
57
- kind: 'color-stop',
58
- color: 'red',
59
- position: { kind: 'percentage', value: 0 }
60
- },
61
- {
62
- kind: 'color-stop',
63
- color: 'blue',
64
- position: { kind: 'percentage', value: 1 }
65
- }
66
- ]
67
- }
52
+ canvas.draw(ctx, 300, 300);
68
53
  ```
69
54
 
70
55
  ---
71
56
 
72
- ## Supported Gradients
73
-
74
- Gradiente currently supports:
57
+ ## Supported
75
58
 
76
59
  ```ts
77
- parse('linear-gradient(...)')
78
- parse('repeating-linear-gradient(...)')
60
+ linear-gradient(...)
61
+ repeating-linear-gradient(...)
79
62
 
80
- parse('radial-gradient(...)')
81
- parse('repeating-radial-gradient(...)')
63
+ radial-gradient(...)
64
+ repeating-radial-gradient(...)
82
65
 
83
- parse('conic-gradient(...)')
84
- parse('repeating-conic-gradient(...)')
66
+ conic-gradient(...)
67
+ repeating-conic-gradient(...)
85
68
  ```
86
69
 
87
70
  ---
88
71
 
89
- ## What Gradiente Does
72
+ ## What it does
90
73
 
91
- ### Parses gradients into structured objects
74
+ * Parses gradients into structured objects
75
+ * Normalizes angles, positions, and stops
76
+ * Transforms gradients to different targets:
92
77
 
93
- ```ts
94
- import { parse } from 'gradiente';
95
-
96
- const gradient = parse('conic-gradient(from 45deg, red, blue)');
97
- ```
98
-
99
- Instead of getting a raw string you have to manually interpret, you get real data you can work with.
78
+ * CSS
79
+ * Canvas
80
+ * (more coming)
100
81
 
101
82
  ---
102
83
 
103
- ### Keeps values renderer-friendly
104
-
105
- Angles and positions are normalized into a stable internal representation so they are easier to use in:
106
-
107
- * Canvas
108
- * WebGL
109
- * Pixi
110
- * Konva
111
- * custom graphics engines
112
-
113
-
114
-
115
- ## Design Goals
116
-
117
- Gradiente is built around a few core ideas:
118
-
119
- * **Simple external API**
120
- * **Normalized internal model**
121
- * **Predictable stop data**
122
- * **Useful for real rendering systems**
123
- * **Easy to extend for future gradient types**
124
-
125
- It is not trying to be a full browser CSS engine.
126
-
127
- It is trying to be a practical gradient engine for developers.
128
-
129
- ---
130
-
131
- ## Built For
132
-
133
- Gradiente is especially useful for:
84
+ ## Built for
134
85
 
135
86
  * design tools
136
87
  * visual editors
137
- * whiteboards
138
88
  * canvas engines
139
- * procedural graphics
140
- * charting and data visualization systems
141
- * custom render pipelines
89
+ * WebGL / Pixi / Konva
90
+ * custom rendering pipelines
142
91
 
143
92
  ---
144
93
 
145
- ## Current Status
146
-
147
- Implemented:
94
+ ## Status
148
95
 
149
- * linear gradients
150
- * repeating linear gradients
151
- * radial gradients
152
- * repeating radial gradients
153
- * conic gradients
154
- * repeating conic gradients
155
- * stop normalization
156
- * repeating stop expansion
157
-
158
- Planned:
159
-
160
- * gradient serialization
161
- * gradient sampling
162
- * playground / live preview
163
- * docs website
96
+ * [x] linear gradients
97
+ * [x] radial gradients
98
+ * [x] conic gradients
99
+ * [x] canvas + css transformers
100
+ * [ ] docs
101
+ * [ ] playground
102
+ * [ ] more render targets
164
103
 
165
104
  ---
166
105
 
167
106
  ## Philosophy
168
107
 
169
- Gradiente treats gradients as a structured graphics primitive.
170
-
171
- Not a string to preserve.
172
- Not a browser quirk to emulate.
173
- A piece of graphics data you can actually use.
108
+ Gradiente treats gradients as a graphics primitive.
174
109
 
175
- > **Build gradients like an engine, not like a stylesheet.**
110
+ Not a string to preserve -
111
+ but data you can transform and render anywhere.