Skip to content

Instantly share code, notes, and snippets.

View rutvik110's full-sized avatar
🎵
Humming

Rutvik Tak rutvik110

🎵
Humming
View GitHub Profile
@rutvik110
rutvik110 / custom_hero_transition_route.dart
Last active May 22, 2023 09:19
Custom navigation route that better support hero animations.
// Couldn't find the original developer and the gist of this code.
// Full credit goes to the original developer for the implementation of [HeroDialogRoute].
import 'package:flutter/material.dart';
class HeroDialogRoute<T> extends PageRoute<T> {
HeroDialogRoute({required this.builder}) : super();
final WidgetBuilder builder;
@rutvik110
rutvik110 / catenary_algorithm_rope_painter.dart
Last active January 19, 2023 19:11
An implementation of catenary algorithm in dart to paint a hanging rope.
// An example of simulating a simple rope. For, the construction of rope, catenary algorithm(https://en.wikipedia.org/wiki/Catenary) is used.
// The catenary is a curve that describes the shape of a hanging chain or cable, or the curve described by a freely hanging chain or cable.
// The implementation of catenary algorithm is based on the following js implementation : https://github.com/dulnan/catenary-curve/blob/9cb7e53e2db4bd5c499f5051abde8bfd853d946a/src/main.ts#L254
// In action : https://github.com/rutvik110/Flutter-Animations/tree/master/lib/flutter_design_challenges/ropes
import 'dart:developer' as dev;
import 'dart:math' as math;
import 'package:dart_numerics/dart_numerics.dart' as numerics;
@rutvik110
rutvik110 / ffmpegkit_helper.dart
Created December 27, 2022 02:03
FFmpegKit helper with imagesToVideo, imagesToGif, videoToGif helper
import 'dart:developer' as dev;
import 'dart:io';
import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';
import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart';
class FFMPEGKITHelper {
// image files should be stored in numbered format like 1.png, 2.png, 3.png etc to work with ffmpeg
static Future<String> imagesToMp4(List<File> images) async {
@rutvik110
rutvik110 / de_casteljaus_algorithm.dart
Created December 22, 2022 17:01
Implementation of De Casteljau's algorithm in dart
// Implementation of De Casteljau's algorithm in dart
// ref - https://pomax.github.io/bezierinfo/#splitting, https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm,
List<List<math.Point<num>>> drawCurvePoint(List<math.Point> points, double t) {
final List<math.Point<num>> left = <math.Point>[];
final List<math.Point<num>> right = <math.Point>[];
if (points.length == 1) {
left.add(points[0]);
right.add(points[0]);
//get the position of the latest coordinate on the curve at any point in animation based on animation position(t)
class BezierTween extends Tween<Offset> {
BezierTween({required this.begin, required this.end, required this.control})
: super(begin: begin, end: end);
@override
final Offset begin;
@override
final Offset end;
final Offset control;
#pragma glslify: range = require('glsl-range');
void main () {
// Your incoming value
float x = 25.0;
// Map value to 0..1 domain
// (no need if x is already in 0..1 range)
float min = 10.0;
float max = 100.0;
class Bar extends BodyComponent with ContactCallbacks, KeyboardHandler {
late BodyDef bodyDef;
late Vector2 barPosition;
@override
Body createBody() {
@rutvik110
rutvik110 / highcontrast_flutter.dart
Created August 7, 2022 16:43
highcontrast_flutter
Container(
color: MediaQuery.of(context).highContrast ? highContrastBgColor : BgColor,
child: const Text("Hello World!"),
),
@rutvik110
rutvik110 / counter_app_build.dart
Created August 7, 2022 09:20
Counter app build method
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
@rutvik110
rutvik110 / counter_app_build.dart
Created August 7, 2022 09:19
Counter app build method
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),