Commit 3b2c642c authored by Lila NICKLER's avatar Lila NICKLER

Exercice 3

parent 92e27496
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:math' as math; import 'dart:math' as math;
class Exercice1 extends StatelessWidget { class Exercice1 extends StatelessWidget {
Widget build(BuildContext context) Widget build(BuildContext context) {
{ var mediaQueryData = MediaQuery.of(context);
var mediaQueryData = MediaQuery.of(context); return Scaffold(
appBar: AppBar(
return Container( title: Text("Exercice 1"),
height:mediaQueryData.size.height - 200 , ),
child:Image.network("https://picsum.photos/512/1024"), body: Center(
); child: Container(
} height: mediaQueryData.size.height - 200,
child: Image.network("https://picsum.photos/512/1024")),
)
);
}
} }
class Exercice2 extends StatefulWidget { class Exercice2 extends StatefulWidget {
...@@ -28,116 +32,175 @@ class _Exercice2State extends State<Exercice2> { ...@@ -28,116 +32,175 @@ class _Exercice2State extends State<Exercice2> {
double _currentSlider3Value = 100.0; double _currentSlider3Value = 100.0;
bool _mirror = false; bool _mirror = false;
Image image = Image.network("https://picsum.photos/512/1024"); Image image = Image.network("https://picsum.photos/512/1024");
double _size ; double _size;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var mediaQueryData = MediaQuery.of(context); var mediaQueryData = MediaQuery.of(context);
//_size = 1/(_currentSlider3Value/100); return Scaffold(
appBar: AppBar(
return ListView( title: Text("Exercice 1"),
),
body: Center(
child:
ListView(
children: [
Container(
height: mediaQueryData.size.height * (2 / 3),
width: mediaQueryData.size.width,
child: Transform(
origin: Offset(mediaQueryData.size.width / 2,
mediaQueryData.size.height * (2 / 3) / 2),
transform: Matrix4(
1, 0, 0, 0, // scale X
0, 1, 0, 0, // scale Y
0, 0, 1, 0,
0, 0, 0, (1 / (_currentSlider3Value / 100)), // scale X&Y
)
..rotateX(math.pi / 180 * _currentSlider1Value)
..rotateY(_mirror ? math.pi : 0)
..rotateZ(math.pi / 180 * _currentSlider2Value),
child: Image.network("https://picsum.photos/512/1024")),
),
Row(
children: [
Container(
width: mediaQueryData.size.width / 8,
child:
Text("Rotation X")),
Container(
width: mediaQueryData.size.width * (7 / 8),
child: Slider(
value: _currentSlider1Value,
min: 0,
max: 360,
divisions: 360,
label: _currentSlider1Value.round().toString(),
onChanged: (double value) {
setState(() {
_currentSlider1Value = value;
});
}),)
],
),
Row(
children: [
Container(
width: mediaQueryData.size.width / 8,
child: Text("Rotation Y"),
),
Container(
width: mediaQueryData.size.width * (7 / 8),
child:
Slider(
value: _currentSlider2Value,
min: 0,
max: 360,
divisions: 360,
label: _currentSlider2Value.round().toString(),
onChanged: (double value) {
setState(() {
_currentSlider2Value = value;
});
},
)
),
]
),
Row(
children: [
Container(
width: mediaQueryData.size.width / 8,
child: Text("Taille"),
),
Container(
width: mediaQueryData.size.width * (7 / 8),
child: Slider(
value: _currentSlider3Value,
min: 0,
max: 100,
divisions: 100,
label: _currentSlider3Value.round().toString(),
onChanged: (double value) {
setState(() {
_currentSlider3Value = value;
});
},
)
)
]
),
Row(children: [
Container(
width: mediaQueryData.size.width / 7,
child: Text("Miroir"),),
Container(
child: Checkbox(
value: _mirror,
onChanged: (value) {
setState(() {
_mirror = !_mirror;
}
);
},
)
)
]
),
]
)
));
}
}
class Exercice3 extends StatelessWidget{
@override
Widget build(BuildContext context) {
return ListView(
children: [ children: [
Container( Card(child:
height: mediaQueryData.size.height*(2/3), ListTile(
width: mediaQueryData.size.width, title: Text("Exercice 1"),
child: Transform( subtitle: Text("Affichage d'une image"),
origin:Offset(mediaQueryData.size.width/2, mediaQueryData.size.height*(2/3)/2), leading: Icon(Icons.play_arrow_rounded),
transform: Matrix4( onTap: (){
1, 0, 0, 0, // scale X Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice1()));
0, 1, 0, 0, // scale Y },)),
0, 0, 1, 0, Card(child:
0, 0, 0, (1/(_currentSlider3Value/100)), // scale X&Y ListTile(
) leading: Icon(Icons.play_arrow_rounded),
..rotateX(math.pi / 180 * _currentSlider1Value) title: Text("Exercice 2"),
..rotateY(_mirror ? math.pi : 0) subtitle: Text("Rotation, taille et mode miroir"),
..rotateZ(math.pi / 180 * _currentSlider2Value), onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice2()));
child: Image.network("https://picsum.photos/512/1024")), },))
), ],
Row(
children: [ );
Container ( }
width:mediaQueryData.size.width/8 ,
child:
Text("Rotation X") ), }
Container (
width:mediaQueryData.size.width*(7/8), class Exercice4 extends StatelessWidget{
child: Slider( @override
value: _currentSlider1Value, Widget build(BuildContext context) {
min: 0, return Scaffold(
max: 360, appBar: AppBar(
divisions: 360,
label: _currentSlider1Value.round().toString(), title: Text("Exercice 1"),
onChanged:(double value){ ),
setState(() { body: Center(
_currentSlider1Value = value; child: Container(
}); child: Image.network("https://picsum.photos/512/1024")),
}),) )
],
),
Row(
children: [
Container(
width:mediaQueryData.size.width/8 ,
child:Text("Rotation Y"),
),
Container(
width:mediaQueryData.size.width*(7/8),
child:
Slider(
value: _currentSlider2Value,
min: 0,
max: 360,
divisions: 360,
label: _currentSlider2Value.round().toString(),
onChanged:(double value){
setState(() {
_currentSlider2Value = value;
});
},
)),
]
),
Row(
children: [
Container (
width:mediaQueryData.size.width/8,
child:Text("Taille"),
),
Container(
width:mediaQueryData.size.width*(7/8),
child:Slider(
value: _currentSlider3Value,
min: 0,
max: 100,
divisions: 100,
label: _currentSlider3Value.round().toString(),
onChanged:(double value){
setState(() {
_currentSlider3Value = value;
});
},
))
]
),
Row( children: [
Container (
width:mediaQueryData.size.width/7,
child: Text("Miroir"), ),
Container(
child: Checkbox(
value: _mirror,
onChanged: (value) {
setState(() {
_mirror = !_mirror;
});
},
))
]
),
]
); );
} }
}
}
...@@ -34,7 +34,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -34,7 +34,7 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
//static Exercice1 exo1 = new Exercice1(); //static Exercice1 exo1 = new Exercice1();
static Exercice2 exo2 = new Exercice2(); static Exercice3 exo3 = new Exercice3();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -46,7 +46,7 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -46,7 +46,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[ children: <Widget>[
Expanded(child: exo2) Expanded(child: exo3)
], ],
), ),
), ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment