smilesDrawer
smilesDrawer copied to clipboard
Pass default value `weights = null` to `SvgDrawer.draw()`
Resolves #171. Although the weights
parameter was added to SvgDrawer.draw()
in f3693b3, the method call in Drawer.draw()
wasn't updated correspondingly. Drawer.draw()
could be amended to also take a weights
argument, which it would pass to SvgDrawer.draw()
, but this might break existing code even more and would require an update of the documentation of the README.
Example to reproduce:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="dist/smiles-drawer.js"></script>
</head>
<body>
<canvas id="canvas" style="width: 200px; height: 200px; background-color: lightgrey"></canvas>
<script>
SmilesDrawer.parse(
"CCCNC",
tree => {
(new SmilesDrawer.Drawer()).draw(tree, 'canvas');
},
alert
);
</script>
</body>
</html>
Before the proposed change, this gives an error (TypeError: this.svgWrapper is null
). With the proposed change, the error is resolved and the structure is displayed correctly.
Deploy Preview for smilesdrawer-doc canceled.
Name | Link |
---|---|
Latest commit | 2c5d7abf02e8af167738945b068dcdfd0ba0f4cd |
Latest deploy log | https://app.netlify.com/sites/smilesdrawer-doc/deploys/648b7fc33f4a60000840defc |
It should also fix #161