@meursyphus/flitter 2.0.1 → 2.0.2
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 +31 -36
- package/index.cjs +384 -3
- package/index.d.cts +63 -34
- package/index.d.ts +63 -34
- package/index.global.js +380 -2
- package/index.js +383 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
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
4
|
|
|
5
|
-
|
|
6
5
|
## Key Features
|
|
7
6
|
|
|
8
7
|
- **Render Object Tree**: Flitter uses a render object tree for efficient rendering, allowing easy management and manipulation of complex layouts.
|
|
@@ -39,18 +38,35 @@ Flitter can be used in various JavaScript environments. Here are installation an
|
|
|
39
38
|
npm install @meursyphus/flitter
|
|
40
39
|
```
|
|
41
40
|
|
|
42
|
-
```javascript
|
|
43
|
-
import {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
```javascript
|
|
42
|
+
import { Container } from "@meursyphus/flitter";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* canvas style must be set to 100%, 100%
|
|
46
|
+
* and you also must wrap div for canvas in order to calculate the size of the canvas
|
|
47
|
+
*/
|
|
48
|
+
document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
|
|
49
|
+
<div style="width: 100vw; height: 100vh" id="container">
|
|
50
|
+
<canvas style="width: 100%; height: 100%;" id="view" />
|
|
51
|
+
</div>
|
|
52
|
+
`;
|
|
53
|
+
// Note: SVG is also supported
|
|
54
|
+
// document.querySelector<HTMLDivElement>("#app")!.innerHTML = `
|
|
55
|
+
// <div style="width: 100vw; height: 100vh" id="container">
|
|
56
|
+
// <svg style="width: 100%; height: 100%;" id="view"></svg>
|
|
57
|
+
// </div>
|
|
58
|
+
// `;
|
|
59
|
+
const app = new AppRunner({
|
|
60
|
+
view: document.querySelector<HTMLCanvasElement>("#view")!,
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* you must set resizeTarget to calculate the size of the canvas
|
|
64
|
+
*/
|
|
65
|
+
app.onMount({
|
|
66
|
+
resizeTarget: document.querySelector<HTMLDivElement>("#container")!,
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
app.runApp(Container({ color: 'lightblue' }));
|
|
54
70
|
```
|
|
55
71
|
|
|
56
72
|
### React
|
|
@@ -68,23 +84,13 @@ const App = () => (
|
|
|
68
84
|
<Widget
|
|
69
85
|
width="600px"
|
|
70
86
|
height="300px"
|
|
71
|
-
renderer="svg
|
|
87
|
+
renderer="canvas" // or svg
|
|
72
88
|
widget={Container({
|
|
73
89
|
alignment: Alignment.center,
|
|
74
90
|
color: 'lightblue',
|
|
75
91
|
child: Text("Hello, Flitter SVG!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
|
|
76
92
|
})}
|
|
77
93
|
/>
|
|
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
94
|
</>
|
|
89
95
|
);
|
|
90
96
|
```
|
|
@@ -104,24 +110,13 @@ npm install @meursyphus/flitter @meursyphus/flitter-svelte
|
|
|
104
110
|
<Widget
|
|
105
111
|
width="600px"
|
|
106
112
|
height="300px"
|
|
107
|
-
renderer="svg"
|
|
113
|
+
renderer="canvas" <!-- or "svg" -->
|
|
108
114
|
widget={Container({
|
|
109
115
|
alignment: Alignment.center,
|
|
110
116
|
color: 'lightblue',
|
|
111
117
|
child: Text("Hello, Flitter SVG!", { style: TextStyle({ fontSize: 30, weight: 'bold' }) })
|
|
112
118
|
})}
|
|
113
119
|
/>
|
|
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
120
|
```
|
|
126
121
|
|
|
127
122
|
## Usage Example
|
package/index.cjs
CHANGED
|
@@ -13082,6 +13082,30 @@ var rose = {
|
|
|
13082
13082
|
950: "#4c0519"
|
|
13083
13083
|
};
|
|
13084
13084
|
|
|
13085
|
+
// src/type/_types/object-fit.ts
|
|
13086
|
+
var ObjectFit = /* @__PURE__ */ ((ObjectFit2) => {
|
|
13087
|
+
ObjectFit2["fill"] = "fill";
|
|
13088
|
+
ObjectFit2["contain"] = "contain";
|
|
13089
|
+
ObjectFit2["cover"] = "cover";
|
|
13090
|
+
ObjectFit2["none"] = "none";
|
|
13091
|
+
ObjectFit2["scaleDown"] = "scale-down";
|
|
13092
|
+
return ObjectFit2;
|
|
13093
|
+
})(ObjectFit || {});
|
|
13094
|
+
|
|
13095
|
+
// src/type/_types/object-position.ts
|
|
13096
|
+
var ObjectPosition = /* @__PURE__ */ ((ObjectPosition2) => {
|
|
13097
|
+
ObjectPosition2["center"] = "center";
|
|
13098
|
+
ObjectPosition2["top"] = "top";
|
|
13099
|
+
ObjectPosition2["right"] = "right";
|
|
13100
|
+
ObjectPosition2["bottom"] = "bottom";
|
|
13101
|
+
ObjectPosition2["left"] = "left";
|
|
13102
|
+
ObjectPosition2["topLeft"] = "top left";
|
|
13103
|
+
ObjectPosition2["topRight"] = "top right";
|
|
13104
|
+
ObjectPosition2["bottomLeft"] = "bottom left";
|
|
13105
|
+
ObjectPosition2["bottomRight"] = "bottom right";
|
|
13106
|
+
return ObjectPosition2;
|
|
13107
|
+
})(ObjectPosition || {});
|
|
13108
|
+
|
|
13085
13109
|
// src/framework/renderer/renderer.ts
|
|
13086
13110
|
var _resizeHandlers;
|
|
13087
13111
|
var RenderContext = class {
|
|
@@ -14002,10 +14026,10 @@ var RenderObject = class {
|
|
|
14002
14026
|
dispose() {
|
|
14003
14027
|
this.renderOwner.disposeRenderObject(this);
|
|
14004
14028
|
}
|
|
14005
|
-
getIntrinsicWidth(
|
|
14029
|
+
getIntrinsicWidth(_height2) {
|
|
14006
14030
|
return 0;
|
|
14007
14031
|
}
|
|
14008
|
-
getIntrinsicHeight(
|
|
14032
|
+
getIntrinsicHeight(_width2) {
|
|
14009
14033
|
return 0;
|
|
14010
14034
|
}
|
|
14011
14035
|
/*
|
|
@@ -20643,6 +20667,363 @@ dispatch_fn = function(type, event) {
|
|
|
20643
20667
|
};
|
|
20644
20668
|
var TextField_default = classToFunction_default(TextField);
|
|
20645
20669
|
|
|
20670
|
+
// src/component/base/base-image/calculatePosition.ts
|
|
20671
|
+
var objectPositionMap = {
|
|
20672
|
+
center: { x: 0.5, y: 0.5 },
|
|
20673
|
+
top: { x: 0.5, y: 0 },
|
|
20674
|
+
right: { x: 1, y: 0.5 },
|
|
20675
|
+
bottom: { x: 0.5, y: 1 },
|
|
20676
|
+
left: { x: 0, y: 0.5 },
|
|
20677
|
+
"top left": { x: 0, y: 0 },
|
|
20678
|
+
"top right": { x: 1, y: 0 },
|
|
20679
|
+
"bottom left": { x: 0, y: 1 },
|
|
20680
|
+
"bottom right": { x: 1, y: 1 }
|
|
20681
|
+
};
|
|
20682
|
+
function calcSize(sourceSize, containerSize, imageSize, positionPercent) {
|
|
20683
|
+
if (imageSize > containerSize) {
|
|
20684
|
+
const ratio = sourceSize / imageSize;
|
|
20685
|
+
const sSize = Math.min(sourceSize, containerSize * ratio);
|
|
20686
|
+
const s = (sourceSize - sSize) * positionPercent;
|
|
20687
|
+
return {
|
|
20688
|
+
s: Math.max(0, Math.min(s, sourceSize - sSize)),
|
|
20689
|
+
sSize,
|
|
20690
|
+
d: 0,
|
|
20691
|
+
dSize: containerSize
|
|
20692
|
+
};
|
|
20693
|
+
} else {
|
|
20694
|
+
const d = (containerSize - imageSize) * positionPercent;
|
|
20695
|
+
return {
|
|
20696
|
+
s: 0,
|
|
20697
|
+
sSize: sourceSize,
|
|
20698
|
+
d,
|
|
20699
|
+
dSize: imageSize
|
|
20700
|
+
};
|
|
20701
|
+
}
|
|
20702
|
+
}
|
|
20703
|
+
function calculateImageRendering(sourceImageSize, calcImageSizeResult, objectPosition = "center") {
|
|
20704
|
+
const {
|
|
20705
|
+
container: { width: containerWidth, height: containerHeight },
|
|
20706
|
+
image: { width: imageWidth, height: imageHeight }
|
|
20707
|
+
} = calcImageSizeResult;
|
|
20708
|
+
const { x: xPercent, y: yPercent } = objectPositionMap[objectPosition];
|
|
20709
|
+
const horizontalResult = calcSize(
|
|
20710
|
+
sourceImageSize.width,
|
|
20711
|
+
containerWidth,
|
|
20712
|
+
imageWidth,
|
|
20713
|
+
xPercent
|
|
20714
|
+
);
|
|
20715
|
+
const verticalResult = calcSize(
|
|
20716
|
+
sourceImageSize.height,
|
|
20717
|
+
containerHeight,
|
|
20718
|
+
imageHeight,
|
|
20719
|
+
yPercent
|
|
20720
|
+
);
|
|
20721
|
+
return {
|
|
20722
|
+
sx: Math.round(horizontalResult.s),
|
|
20723
|
+
sy: Math.round(verticalResult.s),
|
|
20724
|
+
sWidth: Math.round(horizontalResult.sSize),
|
|
20725
|
+
sHeight: Math.round(verticalResult.sSize),
|
|
20726
|
+
dx: Math.round(horizontalResult.d),
|
|
20727
|
+
dy: Math.round(verticalResult.d),
|
|
20728
|
+
dWidth: Math.round(horizontalResult.dSize),
|
|
20729
|
+
dHeight: Math.round(verticalResult.dSize)
|
|
20730
|
+
};
|
|
20731
|
+
}
|
|
20732
|
+
|
|
20733
|
+
// src/component/base/base-image/calculateSize.ts
|
|
20734
|
+
function calculateSize(source, container, objectFit = "none") {
|
|
20735
|
+
var _a, _b;
|
|
20736
|
+
const aspectRatio = source.width / source.height;
|
|
20737
|
+
let containerWidth = (_a = container.width) != null ? _a : source.width;
|
|
20738
|
+
let containerHeight = (_b = container.height) != null ? _b : source.height;
|
|
20739
|
+
if (container.width != null && container.height == null) {
|
|
20740
|
+
containerHeight = Math.round(container.width / aspectRatio);
|
|
20741
|
+
} else if (container.width == null && container.height != null) {
|
|
20742
|
+
containerWidth = Math.round(container.height * aspectRatio);
|
|
20743
|
+
}
|
|
20744
|
+
const imageSize = fitFunctions[objectFit](source, {
|
|
20745
|
+
width: containerWidth,
|
|
20746
|
+
height: containerHeight
|
|
20747
|
+
});
|
|
20748
|
+
return {
|
|
20749
|
+
width: Math.round(containerWidth),
|
|
20750
|
+
height: Math.round(containerHeight),
|
|
20751
|
+
image: {
|
|
20752
|
+
width: Math.round(imageSize.width),
|
|
20753
|
+
height: Math.round(imageSize.height)
|
|
20754
|
+
}
|
|
20755
|
+
};
|
|
20756
|
+
}
|
|
20757
|
+
var fitFunctions = {
|
|
20758
|
+
fill: fillFit,
|
|
20759
|
+
contain: containFit,
|
|
20760
|
+
cover: coverFit,
|
|
20761
|
+
none: noneFit,
|
|
20762
|
+
"scale-down": scaleDownFit
|
|
20763
|
+
};
|
|
20764
|
+
function fillFit(source, container) {
|
|
20765
|
+
return { width: container.width, height: container.height };
|
|
20766
|
+
}
|
|
20767
|
+
function containFit(source, result) {
|
|
20768
|
+
const aspectRatio = source.width / source.height;
|
|
20769
|
+
if (result.width / result.height > aspectRatio) {
|
|
20770
|
+
return { width: result.height * aspectRatio, height: result.height };
|
|
20771
|
+
} else {
|
|
20772
|
+
return { width: result.width, height: result.width / aspectRatio };
|
|
20773
|
+
}
|
|
20774
|
+
}
|
|
20775
|
+
function coverFit(source, container) {
|
|
20776
|
+
const aspectRatio = source.width / source.height;
|
|
20777
|
+
if (container.width / container.height > aspectRatio) {
|
|
20778
|
+
return { width: container.width, height: container.width / aspectRatio };
|
|
20779
|
+
} else {
|
|
20780
|
+
return { width: container.height * aspectRatio, height: container.height };
|
|
20781
|
+
}
|
|
20782
|
+
}
|
|
20783
|
+
function noneFit(source, _) {
|
|
20784
|
+
return { width: source.width, height: source.height };
|
|
20785
|
+
}
|
|
20786
|
+
function scaleDownFit(source, container) {
|
|
20787
|
+
const containSize = containFit(source, container);
|
|
20788
|
+
if (containSize.width > source.width || containSize.height > source.height) {
|
|
20789
|
+
return { width: source.width, height: source.height };
|
|
20790
|
+
}
|
|
20791
|
+
return containSize;
|
|
20792
|
+
}
|
|
20793
|
+
|
|
20794
|
+
// src/component/base/base-image/BaseImage.ts
|
|
20795
|
+
var _Image = class extends SingleChildRenderObjectWidget_default {
|
|
20796
|
+
constructor({
|
|
20797
|
+
key,
|
|
20798
|
+
src,
|
|
20799
|
+
objectFit: fit,
|
|
20800
|
+
width,
|
|
20801
|
+
height,
|
|
20802
|
+
objectPosition: position
|
|
20803
|
+
}) {
|
|
20804
|
+
super(key);
|
|
20805
|
+
__publicField(this, "_src");
|
|
20806
|
+
__publicField(this, "_fit");
|
|
20807
|
+
__publicField(this, "_width");
|
|
20808
|
+
__publicField(this, "_height");
|
|
20809
|
+
__publicField(this, "_position");
|
|
20810
|
+
this._src = src;
|
|
20811
|
+
this._fit = fit;
|
|
20812
|
+
this._width = width;
|
|
20813
|
+
this._height = height;
|
|
20814
|
+
this._position = position;
|
|
20815
|
+
}
|
|
20816
|
+
createRenderObject() {
|
|
20817
|
+
return new RenderImage({
|
|
20818
|
+
src: this._src,
|
|
20819
|
+
objectFit: this._fit,
|
|
20820
|
+
width: this._width,
|
|
20821
|
+
height: this._height,
|
|
20822
|
+
objectPosition: this._position
|
|
20823
|
+
});
|
|
20824
|
+
}
|
|
20825
|
+
updateRenderObject(renderObject) {
|
|
20826
|
+
renderObject.src = this._src;
|
|
20827
|
+
renderObject.fit = this._fit;
|
|
20828
|
+
renderObject.width = this._width;
|
|
20829
|
+
renderObject.height = this._height;
|
|
20830
|
+
renderObject.position = this._position;
|
|
20831
|
+
}
|
|
20832
|
+
};
|
|
20833
|
+
var _src, _fit, _width, _height, _position, _mounted;
|
|
20834
|
+
var RenderImage = class extends SingleChildRenderObject_default {
|
|
20835
|
+
constructor({
|
|
20836
|
+
src,
|
|
20837
|
+
objectFit,
|
|
20838
|
+
width,
|
|
20839
|
+
height,
|
|
20840
|
+
objectPosition
|
|
20841
|
+
}) {
|
|
20842
|
+
super({ isPainter: true });
|
|
20843
|
+
__privateAdd(this, _src, void 0);
|
|
20844
|
+
__privateAdd(this, _fit, void 0);
|
|
20845
|
+
__privateAdd(this, _width, void 0);
|
|
20846
|
+
__privateAdd(this, _height, void 0);
|
|
20847
|
+
__privateAdd(this, _position, void 0);
|
|
20848
|
+
__publicField(this, "image");
|
|
20849
|
+
__publicField(this, "imageLoaded", false);
|
|
20850
|
+
__publicField(this, "calculatedImageSize");
|
|
20851
|
+
__privateAdd(this, _mounted, false);
|
|
20852
|
+
__privateSet(this, _src, src);
|
|
20853
|
+
__privateSet(this, _fit, objectFit);
|
|
20854
|
+
__privateSet(this, _width, width);
|
|
20855
|
+
__privateSet(this, _height, height);
|
|
20856
|
+
__privateSet(this, _position, objectPosition);
|
|
20857
|
+
if (browser) {
|
|
20858
|
+
this.image = new Image();
|
|
20859
|
+
this.image.onload = () => {
|
|
20860
|
+
this.imageLoaded = true;
|
|
20861
|
+
if (!__privateGet(this, _mounted))
|
|
20862
|
+
return;
|
|
20863
|
+
this.markNeedsLayout();
|
|
20864
|
+
};
|
|
20865
|
+
this.image.src = src;
|
|
20866
|
+
}
|
|
20867
|
+
}
|
|
20868
|
+
get src() {
|
|
20869
|
+
return __privateGet(this, _src);
|
|
20870
|
+
}
|
|
20871
|
+
set src(value) {
|
|
20872
|
+
if (__privateGet(this, _src) === value)
|
|
20873
|
+
return;
|
|
20874
|
+
__privateSet(this, _src, value);
|
|
20875
|
+
if (this.image != null) {
|
|
20876
|
+
this.image.src = value;
|
|
20877
|
+
}
|
|
20878
|
+
this.markNeedsLayout();
|
|
20879
|
+
}
|
|
20880
|
+
get fit() {
|
|
20881
|
+
return __privateGet(this, _fit);
|
|
20882
|
+
}
|
|
20883
|
+
set fit(value) {
|
|
20884
|
+
if (__privateGet(this, _fit) === value)
|
|
20885
|
+
return;
|
|
20886
|
+
__privateSet(this, _fit, value);
|
|
20887
|
+
this.markNeedsLayout();
|
|
20888
|
+
}
|
|
20889
|
+
get width() {
|
|
20890
|
+
return __privateGet(this, _width);
|
|
20891
|
+
}
|
|
20892
|
+
set width(value) {
|
|
20893
|
+
if (__privateGet(this, _width) === value)
|
|
20894
|
+
return;
|
|
20895
|
+
__privateSet(this, _width, value);
|
|
20896
|
+
this.markNeedsLayout();
|
|
20897
|
+
}
|
|
20898
|
+
get height() {
|
|
20899
|
+
return __privateGet(this, _height);
|
|
20900
|
+
}
|
|
20901
|
+
set height(value) {
|
|
20902
|
+
if (__privateGet(this, _height) === value)
|
|
20903
|
+
return;
|
|
20904
|
+
__privateSet(this, _height, value);
|
|
20905
|
+
this.markNeedsLayout();
|
|
20906
|
+
}
|
|
20907
|
+
get position() {
|
|
20908
|
+
return __privateGet(this, _position);
|
|
20909
|
+
}
|
|
20910
|
+
set position(value) {
|
|
20911
|
+
if (__privateGet(this, _position) === value)
|
|
20912
|
+
return;
|
|
20913
|
+
__privateSet(this, _position, value);
|
|
20914
|
+
this.markNeedsLayout();
|
|
20915
|
+
}
|
|
20916
|
+
getIntrinsicWidth() {
|
|
20917
|
+
if (this.width != null)
|
|
20918
|
+
return this.width;
|
|
20919
|
+
return 0;
|
|
20920
|
+
}
|
|
20921
|
+
getIntrinsicHeight() {
|
|
20922
|
+
if (this.height != null)
|
|
20923
|
+
return this.height;
|
|
20924
|
+
return 0;
|
|
20925
|
+
}
|
|
20926
|
+
preformLayout() {
|
|
20927
|
+
var _a, _b;
|
|
20928
|
+
__privateSet(this, _mounted, true);
|
|
20929
|
+
if (!this.imageLoaded) {
|
|
20930
|
+
this.size = this.constraints.constrain(
|
|
20931
|
+
new size_default({
|
|
20932
|
+
width: (_a = this.width) != null ? _a : 0,
|
|
20933
|
+
height: (_b = this.height) != null ? _b : 0
|
|
20934
|
+
})
|
|
20935
|
+
);
|
|
20936
|
+
return;
|
|
20937
|
+
}
|
|
20938
|
+
assert(this.image != null);
|
|
20939
|
+
const sourceSize = { width: this.image.width, height: this.image.height };
|
|
20940
|
+
const { width, height } = calculateSize(
|
|
20941
|
+
sourceSize,
|
|
20942
|
+
{
|
|
20943
|
+
width: this.width && this.constraints.constrainWidth(this.width),
|
|
20944
|
+
height: this.height && this.constraints.constrainHeight(this.height)
|
|
20945
|
+
},
|
|
20946
|
+
this.fit
|
|
20947
|
+
);
|
|
20948
|
+
const size = new size_default({ width, height });
|
|
20949
|
+
this.size = this.constraints.constrain(size);
|
|
20950
|
+
this.calculatedImageSize = calculateSize(
|
|
20951
|
+
sourceSize,
|
|
20952
|
+
{
|
|
20953
|
+
width: this.size.width,
|
|
20954
|
+
height: this.size.height
|
|
20955
|
+
},
|
|
20956
|
+
this.fit
|
|
20957
|
+
).image;
|
|
20958
|
+
}
|
|
20959
|
+
createCanvasPainter() {
|
|
20960
|
+
return new ImageCanvasPatiner(this);
|
|
20961
|
+
}
|
|
20962
|
+
createSvgPainter() {
|
|
20963
|
+
return new ImageSvgPainter(this);
|
|
20964
|
+
}
|
|
20965
|
+
};
|
|
20966
|
+
_src = new WeakMap();
|
|
20967
|
+
_fit = new WeakMap();
|
|
20968
|
+
_width = new WeakMap();
|
|
20969
|
+
_height = new WeakMap();
|
|
20970
|
+
_position = new WeakMap();
|
|
20971
|
+
_mounted = new WeakMap();
|
|
20972
|
+
var ImageCanvasPatiner = class extends CanvasPainter {
|
|
20973
|
+
performPaint(context, offset) {
|
|
20974
|
+
const {
|
|
20975
|
+
size,
|
|
20976
|
+
image,
|
|
20977
|
+
imageLoaded,
|
|
20978
|
+
calculatedImageSize: imageSize,
|
|
20979
|
+
position = "center"
|
|
20980
|
+
} = this.renderObject;
|
|
20981
|
+
if (!image)
|
|
20982
|
+
return;
|
|
20983
|
+
if (!imageLoaded)
|
|
20984
|
+
return;
|
|
20985
|
+
assert(imageSize != null);
|
|
20986
|
+
const { sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight } = calculateImageRendering(
|
|
20987
|
+
{ width: image.width, height: image.height },
|
|
20988
|
+
{
|
|
20989
|
+
container: size,
|
|
20990
|
+
image: { width: imageSize.width, height: imageSize.height }
|
|
20991
|
+
},
|
|
20992
|
+
position
|
|
20993
|
+
);
|
|
20994
|
+
context.canvas.drawImage(
|
|
20995
|
+
image,
|
|
20996
|
+
sx,
|
|
20997
|
+
sy,
|
|
20998
|
+
sWidth,
|
|
20999
|
+
sHeight,
|
|
21000
|
+
offset.x + dx,
|
|
21001
|
+
offset.y + dy,
|
|
21002
|
+
dWidth,
|
|
21003
|
+
dHeight
|
|
21004
|
+
);
|
|
21005
|
+
}
|
|
21006
|
+
};
|
|
21007
|
+
var ImageSvgPainter = class extends SvgPainter {
|
|
21008
|
+
createDefaultSvgEl(context) {
|
|
21009
|
+
return {
|
|
21010
|
+
img: context.createSvgEl("image")
|
|
21011
|
+
};
|
|
21012
|
+
}
|
|
21013
|
+
performPaint({ img }) {
|
|
21014
|
+
const { src } = this.renderObject;
|
|
21015
|
+
img.setAttribute("href", src);
|
|
21016
|
+
console.warn("not implemented svg painter on image widget");
|
|
21017
|
+
}
|
|
21018
|
+
};
|
|
21019
|
+
var BaseImage_default = _Image;
|
|
21020
|
+
|
|
21021
|
+
// src/component/Image.ts
|
|
21022
|
+
var Image_default = classToFunction_default(BaseImage_default);
|
|
21023
|
+
|
|
21024
|
+
|
|
21025
|
+
|
|
21026
|
+
|
|
20646
21027
|
|
|
20647
21028
|
|
|
20648
21029
|
|
|
@@ -20783,4 +21164,4 @@ var TextField_default = classToFunction_default(TextField);
|
|
|
20783
21164
|
|
|
20784
21165
|
|
|
20785
21166
|
|
|
20786
|
-
exports.Align = Align_default; exports.Alignment = alignment_default; exports.AnimatedAlign = AnimatedAlign_default; exports.AnimatedBaseWidgetState = AnimatedBaseWidgetState; exports.AnimatedContainer = AnimatedContainer_default; exports.AnimatedFractionallySizedBox = AnimatedFractionallySizedBox_default; exports.AnimatedOpacity = AnimatedOpacity_default; exports.AnimatedPadding = AnimatedPadding_default; exports.AnimatedPositioned = AnimatedPositioned_default; exports.AnimatedRotation = AnimatedRotation_default; exports.AnimatedScale = AnimatedScale_default; exports.AnimatedSlide = AnimatedSlide_default; exports.Animation = Animation_default; exports.AnimationController = AnimationController_default; exports.AppRunner = AppRunner; exports.AspectRatio = AspectRatio_default; exports.Axis = Axis; exports.Border = border_default; exports.BorderRadius = BorderRadius; exports.BorderRadiusGeometry = border_radius_geometry_default; exports.BorderSide = BorderSide; exports.BorderStyle = border_style_default; exports.BoxDecoration = BoxDecoration; exports.BoxShadow = box_shadow_default; exports.BuildContext = BuildContext; exports.BuildOwner = BuildOwner_default; exports.Builder = Builder_default; exports.Calculable = calculable_default; exports.CalculableTween = CalculableTween_default; exports.CanvasPainter = CanvasPainter; exports.Center = Center; exports.ChangeNotifier = ChangeNotifier_default; exports.ChangeNotifierProvider = ChangeNotifierProvider_default; exports.ClipOval = ClipOval; exports.ClipPath = ClipPath_default; exports.ClipRRect = ClipOval2; exports.ClipRect = ClipRect; exports.Color = color_default; exports.ColoredBox = ColoredBox_default; exports.Colors = colors_exports; exports.Column = Column; exports.ComponentElement = ComponentElement_default; exports.ComponentWidget = StatelessWidget_default; exports.ConstrainedBox = ConstrainedBox_default; exports.Constraints = constraints_default; exports.ConstraintsTransformBox = ConstraintsTransformBox_default; exports.Container = Container_default; exports.CrossAxisAlignment = CrossAxisAlignment; exports.Curve = Curve_default; exports.CurvedAnimation = CurvedAnimation_default; exports.Curves = Curves_default; exports.CustomPaint = CustomPaint_default; exports.Data = data_default; exports.DecoratedBox = DecoratedBox_default; exports.Draggable = Draggable_default; exports.EdgeInsets = edge_insets_default; exports.Element = Element_default; exports.Expanded = Expanded_default; exports.Flex = Flex2; exports.Flexible = Flexible_default; exports.FractionalTranslation = FractionalTranslation_default; exports.FractionallySizedBox = FractionallySizedBox_default; exports.Gap = gap_default; exports.GestureDetector = GestureDetector_default; exports.GlobalKey = Globalkey_default; exports.Grid = Grid_default; exports.ImplicitlyAnimatedWidget = ImplicitlyAnimatedWidget; exports.ImplicitlyAnimatedWidgetState = ImplicitlyAnimatedWidgetState; exports.IndexedStack = IndexedStack2; exports.IntrinsicHeight = IntrinsicHeight_default; exports.IntrinsicWidth = IntrinsicWidth_default; exports.LimitedBox = LimitedBox_default; exports.Listenable = Listenable; exports.MainAxisAlignment = MainAxisAlignment; exports.MainAxisSize = MainAxisSize; exports.Matrix3 = matrix3_default; exports.Matrix4 = matrix4_default; exports.MultiChildRenderObject = MultiChildRenderObject_default; exports.MultiChildRenderObjectWidget = MultiChildRenderObjectWidget_default; exports.Offset = offset_default; exports.Opacity = Opacity_default; exports.OverflowBox = OverflowBox_default; exports.Padding = Padding2; exports.Painter = BaseCustomPaint_default; exports.Paragraph = Paragraph; exports.Path = path_default; exports.Positioned = Positioned_default; exports.Provider = Provider_default; exports.RRect = r_rect_default; exports.Radius = radius_default; exports.ReactiveChangeNotifier = ReactiveChangeNotifier_default; exports.Rect = rect_default; exports.RenderAligningShiftedBox = RenderAligningShiftedBox_default; exports.RenderBox = RenderBox_default; exports.RenderFrameDispatcher = RenderFrameDispatcher_default; exports.RenderObject = RenderObject_default; exports.RenderObjectElement = RenderObjectElement_default; exports.RenderObjectToWidgetAdapter = RenderObjectToWidgetAdapter_default; exports.RenderObjectWidget = RenderObjectWidget_default; exports.RenderPipeline = RenderPipeline; exports.RenderPipelineProvider = RenderPipelineProvider; exports.RenderView = RenderView_default; exports.RichText = RichText_default; exports.Row = Row; exports.Scheduler = Scheduler_default; exports.SingleChildRenderObject = SingleChildRenderObject_default; exports.SingleChildRenderObjectWidget = SingleChildRenderObjectWidget_default; exports.Size = size_default; exports.SizedBox = SizedBox_default; exports.Spacer = Spacer_default; exports.Stack = Stack; exports.StackFit = stack_fit_default; exports.State = State; exports.StatefulElement = StatefulElement; exports.StatefulWidget = StatefulWidget_default; exports.StatelessElement = StatelessElement_default; exports.StatelessWidget = StatelessWidget_default; exports.SvgPainter = SvgPainter; exports.Text = Text_default; exports.TextAlign = text_align_default; exports.TextBaseline = text_baseline_default; exports.TextDirection = text_direction_default; exports.TextField = TextField_default; exports.TextOverflow = text_overflow_default; exports.TextPainter = TextPainter; exports.TextSpan = text_span_default; exports.TextStyle = text_style_default; exports.TextWidthBasis = text_width_basis_default; exports.ToolTipPosition = ToolTipPosition; exports.Tooltip = Tooltip_default; exports.Transform = Transform_default; exports.Tween = Tween_default; exports.UnconstrainedBox = UnconstrainedBox_default; exports.Utils = Utils; exports.Vector2 = vector2_default; exports.Vector3 = vector3_default; exports.Vector4 = vector4_default; exports.VerticalDirection = VerticalDirection; exports.Widget = Widget_default; exports.ZIndex = ZIndex_default;
|
|
21167
|
+
exports.Align = Align_default; exports.Alignment = alignment_default; exports.AnimatedAlign = AnimatedAlign_default; exports.AnimatedBaseWidgetState = AnimatedBaseWidgetState; exports.AnimatedContainer = AnimatedContainer_default; exports.AnimatedFractionallySizedBox = AnimatedFractionallySizedBox_default; exports.AnimatedOpacity = AnimatedOpacity_default; exports.AnimatedPadding = AnimatedPadding_default; exports.AnimatedPositioned = AnimatedPositioned_default; exports.AnimatedRotation = AnimatedRotation_default; exports.AnimatedScale = AnimatedScale_default; exports.AnimatedSlide = AnimatedSlide_default; exports.Animation = Animation_default; exports.AnimationController = AnimationController_default; exports.AppRunner = AppRunner; exports.AspectRatio = AspectRatio_default; exports.Axis = Axis; exports.Border = border_default; exports.BorderRadius = BorderRadius; exports.BorderRadiusGeometry = border_radius_geometry_default; exports.BorderSide = BorderSide; exports.BorderStyle = border_style_default; exports.BoxDecoration = BoxDecoration; exports.BoxShadow = box_shadow_default; exports.BuildContext = BuildContext; exports.BuildOwner = BuildOwner_default; exports.Builder = Builder_default; exports.Calculable = calculable_default; exports.CalculableTween = CalculableTween_default; exports.CanvasPainter = CanvasPainter; exports.Center = Center; exports.ChangeNotifier = ChangeNotifier_default; exports.ChangeNotifierProvider = ChangeNotifierProvider_default; exports.ClipOval = ClipOval; exports.ClipPath = ClipPath_default; exports.ClipRRect = ClipOval2; exports.ClipRect = ClipRect; exports.Color = color_default; exports.ColoredBox = ColoredBox_default; exports.Colors = colors_exports; exports.Column = Column; exports.ComponentElement = ComponentElement_default; exports.ComponentWidget = StatelessWidget_default; exports.ConstrainedBox = ConstrainedBox_default; exports.Constraints = constraints_default; exports.ConstraintsTransformBox = ConstraintsTransformBox_default; exports.Container = Container_default; exports.CrossAxisAlignment = CrossAxisAlignment; exports.Curve = Curve_default; exports.CurvedAnimation = CurvedAnimation_default; exports.Curves = Curves_default; exports.CustomPaint = CustomPaint_default; exports.Data = data_default; exports.DecoratedBox = DecoratedBox_default; exports.Draggable = Draggable_default; exports.EdgeInsets = edge_insets_default; exports.Element = Element_default; exports.Expanded = Expanded_default; exports.Flex = Flex2; exports.Flexible = Flexible_default; exports.FractionalTranslation = FractionalTranslation_default; exports.FractionallySizedBox = FractionallySizedBox_default; exports.Gap = gap_default; exports.GestureDetector = GestureDetector_default; exports.GlobalKey = Globalkey_default; exports.Grid = Grid_default; exports.Image = Image_default; exports.ImplicitlyAnimatedWidget = ImplicitlyAnimatedWidget; exports.ImplicitlyAnimatedWidgetState = ImplicitlyAnimatedWidgetState; exports.IndexedStack = IndexedStack2; exports.IntrinsicHeight = IntrinsicHeight_default; exports.IntrinsicWidth = IntrinsicWidth_default; exports.LimitedBox = LimitedBox_default; exports.Listenable = Listenable; exports.MainAxisAlignment = MainAxisAlignment; exports.MainAxisSize = MainAxisSize; exports.Matrix3 = matrix3_default; exports.Matrix4 = matrix4_default; exports.MultiChildRenderObject = MultiChildRenderObject_default; exports.MultiChildRenderObjectWidget = MultiChildRenderObjectWidget_default; exports.ObjectFit = ObjectFit; exports.ObjectPosition = ObjectPosition; exports.Offset = offset_default; exports.Opacity = Opacity_default; exports.OverflowBox = OverflowBox_default; exports.Padding = Padding2; exports.Painter = BaseCustomPaint_default; exports.Paragraph = Paragraph; exports.Path = path_default; exports.Positioned = Positioned_default; exports.Provider = Provider_default; exports.RRect = r_rect_default; exports.Radius = radius_default; exports.ReactiveChangeNotifier = ReactiveChangeNotifier_default; exports.Rect = rect_default; exports.RenderAligningShiftedBox = RenderAligningShiftedBox_default; exports.RenderBox = RenderBox_default; exports.RenderFrameDispatcher = RenderFrameDispatcher_default; exports.RenderObject = RenderObject_default; exports.RenderObjectElement = RenderObjectElement_default; exports.RenderObjectToWidgetAdapter = RenderObjectToWidgetAdapter_default; exports.RenderObjectWidget = RenderObjectWidget_default; exports.RenderPipeline = RenderPipeline; exports.RenderPipelineProvider = RenderPipelineProvider; exports.RenderView = RenderView_default; exports.RichText = RichText_default; exports.Row = Row; exports.Scheduler = Scheduler_default; exports.SingleChildRenderObject = SingleChildRenderObject_default; exports.SingleChildRenderObjectWidget = SingleChildRenderObjectWidget_default; exports.Size = size_default; exports.SizedBox = SizedBox_default; exports.Spacer = Spacer_default; exports.Stack = Stack; exports.StackFit = stack_fit_default; exports.State = State; exports.StatefulElement = StatefulElement; exports.StatefulWidget = StatefulWidget_default; exports.StatelessElement = StatelessElement_default; exports.StatelessWidget = StatelessWidget_default; exports.SvgPainter = SvgPainter; exports.Text = Text_default; exports.TextAlign = text_align_default; exports.TextBaseline = text_baseline_default; exports.TextDirection = text_direction_default; exports.TextField = TextField_default; exports.TextOverflow = text_overflow_default; exports.TextPainter = TextPainter; exports.TextSpan = text_span_default; exports.TextStyle = text_style_default; exports.TextWidthBasis = text_width_basis_default; exports.ToolTipPosition = ToolTipPosition; exports.Tooltip = Tooltip_default; exports.Transform = Transform_default; exports.Tween = Tween_default; exports.UnconstrainedBox = UnconstrainedBox_default; exports.Utils = Utils; exports.Vector2 = vector2_default; exports.Vector3 = vector3_default; exports.Vector4 = vector4_default; exports.VerticalDirection = VerticalDirection; exports.Widget = Widget_default; exports.ZIndex = ZIndex_default;
|