{"id":15293094,"url":"https://github.com/kreitai/smoothie","last_synced_at":"2025-07-26T02:32:00.306Z","repository":{"id":53024199,"uuid":"250763108","full_name":"kreitai/smoothie","owner":"kreitai","description":"Turn data points into a smooth Bézier curve in Dart","archived":false,"fork":false,"pushed_at":"2022-10-07T05:12:40.000Z","size":617,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-14T21:41:43.485Z","etag":null,"topics":["bezier","bezier-curves","dart","fintech-utility","flutter","smoothing","smoothing-lines","smoothing-splines"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kreitai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-28T10:09:34.000Z","updated_at":"2022-10-07T05:12:45.000Z","dependencies_parsed_at":"2022-09-05T01:51:01.489Z","dependency_job_id":null,"html_url":"https://github.com/kreitai/smoothie","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreitai%2Fsmoothie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreitai%2Fsmoothie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreitai%2Fsmoothie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreitai%2Fsmoothie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kreitai","download_url":"https://codeload.github.com/kreitai/smoothie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227643227,"owners_count":17797995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bezier","bezier-curves","dart","fintech-utility","flutter","smoothing","smoothing-lines","smoothing-splines"],"created_at":"2024-09-30T16:39:47.364Z","updated_at":"2024-12-01T23:23:31.276Z","avatar_url":"https://github.com/kreitai.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Pub Popularity](https://img.shields.io/pub/popularity/smoothie?style=plastic)![Pub Likes](https://img.shields.io/pub/likes/smoothie?style=plastic)![Pub Points](https://img.shields.io/pub/points/smoothie?style=plastic)](https://pub.dartlang.org/packages/smoothie)\n\n# smoothie\n\nCreate and sample a smooth Bézier curve going through a given set of points\n\n## Usage\n\nLet's say you have some arbitrary data (a list of points):\n\n```dart\nvar _originalDataSeries = \u003cPoint\u003e[\n    Point(0, 5),\n    Point(3, 15),\n    Point(5, 10),\n    Point(6, 6),\n    Point(9, 13),\n  ];\n```\n\nDefine a desired number of samples in the resulting curve:\n\n```dart\nint _sampleCount = 100;\n```\nImport `smoothie`:\n\n```\nimport 'package:smoothie/smoothie.dart';\n```\n\nCreate a smooth curve using the `getSampledCurveFromPoints` extension function on your original data:\n\n```dart\nList\u003cPoint\u003cnum\u003e\u003e _sampledCurve = _originalDataSeries.smooth(_sampleCount);\n```\n\nSee oversampling in action:\n\n\u003cimg src=\"https://raw.githubusercontent.com/alekskuzmin/smoothie/master/example/example.gif\" width=\"270\" height=\"480\"\u003e\n\nFull example using the `charts_flutter` package:\n\n```dart\nimport 'dart:math';\n\nimport 'package:charts_flutter/flutter.dart' as charts;\nimport 'package:flutter/material.dart';\nimport 'package:smoothie/smoothie.dart';\n\nvoid main() =\u003e runApp(MyApp());\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return MaterialApp(\n      title: 'Smoothie Demo',\n      theme: ThemeData(\n        primarySwatch: Colors.teal,\n      ),\n      home: SmoothieHomePage(),\n    );\n  }\n}\n\nclass SmoothieHomePage extends StatefulWidget {\n  SmoothieHomePage({Key? key}) : super(key: key);\n\n  @override\n  _SmoothieHomePageState createState() =\u003e _SmoothieHomePageState();\n}\n\nclass _SmoothieHomePageState extends State\u003cSmoothieHomePage\u003e {\n  int _samplingPointCount = 0;\n\n  var _originalDataSeries = \u003cPoint\u003e[\n    Point(0, 5),\n    Point(2, 15),\n    Point(3, 10),\n    Point(8, 6),\n    Point(9, 13),\n  ];\n\n  @override\n  void initState() {\n    super.initState();\n    _samplingPointCount = _originalDataSeries.length;\n  }\n\n  void _incrementCounter() {\n    setState(() {\n      _samplingPointCount++;\n    });\n  }\n\n  void _decrementCounter() {\n    setState(() {\n      if (_samplingPointCount \u003e _originalDataSeries.length)\n        _samplingPointCount--;\n    });\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    var series = [\n      new charts.Series(\n        domainFn: (Point chartData, _) =\u003e chartData.x,\n        measureFn: (Point chartData, _) =\u003e chartData.y,\n        colorFn: (Point point, _) =\u003e charts.MaterialPalette.teal.shadeDefault,\n        id: 'Example Series',\n        data: _originalDataSeries.smooth(\n          _samplingPointCount,\n        ),\n      ),\n    ];\n\n    var chart = new charts.LineChart(\n      series,\n      animate: false,\n      defaultRenderer: new charts.LineRendererConfig(\n        includeArea: true,\n      ),\n    );\n\n    return Scaffold(\n        appBar: AppBar(\n          title: Text(\"Smoothie Demo\"),\n        ),\n        body: Center(\n          child: Column(\n            mainAxisAlignment: MainAxisAlignment.center,\n            children: \u003cWidget\u003e[\n              Text(\n                'The smooth curve now has $_samplingPointCount points.',\n              ),\n              Container(\n                height: 200,\n                child: chart,\n              ),\n            ],\n          ),\n        ),\n        floatingActionButton: Row(\n          mainAxisAlignment: MainAxisAlignment.end,\n          children: \u003cWidget\u003e[\n            FloatingActionButton(\n              onPressed: _decrementCounter,\n              tooltip: 'Decrement',\n              child: Icon(Icons.remove),\n            ),\n            FloatingActionButton(\n              onPressed: _incrementCounter,\n              tooltip: 'Increment',\n              child: Icon(Icons.add),\n            ),\n          ],\n        ));\n  }\n}\n```\n\nIf you want to run the example as is and you are using null safety, you have to pass `--no-sound-null-safety` to the build command as the current version of `charts_flutter` does not yet support null safety:\n```console\ncd example\nflutter run --no-sound-null-safety\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreitai%2Fsmoothie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkreitai%2Fsmoothie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreitai%2Fsmoothie/lists"}