Comments (2)
here is the code to remove too much close points and to convert float to int in dart
import 'package:xml/xml.dart';
...
final String stringSVG = _controller.toRawSVG()!;
final String stringSVGReduced =
optimiseSVG(stringSVG, float2int: true, minDistanceBetweenPoints: 3);
String optimiseSVG(String stringSVG,
{bool float2int = false, int minDistanceBetweenPoints = 0}) {
final document = XmlDocument.parse(stringSVG);
var svgroot = document.root;
for (XmlElement child in svgroot.childElements) {
if (child.localName == "svg") {
for (XmlElement childsvg in child.childElements) {
if (childsvg.localName == "polyline") {
List attrs = childsvg.attributes;
for (XmlAttribute attr in attrs) {
if (attr.localName == "points") {
String value = attr.value;
List<String> points = value.split(" ");
List<String> filteredPoints = [];
dynamic x_prec = -1;
dynamic y_prec = -1;
for (String point in points) {
List<String> xy = point.split(",");
double doublex = double.parse(xy[0]);
double doubley = double.parse(xy[1]);
dynamic x;
dynamic y;
if (float2int) {
x = doublex.round();
y = doubley.round();
} else {
x = doublex;
y = doubley;
}
if ((x - x_prec).abs() > minDistanceBetweenPoints ||
(y - y_prec).abs() > minDistanceBetweenPoints) {
String s = "${x},${y}";
filteredPoints.add(s);
x_prec = x;
y_prec = y;
}
}
childsvg.setAttribute("points", filteredPoints.join(" "));
}
}
}
}
}
}
return document.toString();
}
from signature.
Hi,
thanks, we will analyze this.
from signature.
Related Issues (20)
- App crashes spontaneously while drawing HOT 2
- problem with signature with Samsung HOT 3
- Black area in horizontal screenmode HOT 1
- Drawing gradually show after continuous drawing
- Wrapping the signature widget in padding draws out of right boundry HOT 1
- Problem with using Signature in a Stack HOT 1
- how can add text on signature ?
- when try to use m-pencil with signature the app hang
- Export toRawSVG dose not working correctly HOT 8
- When use onLongPress method to clear signature pad, it clear signature but when we start draw signature again it will display dot in position where we press long tap HOT 2
- Can we populate saved signature to signature pad? HOT 1
- Invalid width setting for iOS brush
- Dynamic Pressure Support breaks screen with Ipad and Apple Pencil HOT 1
- Signature svg error HOT 1
- SIgnatureController doesn't return Image from flutter/material.dart HOT 1
- Dynamic color change for penColor HOT 1
- _controller.isEmpty() constantly listening to changes to signature pad HOT 2
- toJson: Converting object to an encodable object failed: Instance of 'Point' HOT 4
- Contributing Guide missing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from signature.