Skip to content

Commit 995ddb8

Browse files
committed
Fitst commit from Vinyl
1 parent 0b36de3 commit 995ddb8

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

lib/vinyl/widget_viewer.dart

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,51 @@ class WidgetViewer extends StatefulWidget {
1010
class _WidgetViewerState extends State<WidgetViewer> {
1111
double _horizontalRotation = 0;
1212
double _verticalRotation = 0;
13+
double _zRotation = 0;
14+
double _perspective = 0;
1315
double _zoom = 1;
1416

17+
final List<Color> colors = [Colors.green, Colors.yellow, Colors.purple];
18+
1519
@override
1620
Widget build(BuildContext context) {
1721
return Scaffold(
18-
appBar: AppBar(title: Text('3D Widget Viewer')),
22+
appBar: AppBar(title: Text('3D Stacked Widget Viewer')),
1923
body: Column(
2024
children: [
2125
Expanded(
2226
child: Center(
2327
child: Transform(
28+
// setEntry(0, 3, x): Translates along the X-axis
29+
// setEntry(1, 3, y): Translates along the Y-axis
30+
// setEntry(2, 3, z): Translates along the Z-axis
2431
transform: Matrix4.identity()
25-
..setEntry(3, 2, 0.001) // perspective
26-
..rotateY(_horizontalRotation * pi / 180)
27-
..rotateX(_verticalRotation * pi / 180)
32+
..setEntry(3, 2, 0.0003512553609721081) // perspectivez
33+
// ..setEntry(3, 1, _perspective) // y
34+
// ..setEntry(3, 0, _perspective) //x
35+
..rotateY(323 * pi / 180) // horixontal
36+
..rotateX(355 * pi / 180) // vertical
37+
..rotateZ(6 * pi / 180) //z : 32
2838
..scale(_zoom),
2939
alignment: Alignment.center,
30-
child: Container(
31-
width: 200,
32-
height: 200,
33-
color: Colors.blue,
34-
child: Center(
35-
child: Text('2D Widget',
36-
style: TextStyle(color: Colors.white))),
40+
child: Stack(
41+
children: List.generate(colors.length, (index) {
42+
return Transform(
43+
transform: Matrix4.identity()
44+
..translate(0.0, 0.0, -index * 50.0), // -index * 50.0
45+
child: Container(
46+
width: 200,
47+
height: 200,
48+
color: colors[index],
49+
child: Center(
50+
child: Text(
51+
'Layer ${index + 1}',
52+
style: TextStyle(color: Colors.white),
53+
),
54+
),
55+
),
56+
);
57+
}),
3758
),
3859
),
3960
),
@@ -56,6 +77,21 @@ class _WidgetViewerState extends State<WidgetViewer> {
5677
label:
5778
'Vertical Rotation: ${_verticalRotation.toStringAsFixed(0)}°',
5879
),
80+
_buildSlider(
81+
value: _zRotation,
82+
onChanged: (value) => setState(() => _zRotation = value),
83+
label: 'Z Rotation: ${_zRotation.toStringAsFixed(0)}°',
84+
),
85+
_buildSlider(
86+
value: _perspective,
87+
min: -0.1,
88+
max: 0.1,
89+
onChanged: (value) => setState(() {
90+
_perspective = value;
91+
print("Perspective, value: $_perspective");
92+
}),
93+
label: 'Perspective: ${_perspective.toStringAsFixed(0)}°',
94+
),
5995
_buildSlider(
6096
value: _zoom,
6197
min: 0.5,

0 commit comments

Comments
 (0)