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")),
)
); );
} }
} }
...@@ -28,26 +32,32 @@ class _Exercice2State extends State<Exercice2> { ...@@ -28,26 +32,32 @@ 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: [ children: [
Container( Container(
height: mediaQueryData.size.height*(2/3), height: mediaQueryData.size.height * (2 / 3),
width: mediaQueryData.size.width, width: mediaQueryData.size.width,
child: Transform( child: Transform(
origin:Offset(mediaQueryData.size.width/2, mediaQueryData.size.height*(2/3)/2), origin: Offset(mediaQueryData.size.width / 2,
mediaQueryData.size.height * (2 / 3) / 2),
transform: Matrix4( transform: Matrix4(
1, 0, 0, 0, // scale X 1, 0, 0, 0, // scale X
0, 1, 0, 0, // scale Y 0, 1, 0, 0, // scale Y
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 0, (1/(_currentSlider3Value/100)), // scale X&Y 0, 0, 0, (1 / (_currentSlider3Value / 100)), // scale X&Y
) )
..rotateX(math.pi / 180 * _currentSlider1Value) ..rotateX(math.pi / 180 * _currentSlider1Value)
..rotateY(_mirror ? math.pi : 0) ..rotateY(_mirror ? math.pi : 0)
...@@ -57,19 +67,19 @@ class _Exercice2State extends State<Exercice2> { ...@@ -57,19 +67,19 @@ class _Exercice2State extends State<Exercice2> {
), ),
Row( Row(
children: [ children: [
Container ( Container(
width:mediaQueryData.size.width/8 , width: mediaQueryData.size.width / 8,
child: child:
Text("Rotation X") ), Text("Rotation X")),
Container ( Container(
width:mediaQueryData.size.width*(7/8), width: mediaQueryData.size.width * (7 / 8),
child: Slider( child: Slider(
value: _currentSlider1Value, value: _currentSlider1Value,
min: 0, min: 0,
max: 360, max: 360,
divisions: 360, divisions: 360,
label: _currentSlider1Value.round().toString(), label: _currentSlider1Value.round().toString(),
onChanged:(double value){ onChanged: (double value) {
setState(() { setState(() {
_currentSlider1Value = value; _currentSlider1Value = value;
}); });
...@@ -79,11 +89,11 @@ class _Exercice2State extends State<Exercice2> { ...@@ -79,11 +89,11 @@ class _Exercice2State extends State<Exercice2> {
Row( Row(
children: [ children: [
Container( Container(
width:mediaQueryData.size.width/8 , width: mediaQueryData.size.width / 8,
child:Text("Rotation Y"), child: Text("Rotation Y"),
), ),
Container( Container(
width:mediaQueryData.size.width*(7/8), width: mediaQueryData.size.width * (7 / 8),
child: child:
Slider( Slider(
value: _currentSlider2Value, value: _currentSlider2Value,
...@@ -91,53 +101,106 @@ class _Exercice2State extends State<Exercice2> { ...@@ -91,53 +101,106 @@ class _Exercice2State extends State<Exercice2> {
max: 360, max: 360,
divisions: 360, divisions: 360,
label: _currentSlider2Value.round().toString(), label: _currentSlider2Value.round().toString(),
onChanged:(double value){ onChanged: (double value) {
setState(() { setState(() {
_currentSlider2Value = value; _currentSlider2Value = value;
}); });
}, },
)), )
),
] ]
), ),
Row( Row(
children: [ children: [
Container ( Container(
width:mediaQueryData.size.width/8, width: mediaQueryData.size.width / 8,
child:Text("Taille"), child: Text("Taille"),
), ),
Container( Container(
width:mediaQueryData.size.width*(7/8), width: mediaQueryData.size.width * (7 / 8),
child:Slider( child: Slider(
value: _currentSlider3Value, value: _currentSlider3Value,
min: 0, min: 0,
max: 100, max: 100,
divisions: 100, divisions: 100,
label: _currentSlider3Value.round().toString(), label: _currentSlider3Value.round().toString(),
onChanged:(double value){ onChanged: (double value) {
setState(() { setState(() {
_currentSlider3Value = value; _currentSlider3Value = value;
}); });
}, },
)) )
)
] ]
), ),
Row( children: [ Row(children: [
Container ( Container(
width:mediaQueryData.size.width/7, width: mediaQueryData.size.width / 7,
child: Text("Miroir"), ), child: Text("Miroir"),),
Container( Container(
child: Checkbox( child: Checkbox(
value: _mirror, value: _mirror,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
_mirror = !_mirror; _mirror = !_mirror;
}); }
);
}, },
)) )
)
] ]
), ),
] ]
); )
));
} }
} }
class Exercice3 extends StatelessWidget{
@override
Widget build(BuildContext context) {
return ListView(
children: [
Card(child:
ListTile(
title: Text("Exercice 1"),
subtitle: Text("Affichage d'une image"),
leading: Icon(Icons.play_arrow_rounded),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice1()));
},)),
Card(child:
ListTile(
leading: Icon(Icons.play_arrow_rounded),
title: Text("Exercice 2"),
subtitle: Text("Rotation, taille et mode miroir"),
onTap: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>Exercice2()));
},))
],
);
}
}
class Exercice4 extends StatelessWidget{
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Exercice 1"),
),
body: Center(
child: Container(
child: Image.network("https://picsum.photos/512/1024")),
)
);
}
}
...@@ -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