Skip to content

Instantly share code, notes, and snippets.

@vvshard
vvshard / main.dart
Last active December 22, 2023 11:06
Yin and Yang: without CustomPaint (DartPad) for https://rosettacode.org/wiki/Yin_and_yang
import 'package:flutter/material.dart';
const color = [Colors.black, Colors.white];
Widget cR(int iColor, double r, {Widget? child}) => DecoratedBox(
decoration: BoxDecoration(color: color[iColor], shape: BoxShape.circle),
child: SizedBox.square(dimension: r * 2, child: Center(child: child)));
Widget yinYang(double r, [double th = 1.0]) => Padding(
padding: const EdgeInsets.all(5),
@vvshard
vvshard / main.dart
Last active December 18, 2023 12:55
Yin and Yang (DartPad) for https://rosettacode.org/wiki/Yin_and_yang
import 'dart:math' show pi;
import 'package:flutter/material.dart';
Path yinYang(double r, double x, double y, [double th = 1.0]) {
cR(double dY, double radius) => Rect.fromCircle(center: Offset(x, y + dY), radius: radius);
return Path()
..fillType = PathFillType.evenOdd
..addOval(cR(0, r + th))
..addOval(cR(r / 2, r / 6))
..addOval(cR(-r / 2, r / 6))
@vvshard
vvshard / main.dart
Last active April 7, 2024 07:20
Pythagoras tree: drawing in Flutter (DartPad) for https://rosettacode.org/wiki/Pythagoras_tree
import 'package:flutter/material.dart';
void main() => runApp(FittedBox(
child: CustomPaint(painter: TreePainter(), size: const Size(2400, 1600))));
class TreePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final stroke = Paint()
..style = PaintingStyle.stroke
@vvshard
vvshard / prepRustdocForTranslate.user.js
Last active December 21, 2022 14:29
User script for FF Greasemonkey: Preparing rustdoc pages for 'Translate Web Pages' add-on. See @description for details
// ==UserScript==
// @name Preparing rustdoc for 'Translate Web Pages' add-on
// @description Disables translation of navigation sections and entity names (both in text and in search results), as well as source code blocks in rustdoc pages (ex: in doc.rust-lang.org/stable/std/). !!! To translate comments in the code examples and in the code on the [src] pages, you must enable translation for <PRE> tags in "Translate Web Pages" preferences.
// @version 1.0.5
// @author vvshard
// @grant none
// @license MIT
// ==/UserScript==
if (["rustdoc", "rustdoc-page"].some(clNm => document.body.classList.contains(clNm))){