@meursyphus/flitter 2.0.1 → 2.0.3

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 CHANGED
@@ -1,21 +1,22 @@
1
1
  # Flitter
2
2
 
3
- Flitter is a powerful framework inspired by Flutter, supporting both SVG and Canvas to create high-performance graphics and user interfaces. It is designed to easily implement complex data visualizations, interactive charts, diagrams, and graphic editors in web applications.
4
-
3
+ Flitter is a powerful JavaScript rendering engine and framework inspired by Flutter, supporting both SVG and Canvas to create high-performance graphics and user interfaces. As a rendering engine, it provides fine-grained control over the rendering process, allowing developers to create complex, interactive visualizations with ease. It is designed to efficiently implement data visualizations, interactive charts, diagrams, and graphic editors in web applications.
5
4
 
6
5
  ## Key Features
7
6
 
8
- - **Render Object Tree**: Flitter uses a render object tree for efficient rendering, allowing easy management and manipulation of complex layouts.
7
+ - **Advanced Rendering Engine**: At its core, Flitter is a sophisticated rendering engine that gives developers precise control over how elements are drawn and updated on the screen.
8
+
9
+ - **Render Object Tree**: Flitter uses a render object tree for efficient rendering, allowing easy management and manipulation of complex layouts. This tree-based approach, central to Flitter's rendering engine, enables optimized updates and redraws.
9
10
 
10
- - **Declarative Programming**: Following a declarative paradigm, the screen automatically updates when values change, simplifying application state management.
11
+ - **Declarative Programming**: Following a declarative paradigm, the screen automatically updates when values change, simplifying application state management and reducing the complexity of manual DOM manipulation.
11
12
 
12
- - **Optimized Rendering**: Re-rendering, painting, and layout recalculations are managed by the renderer pipeline, with optimizations applied to update only necessary parts.
13
+ - **Optimized Rendering Pipeline**: Re-rendering, painting, and layout recalculations are managed by the renderer pipeline, with optimizations applied to update only necessary parts. This ensures high performance even with complex, data-heavy visualizations.
13
14
 
14
- - **Box Model Layout**: Users can easily compose layouts using the familiar Box model.
15
+ - **Dual Renderer Support**: As a flexible rendering engine, Flitter supports both SVG and Canvas, meeting various graphic requirements. Developers can choose the appropriate renderer as needed, switching seamlessly between vector and bitmap graphics.
15
16
 
16
- - **SVG and Canvas Support**: Supports both SVG and Canvas, meeting various graphic requirements. Developers can choose the appropriate renderer as needed.
17
+ - **Box Model Layout**: Users can easily compose layouts using the familiar Box model, providing a intuitive way to structure complex UIs within the rendering engine.
17
18
 
18
- - **Diverse Applications**: Can be utilized in various fields such as charts, diagrams, data visualization, and graphic editors.
19
+ - **Diverse Applications**: Can be utilized in various fields such as charts, diagrams, data visualization, and graphic editors, leveraging the power of the underlying rendering engine.
19
20
 
20
21
  # Showcase
21
22
  Here are some examples of what you can create with Flitter:
@@ -39,18 +40,35 @@ Flitter can be used in various JavaScript environments. Here are installation an
39
40
  npm install @meursyphus/flitter
40
41
  ```
41
42
 
42
- ```javascript
43
- import { Widget, Container, AppRunner } from '@meursyphus/flitter';
44
-
45
- // Using SVG renderer
46
- const svgElement = document.getElementById('mySvg');
47
- const svgRunner = new AppRunner({ view: svgElement });
48
- svgRunner.runApp(Container({ color: 'lightblue' }));
49
-
50
- // Using Canvas renderer
51
- const canvasElement = document.getElementById('myCanvas');
52
- const canvasRunner = new AppRunner({ view: canvasElement });
53
- canvasRunner.runApp(Container({ color: 'lightgreen' }));
43
+ ```javascript
44
+ import { Container } from "@meursyphus/flitter";
45
+
46
+ /**
47
+ * canvas style must be set to 100%, 100%
48
+ * and you also must wrap div for canvas in order to calculate the size of the canvas
49
+ */
50
+ document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
51
+ <div style="width: 100vw; height: 100vh" id="container">
52
+ <canvas style="width: 100%; height: 100%;" id="view" />
53
+ </div>
54
+ `;
55
+ // Note: SVG is also supported
56
+ // document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
57
+ // <div style="width: 100vw; height: 100vh" id="container">
58
+ // <svg style="width: 100%; height: 100%;" id="view"></svg>
59
+ // </div>
60
+ // `;
61
+ const app = new AppRunner({
62
+ view: document.querySelector<HTMLCanvasElement>("#view")!,
63
+ });
64
+ /**
65
+ * you must set resizeTarget to calculate the size of the canvas
66
+ */
67
+ app.onMount({
68
+ resizeTarget: document.querySelector<HTMLDivElement>("#container")!,
69
+ });
70
+
71
+ app.runApp(Container({ color: 'lightblue' }));
54
72
  ```
55
73
 
56
74
  ### React
@@ -68,23 +86,13 @@ const App = () => (
68
86
  <Widget
69
87
  width="600px"
70
88
  height="300px"
71
- renderer="svg"
89
+ renderer="canvas" // or svg
72
90
  widget={Container({
73
91
  alignment: Alignment.center,
74
92
  color: 'lightblue',
75
93
  child: Text("Hello, Flitter SVG!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
76
94
  })}
77
95
  />
78
- <Widget
79
- width="600px"
80
- height="300px"
81
- renderer="canvas"
82
- widget={Container({
83
- alignment: Alignment.center,
84
- color: 'lightgreen',
85
- child: Text("Hello, Flitter Canvas!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
86
- })}
87
- />
88
96
  </>
89
97
  );
90
98
  ```
@@ -104,24 +112,13 @@ npm install @meursyphus/flitter @meursyphus/flitter-svelte
104
112
  <Widget
105
113
  width="600px"
106
114
  height="300px"
107
- renderer="svg"
115
+ renderer="canvas" <!-- or "svg" -->
108
116
  widget={Container({
109
117
  alignment: Alignment.center,
110
118
  color: 'lightblue',
111
119
  child: Text("Hello, Flitter SVG!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
112
120
  })}
113
121
  />
114
-
115
- <Widget
116
- width="600px"
117
- height="300px"
118
- renderer="canvas"
119
- widget={Container({
120
- alignment: Alignment.center,
121
- color: 'lightgreen',
122
- child: Text("Hello, Flitter Canvas!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
123
- })}
124
- />
125
122
  ```
126
123
 
127
124
  ## Usage Example
@@ -245,15 +242,18 @@ class BarState extends State<Bar> {
245
242
 
246
243
  ## Why Flitter?
247
244
 
248
- 1. **Easy Learning Curve**: Uses syntax similar to Flutter, allowing mobile developers to easily adapt to the web environment.
245
+ 1. **Powerful Rendering Engine**: Flitter's core strength lies in its advanced rendering capabilities, allowing for smooth handling of complex graphics and animations.
246
+
247
+ 2. **Easy Learning Curve**: Uses syntax similar to Flutter, allowing mobile developers to easily adapt to the web environment while leveraging a powerful web-based rendering engine.
248
+
249
+ 3. **High Performance**: The optimized rendering pipeline ensures smooth performance even with complex, data-intensive visualizations.
249
250
 
250
- 2. **High Performance**: Handles complex graphics smoothly with an optimized rendering pipeline.
251
+ 4. **Flexibility**: Abstracts SVG and Canvas manipulation, allowing developers to focus on business logic while the rendering engine handles the low-level drawing operations.
251
252
 
252
- 3. **Flexibility**: Abstracts SVG and Canvas manipulation, allowing developers to focus on business logic.
253
+ 5. **Renderer Selection**: Can choose between SVG and Canvas renderers as needed, meeting various graphic requirements and allowing for the best performance in different scenarios.
253
254
 
254
- 4. **Renderer Selection**: Can choose between SVG and Canvas renderers as needed, meeting various graphic requirements.
255
+ 6. **Reusability**: Increases code reusability through a component-based approach, enabled by the underlying rendering engine's architecture.
255
256
 
256
- 5. **Reusability**: Increases code reusability through a component-based approach.
257
257
 
258
258
  ## Contributing
259
259