-
-
Notifications
You must be signed in to change notification settings - Fork 489
/
card_real_3d_demo_page.dart
192 lines (185 loc) · 7.64 KB
/
card_real_3d_demo_page.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:zflutter/zflutter.dart';
class CardReal3DDemoPage extends StatefulWidget {
const CardReal3DDemoPage({super.key});
@override
State<CardReal3DDemoPage> createState() => _CardReal3DDemoPageState();
}
class _CardReal3DDemoPageState extends State<CardReal3DDemoPage> {
List<ZPathCommand> numPosition(
int index, double size, double width, double height, double z) {
double lineHeight = size / 2;
double initX = index * size - width / 2;
double initY = height / 7;
return [
ZMove.vector(ZVector(initX, initY, z)),
ZLine.vector(ZVector.only(x: initX - lineHeight, y: initY, z: z)),
ZLine.vector(
ZVector.only(x: initX - lineHeight, y: lineHeight + initY, z: z)),
ZLine.vector(
ZVector.only(x: initX - lineHeight, y: lineHeight + initY, z: z)),
ZLine.vector(ZVector.only(x: initX, y: lineHeight + initY, z: z)),
ZLine.vector(ZVector.only(x: initX, y: size + initY, z: z)),
ZLine.vector(ZVector.only(x: initX - lineHeight, y: size + initY, z: z)),
];
}
listNum(width, height, double z) {
List numbs = [];
for (int i = 0; i < 16; i++) {
numbs.addAll(numPosition(i + 1, 17, width, height, z));
}
return numbs;
}
@override
Widget build(BuildContext context) {
double width = 279;
double height = 194;
const double screenRadius = 15;
const double border = 4;
return Scaffold(
appBar: AppBar(title: const Text("CardReal3DDemoPage")),
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Colors.blueAccent, Colors.yellowAccent],
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
),
child: ZDragDetector(builder: (context, controller) {
return ZIllustration(
zoom: 1.0,
children: [
ZPositioned(
rotate: controller.rotate,
child: ZGroup(
children: [
ZGroup(
sortMode: SortMode.stack,
children: [
ZPositioned(
translate: const ZVector(0, 0, -border / 2),
child: ZRoundedRect(
width: width,
height: height,
borderRadius: screenRadius,
fill: true,
stroke: border,
color: Colors.black54,
),
),
ZToBoxAdapter(
width: width,
height: height,
child: ClipRRect(
borderRadius: BorderRadius.circular(screenRadius),
child: Stack(
children: [
SizedBox.fromSize(
size: Size(width, height),
child: Image.asset(
"static/card_down_2.png")),
Transform(
transform: Matrix4.identity()..rotateY(pi),
alignment: FractionalOffset.center,
child: const Align(
alignment: Alignment(0.5, -0.07),
child: Text(
"G S Y",
style: TextStyle(
fontSize: 23,
fontFamily: "bglbt",
fontStyle: FontStyle.italic,
fontWeight: FontWeight.bold),
),
),
)
],
),
),
),
],
),
ZGroup(
sortMode: SortMode.stack,
children: [
ZRoundedRect(
width: width,
height: height,
borderRadius: screenRadius,
fill: true,
color: Colors.blue.withAlpha(100),
),
ZToBoxAdapter(
width: width,
height: height,
child: ClipRRect(
borderRadius: BorderRadius.circular(screenRadius),
child: SizedBox.fromSize(
size: Size(width, height),
child: Image.asset("static/card_up_2.png")),
),
),
ZGroup(
sortMode: SortMode.update,
children: [
ZPositioned(
child: ZShape(
path: [...listNum(width, height, 2)],
fill: false,
stroke: 1,
closed: false,
backfaceColor: Colors.black54,
front: const ZVector.only(z: 100),
color: Colors.grey.withAlpha(200),
),
),
ZPositioned(
child: ZShape(
path: [...listNum(width, height, 1)],
fill: false,
stroke: 2,
closed: false,
backfaceColor: Colors.black54,
front: const ZVector.only(z: 100),
color: Colors.white.withAlpha(200),
),
),
ZPositioned(
rotate: const ZVector(0, 0, tau / 2),
child: ZShape(
visible: false,
path: [...listNum(width, height, 2)],
fill: false,
stroke: 2,
closed: false,
color: Colors.blueGrey.withAlpha(200),
),
),
ZPositioned(
rotate: const ZVector(0, 0, tau / 2),
child: ZShape(
visible: false,
path: [...listNum(width, height, 1)],
fill: false,
stroke: 2,
closed: false,
backfaceColor: Colors.black54,
front: const ZVector.only(z: 100),
color: Colors.white.withAlpha(200),
),
),
],
)
],
),
],
),
)
],
);
}),
),
);
}
}