From 6c1b7fac76a304929a5d3ce58575135d05b0086d Mon Sep 17 00:00:00 2001 From: Hans Kokx Date: Sun, 30 Aug 2026 15:47:17 +0200 Subject: [PATCH] Update launch config and use a custom painter Signed-off-by: Hans Kokx --- .vscode/launch.json | 28 ++++++++++++++++++---- .vscode/tasks.json | 24 +++++++++++++++++++ analysis_options.yaml | 2 +- lib/main.dart | 56 ++++++++++++++++++++++++++++++++++++++++--- pubspec.yaml | 4 ++-- 5 files changed, 104 insertions(+), 10 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ae5a50f..5cdeac0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,18 +1,38 @@ { + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { - "name": "clang - Build and debug active file", + "name": "Flutter", + "request": "launch", + "type": "dart" + }, + { + "name": "Flutter (profile mode)", + "request": "launch", + "type": "dart", + "flutterMode": "profile" + }, + { + "name": "Flutter (release mode)", + "request": "launch", + "type": "dart", + "flutterMode": "release" + }, + { + "name": "Raycaster (C)", "type": "cppdbg", "request": "launch", - "program": "${fileDirname}/${fileBasenameNoExtension}", + "program": "${workspaceFolder}/raycaster", "args": [], "stopAtEntry": false, - "cwd": "${fileDirname}", + "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "lldb", - "preLaunchTask": "C/C++: clang build active file" + "preLaunchTask": "Build raycaster" } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 152c0d5..51581be 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,30 @@ { "version": "2.0.0", "tasks": [ + { + "type": "cppbuild", + "label": "Build raycaster", + "command": "/usr/bin/clang", + "args": [ + "-g", + "${workspaceFolder}/raycaster.c", + "-o", + "${workspaceFolder}/raycaster", + "-framework", + "OpenGL", + "-framework", + "GLUT", + "-Wno-deprecated-declarations" + ], + "options": { + "cwd": "${workspaceFolder}" + }, + "problemMatcher": [ + "$gcc" + ], + "group": "build", + "detail": "Builds raycaster.c explicitly" + }, { "type": "cppbuild", "label": "C/C++: clang build active file", diff --git a/analysis_options.yaml b/analysis_options.yaml index 1b67a16..c676e76 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:flutter_lints/flutter.yaml +include: package:arcane_analysis/analysis_options.yaml analyzer: exclude: diff --git a/lib/main.dart b/lib/main.dart index 640824f..7ef05d7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,5 @@ -import 'package:flutter/material.dart'; +import "package:flutter/material.dart"; +import "package:flutter/rendering.dart"; void main() { runApp(const MainApp()); @@ -9,8 +10,57 @@ class MainApp extends StatelessWidget { @override Widget build(BuildContext context) { - return const MaterialApp( - home: Scaffold(body: Center(child: Text('Hello World!'))), + return LayoutBuilder( + builder: (context, constraints) => CustomPaint( + size: constraints.biggest, + painter: Sky(), + ), ); } } + +class Sky extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + final Rect rect = Offset.zero & size; + const RadialGradient gradient = RadialGradient( + center: Alignment(0.7, -0.6), + radius: 0.2, + colors: [Color(0xFFFFFF00), Color(0xFF0099FF)], + stops: [0.4, 1.0], + ); + canvas.drawRect(rect, Paint()..shader = gradient.createShader(rect)); + } + + @override + SemanticsBuilderCallback get semanticsBuilder { + return (Size size) { + // Annotate a rectangle containing the picture of the sun + // with the label "Sun". When text to speech feature is enabled on the + // device, a user will be able to locate the sun on this picture by + // touch. + Rect rect = Offset.zero & size; + final double width = size.shortestSide * 0.4; + rect = const Alignment(0.8, -0.9).inscribe(Size(width, width), rect); + return [ + CustomPainterSemantics( + rect: rect, + properties: const SemanticsProperties( + label: "Sun", + textDirection: TextDirection.ltr, + ), + ), + ]; + }; + } + + // Since this Sky painter has no fields, it always paints + // the same thing and semantics information is the same. + // Therefore we return false here. If we had fields (set + // from the constructor) then we would return true if any + // of them differed from the same fields on the oldDelegate. + @override + bool shouldRepaint(Sky oldDelegate) => false; + @override + bool shouldRebuildSemantics(Sky oldDelegate) => false; +} diff --git a/pubspec.yaml b/pubspec.yaml index 8810461..618ba6b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: raycaster description: "A new Flutter project." -publish_to: 'none' +publish_to: "none" version: 0.1.0+1 environment: @@ -11,9 +11,9 @@ dependencies: sdk: flutter dev_dependencies: + arcane_analysis: ^1.0.5 flutter_test: sdk: flutter - flutter_lints: ^6.0.0 flutter: uses-material-design: true