Emojis and deadleaves.
- Clone this!
cd deadleaves && npm install && bower install && pip install -r requirements.txt
grunt
- Navigate here (localhost:3000)
Emojis and deadleaves.
Emojis and deadleaves.
cd deadleaves && npm install && bower install && pip install -r requirements.txt
grunt
Why not.
yo @dcjohnston:
The scales of the emojis will be drawn from a power-law distribution. Because JS, AFAIK, does not provide support for sampling from this distribution ๐ข, we need to implement it ourselves.
We can do this using the inverse of the cumulative density function (CDF) to map from probabilities to values. The cumulative density function at x records the probability that a random variable will take on a value less than or equal to x. For well-behaved distributions, this function is monotone increasing and bounded by 0 and 1, so it produces an invertible mapping between the set of possible values and the unit interval [0,1].
Therefore, we simply need to generate random values between 0 and 1 using Math.Random, then map them using the inverse CDF to generate our scales. ๐
The following python code defines a (higher-order) function that returns inverse CDFs for power-laws with different exponents alpha
. Roughly speaking, a higher power means that smaller values are produced. We also need to define a minimum value for the scale, here xmin
, so that we don't find ourselves in the awkward position of rendering emoji of zero size! ๐
def getInversePowerCDF(alpha,xmin):
def inversePowerCDF(p):
return alpha*xmin*p**(-1/(alpha+1))
return inversePowerCDF
Once we've defined the function inversePowerCDF
based on a user-provided alpha
, we need to produce a list of scales:
scales = [] #initialize
for eachEmoji in range(numEmojis):
p = Math.Random()
scales.append(inversePowerCDF(p))
This might also be a convenient time to produce a list of x and y locations - tuples in [0,1] x [0,1] - using Math.Random as well. If there's an efficient vectorization procedure for RNGs in JS, we can cheaply produce the 3 by numEmojis array of random numbers all at once! ๐ฏ ๐ ๐ mmhmm
Add a gallery page that stores (statically) 8 or so of our favorite emoji piles.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.