Skip to content

Instantly share code, notes, and snippets.

@pinkeshdarji
Created March 4, 2021 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pinkeshdarji/acf104ef2f460aae265b86613ddf34ae to your computer and use it in GitHub Desktop.
Save pinkeshdarji/acf104ef2f460aae265b86613ddf34ae to your computer and use it in GitHub Desktop.
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.teal,
brightness: Brightness.dark,
// textButtonTheme: TextButtonThemeData(
// style: TextButton.styleFrom(primary: Colors.red)),
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Custom paint Demo'),
),
body: Container(
child: CustomPaint(
size: Size(400,(400*0.5).toDouble()), //You can Replace [WIDTH] with your desired width for Custom Paint and height will be calculated automatically
painter: RPSCustomPainter(),
),
),
);
}
}
class RPSCustomPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint_0 = new Paint()
..color = const Color(0xFFE8BB57)
..style = PaintingStyle.fill
..strokeWidth = 1;
Path path_0 = Path();
path_0.moveTo(size.width * 0.0625000, 0);
path_0.lineTo(size.width * 0.6125000, 0);
path_0.quadraticBezierTo(size.width * 0.6120750, size.height * 0.0239500,
size.width * 0.6270000, size.height * 0.0290000);
path_0.quadraticBezierTo(size.width * 0.6270000, size.height * 0.0437500,
size.width * 0.6270000, size.height * 0.1000000);
path_0.quadraticBezierTo(size.width * 0.6131000, size.height * 0.1000750,
size.width * 0.6125000, size.height * 0.1250000);
path_0.quadraticBezierTo(size.width * 0.6125875, size.height * 0.1492000,
size.width * 0.6270000, size.height * 0.1500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.2000000);
path_0.quadraticBezierTo(size.width * 0.6129750, size.height * 0.2009500,
size.width * 0.6125000, size.height * 0.2250000);
path_0.quadraticBezierTo(size.width * 0.6127125, size.height * 0.2503500,
size.width * 0.6270000, size.height * 0.2500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.3000000);
path_0.quadraticBezierTo(size.width * 0.6126375, size.height * 0.2996750,
size.width * 0.6125000, size.height * 0.3250000);
path_0.quadraticBezierTo(size.width * 0.6129125, size.height * 0.3491250,
size.width * 0.6270000, size.height * 0.3500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.4000000);
path_0.quadraticBezierTo(size.width * 0.6127250, size.height * 0.3998000,
size.width * 0.6125000, size.height * 0.4250000);
path_0.quadraticBezierTo(size.width * 0.6126250, size.height * 0.4500500,
size.width * 0.6270000, size.height * 0.4500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.5000000);
path_0.quadraticBezierTo(size.width * 0.6128875, size.height * 0.4993250,
size.width * 0.6125000, size.height * 0.5250000);
path_0.quadraticBezierTo(size.width * 0.6129000, size.height * 0.5496000,
size.width * 0.6270000, size.height * 0.5500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.6000000);
path_0.quadraticBezierTo(size.width * 0.6130250, size.height * 0.5994250,
size.width * 0.6125000, size.height * 0.6270000);
path_0.quadraticBezierTo(size.width * 0.6126750, size.height * 0.6504250,
size.width * 0.6270000, size.height * 0.6500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.7000000);
path_0.quadraticBezierTo(size.width * 0.6127375, size.height * 0.7017750,
size.width * 0.6125000, size.height * 0.7250000);
path_0.quadraticBezierTo(size.width * 0.6124625, size.height * 0.7503000,
size.width * 0.6270000, size.height * 0.7500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.8000000);
path_0.quadraticBezierTo(size.width * 0.6129125, size.height * 0.8010750,
size.width * 0.6125000, size.height * 0.8250000);
path_0.quadraticBezierTo(size.width * 0.6123375, size.height * 0.8493750,
size.width * 0.6270000, size.height * 0.8500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.9000000);
path_0.quadraticBezierTo(size.width * 0.6131500, size.height * 0.9015000,
size.width * 0.6125000, size.height * 0.9250000);
path_0.quadraticBezierTo(size.width * 0.6124875, size.height * 0.9503500,
size.width * 0.6270000, size.height * 0.9500000);
path_0.lineTo(size.width * 0.6270000, size.height * 0.9750000);
path_0.quadraticBezierTo(size.width * 0.6122000, size.height * 0.9738750,
size.width * 0.6125000, size.height);
path_0.quadraticBezierTo(size.width * 0.4750000, size.height,
size.width * 0.0625000, size.height);
path_0.quadraticBezierTo(size.width * 0.0013375, size.height * 0.9976500, 0,
size.height * 0.8750000);
path_0.quadraticBezierTo(
0, size.height * 0.8312500, 0, size.height * 0.6270000);
path_0.quadraticBezierTo(size.width * 0.0622000, size.height * 0.6257750,
size.width * 0.0625000, size.height * 0.5000000);
path_0.quadraticBezierTo(size.width * 0.0623500, size.height * 0.3755750, 0,
size.height * 0.3750000);
path_0.quadraticBezierTo(
0, size.height * 0.1875000, 0, size.height * 0.1250000);
path_0.quadraticBezierTo(size.width * 0.0031875, size.height * 0.0027500,
size.width * 0.0625000, 0);
path_0.close();
canvas.drawPath(path_0, paint_0);
Paint paint_1 = new Paint()
..color = const Color(0xFFE4E4E4)
..style = PaintingStyle.fill
..strokeWidth = 1;
Path path_1 = Path();
path_1.moveTo(size.width * 0.64, 0);
path_1.quadraticBezierTo(size.width * 0.86, 0, size.width * 0.94, 0);
path_1.quadraticBezierTo(
size.width * 1.00, size.height * 0.00, size.width, size.height * 0.13);
path_1.quadraticBezierTo(
size.width, size.height * 0.19, size.width, size.height * 0.38);
path_1.quadraticBezierTo(size.width * 0.94, size.height * 0.37,
size.width * 0.94, size.height * 0.50);
path_1.quadraticBezierTo(
size.width * 0.94, size.height * 0.62, size.width, size.height * 0.63);
path_1.lineTo(size.width, size.height * 0.88);
path_1.quadraticBezierTo(
size.width * 1.00, size.height * 1.00, size.width * 0.94, size.height);
path_1.cubicTo(size.width * 0.86, size.height, size.width * 0.71,
size.height, size.width * 0.64, size.height);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.97,
size.width * 0.6270, size.height * 0.975);
path_1.lineTo(size.width * 0.6270, size.height * 0.95);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.95,
size.width * 0.64, size.height * 0.93);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.90,
size.width * 0.6270, size.height * 0.90);
path_1.lineTo(size.width * 0.6270, size.height * 0.85);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.85,
size.width * 0.64, size.height * 0.82);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.80,
size.width * 0.6270, size.height * 0.80);
path_1.lineTo(size.width * 0.6270, size.height * 0.75);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.75,
size.width * 0.64, size.height * 0.72);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.70,
size.width * 0.6270, size.height * 0.70);
path_1.lineTo(size.width * 0.6270, size.height * 0.65);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.65,
size.width * 0.64, size.height * 0.63);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.60,
size.width * 0.6270, size.height * 0.60);
path_1.lineTo(size.width * 0.6270, size.height * 0.55);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.55,
size.width * 0.64, size.height * 0.53);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.50,
size.width * 0.6270, size.height * 0.50);
path_1.lineTo(size.width * 0.6270, size.height * 0.45);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.45,
size.width * 0.64, size.height * 0.42);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.40,
size.width * 0.6270, size.height * 0.40);
path_1.lineTo(size.width * 0.6270, size.height * 0.35);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.35,
size.width * 0.64, size.height * 0.33);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.30,
size.width * 0.6270, size.height * 0.30);
path_1.lineTo(size.width * 0.6270, size.height * 0.25);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.25,
size.width * 0.64, size.height * 0.23);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.20,
size.width * 0.6270, size.height * 0.20);
path_1.lineTo(size.width * 0.6270, size.height * 0.15);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.15,
size.width * 0.64, size.height * 0.13);
path_1.quadraticBezierTo(size.width * 0.64, size.height * 0.10,
size.width * 0.6270, size.height * 0.10);
path_1.lineTo(size.width * 0.6270, size.height * 0.03);
path_1.quadraticBezierTo(
size.width * 0.64, size.height * 0.02, size.width * 0.64, 0);
path_1.close();
canvas.drawPath(path_1, paint_1);
Paint paint_2 = new Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = 1;
Path path_2 = Path();
path_2.moveTo(size.width * 0.0625000, size.height * 0.0500000);
path_2.lineTo(size.width * 0.5500000, size.height * 0.0500000);
path_2.quadraticBezierTo(size.width * 0.5751625, size.height * 0.0446500,
size.width * 0.5750000, size.height * 0.1000000);
path_2.quadraticBezierTo(size.width * 0.5750000, size.height * 0.3000000,
size.width * 0.5750000, size.height * 0.9000000);
path_2.quadraticBezierTo(size.width * 0.5730500, size.height * 0.9525500,
size.width * 0.5375000, size.height * 0.9500000);
path_2.quadraticBezierTo(size.width * 0.4187500, size.height * 0.9500000,
size.width * 0.0625000, size.height * 0.9500000);
path_2.quadraticBezierTo(size.width * 0.0227750, size.height * 0.9485000,
size.width * 0.0250000, size.height * 0.8750000);
path_2.quadraticBezierTo(size.width * 0.0250000, size.height * 0.8312500,
size.width * 0.0250000, size.height * 0.7000000);
path_2.quadraticBezierTo(size.width * 0.0998750, size.height * 0.6626000,
size.width * 0.1000000, size.height * 0.5000000);
path_2.quadraticBezierTo(size.width * 0.0976375, size.height * 0.3463750,
size.width * 0.0250000, size.height * 0.3000000);
path_2.quadraticBezierTo(size.width * 0.0250000, size.height * 0.1687500,
size.width * 0.0250000, size.height * 0.1250000);
path_2.quadraticBezierTo(size.width * 0.0254000, size.height * 0.0527000,
size.width * 0.0625000, size.height * 0.0500000);
path_2.close();
canvas.drawPath(path_2, paint_2);
Paint paint_3 = new Paint()
..color = Colors.black
..style = PaintingStyle.stroke
..strokeWidth = 1;
Path path_3 = Path();
path_3.moveTo(size.width * 0.7125000, size.height * 0.0500000);
path_3.quadraticBezierTo(size.width * 0.8812500, size.height * 0.0500000,
size.width * 0.9375000, size.height * 0.0500000);
path_3.quadraticBezierTo(size.width * 0.9736875, size.height * 0.0485750,
size.width * 0.9750000, size.height * 0.1250000);
path_3.cubicTo(
size.width * 0.9750000,
size.height * 0.1687500,
size.width * 0.9750000,
size.height * 0.2562500,
size.width * 0.9750000,
size.height * 0.3000000);
path_3.cubicTo(
size.width * 0.9508750,
size.height * 0.3115750,
size.width * 0.9045000,
size.height * 0.3680250,
size.width * 0.9000000,
size.height * 0.5000000);
path_3.quadraticBezierTo(size.width * 0.9065125, size.height * 0.6526250,
size.width * 0.9750000, size.height * 0.7000000);
path_3.quadraticBezierTo(size.width * 0.9750000, size.height * 0.8500000,
size.width * 0.9750000, size.height * 0.9000000);
path_3.quadraticBezierTo(size.width * 0.9723500, size.height * 0.9500750,
size.width * 0.9375000, size.height * 0.9500000);
path_3.lineTo(size.width * 0.7000000, size.height * 0.9500000);
path_3.quadraticBezierTo(size.width * 0.6735875, size.height * 0.9556750,
size.width * 0.6750000, size.height * 0.9000000);
path_3.cubicTo(
size.width * 0.6750000,
size.height * 0.7000000,
size.width * 0.6750000,
size.height * 0.3000000,
size.width * 0.6750000,
size.height * 0.1000000);
path_3.cubicTo(
size.width * 0.6773875,
size.height * 0.0457000,
size.width * 0.6879625,
size.height * 0.0512750,
size.width * 0.7125000,
size.height * 0.0500000);
path_3.close();
canvas.drawPath(path_3, paint_3);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment