import 'package:flutter/material.dart';
import 'dart:math' as math;


class Exo2 extends StatefulWidget {
  const Exo2({super.key});

  @override
  State<Exo2> createState() => _Exo2();
}

class _Exo2 extends State<Exo2> {
  double rx = 0.2;
  double ry = 0.5;
  double rz = 0.0;
  bool mirror = false;
  double scale = 0.0;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Exo2",
      home: Scaffold(
        appBar: AppBar(leading: BackButton(onPressed: () => Navigator.of(context).pop()),
        title: const Text('Slider')),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Container(
              clipBehavior: Clip.hardEdge,
              decoration: const BoxDecoration(color: Colors.white),
              child: LayoutBuilder(
                builder: (context, constraints) {
                  return Transform(
                    alignment: Alignment.center,
                    transform: Matrix4.zero()
                        ..rotateX(rx)
                        ..rotateY(ry)
                        ..rotateZ(rz),
                    child: Center(child: Image.network('https://picsum.photos/512/1024',
                        width: constraints.maxHeight,
                        height: constraints.maxWidth,
                        fit: BoxFit.contain,
                    )),
                  );
                }
              ),
            ),
            Slider(
              min: 0,
              max: 2 * math.pi,
              value: rx,
              label: rx.round().toString(),
              onChanged: (double value) {
                setState(() {
                  rx = value;
                });
              },
            ),
            Slider(
              min: 0,
              max: 2 * math.pi,
              value: ry,
              label: ry.round().toString(),
              onChanged: (double value) {
                setState(() {
                  ry = value;
                });
              },
            ),Slider(
              min: 0,
              max: 2 * math.pi,
              value: rz,
              label: rz.round().toString(),
              onChanged: (double value) {
                setState(() {
                  rz = value;
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}