A comparison between rendering circles in SVG and canvas. The functions are purposely written separately but similarly to show some key differences. Notably, SVG's structure allows us to take advantage of D3's wonderful data binding capabilities, which makes diffing new data against present data expressive and easy. Canvas will perform better when animating many nodes (not shown here) and makes styling more succinct, but try zooming in a couple of steps (Cmd-plus in OSX, Ctrl-plus in Windows) to see the difference between rendering pixels and vectors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"workbench.colorTheme": "Base16 Eighties Dark", | |
"workbench.startupEditor": "none", | |
"workbench.editor.revealIfOpen": true, | |
"window.zoomLevel": 0, | |
"editor.fontFamily": "Ubuntu Mono", | |
"editor.tokenColorCustomizations": { | |
"variables": "#d3d0c8ff", | |
"textMateRules":[ | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'), | |
d3 = require('d3'); | |
var document = jsdom.jsdom(); | |
var rect = d3.select(document.body).append('svg').append('rect'); | |
// This works... | |
rect | |
.attr('width', 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 | |
height: 400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gistup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gistup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash'); | |
// Pretty print for JSON-style objects. | |
function pprint(obj) { | |
if (!pprint.indent) pprint.indent = ''; | |
if (_.isPlainObject(obj)) { | |
_.forOwn(obj, function(v, k) { | |
if (_.isArray(v) || _.isPlainObject(v)) { | |
console.log(pprint.indent + k + ':'); | |
pprint.indent += ' '; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"excludes": [ | |
"$RECYCLE.BIN", | |
"RECYCLER", | |
"RecoveryBin", | |
"System Volume Information", | |
"Thumbs.db", | |
"desktop.ini", | |
"Desktop.ini", | |
"*.SYS", |
NewerOlder