Skip to content

Commit 3cca681

Browse files
committed
Started work on time example
1 parent de2831b commit 3cca681

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

lib/examples/time_example.dart

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_shaders/common/shader_view.dart';
3+
4+
class TimeExample extends StatefulWidget {
5+
const TimeExample({Key? key}) : super(key: key);
6+
7+
@override
8+
State<TimeExample> createState() => _TimeExampleState();
9+
}
10+
11+
class _TimeExampleState extends State<TimeExample> {
12+
13+
@override
14+
void initState() {
15+
super.initState();
16+
}
17+
18+
@override
19+
Widget build(BuildContext context) {
20+
return const ShaderView(
21+
shaderName: 'time',
22+
timeUniform: 0,
23+
);
24+
}
25+
}

lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_shaders/examples/hello_example.dart';
2+
import 'package:flutter_shaders/examples/time_example.dart';
33

44
void main() {
55
runApp(const MyApp());
@@ -15,7 +15,7 @@ class MyApp extends StatelessWidget {
1515
theme: ThemeData(
1616
useMaterial3: true,
1717
),
18-
home: const HelloExample(),
18+
home: const TimeExample(),
1919
);
2020
}
2121
}

pubspec.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dev_dependencies:
5454
flutter:
5555
shaders:
5656
- shaders/hello.frag
57+
- shaders/time.frag
5758

5859
# The following line ensures that the Material Icons font is
5960
# included with your application, so that you can use the icons in

shaders/time.frag

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
out vec4 fragColor;
2+
3+
uniform float uTime;
4+
5+
void main() {
6+
fragColor = vec4(1.0, 0.0, 1.0, 1.0) * fract(uTime);
7+
}

0 commit comments

Comments
 (0)