Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
scrolling: yes | |
license: MIT |
Since Twitter doesn't have an edit button, it's a suitable host for JavaScript modules.
Source tweet: https://twitter.com/rauchg/status/712799807073419264
const leftPad = await requireFromTwitter('712799807073419264');
import Foundation | |
public func getASTString() -> String { | |
// get the file path for the file "test.json" in the playground bundle | |
// let filePath = NSBundle.mainBundle().pathForResource("FirstTtest", ofType: "ast") | |
// get the contentData | |
let contentData = NSFileManager.defaultManager().contentsAtPath("a.txt") | |
height: 400 |
height: 2500 |
An experiment to see if I can get svg paths to animate only to a certain horizontal line while a user scrolls. Used in my unreleased wongfu side project.
Built with blockbuilder.org
Particle edges from d3_glyphEdges are the most difficult edge type to implement. Here's an example using a dendrogram and the connecting paths from the dendrogram. Remember that d3_glyphEdge.mutate.particle
mutates the edge data object, spawning new particles, updating the position of existing particles and deleting particles that have reached the end of the path, and it's this array that you use to represent the particles (either with SVG as in this example or, if you're dealing with a lot of particles, probably canvas). As such, an edge object needs to have, along with .source
and .target
, .frequency
(a positive number) to indicate the number of particles created per tick and .particles
(an array) to hold the created particles.
d3_glyphEdge.mutate.particle
does not include its own tick function so you need to create your own. This example uses d3.timer
whereas this network example uses the built-in ti
"use strict"; | |
var mori = require("mori"); | |
var get = mori.get; | |
var assoc = mori.assoc; | |
var hashMap = mori.hashMap; | |
var vector = mori.vector; | |
var map = mori.map; | |
var reduce = mori.reduce; |
extension String { | |
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect { | |
let storage = NSTextStorage(string: self) | |
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height)) | |
let layout = NSLayoutManager() | |
layout.addTextContainer(container) | |
storage.addLayoutManager(layout) | |
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length)) | |
container.lineFragmentPadding = 0.0 | |
let _ = layout.glyphRangeForTextContainer(container) |
license: mit |