- o = [xo = 0, yo = 0] is the origin
- A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
- lengths are in any unit (ex: pixels)
- code snippets are in JavaScript
angleRad = angleDeg * Math.PI / 180;
Result: 1 | |
Items { | |
TemplateId: "BADGE_BATTLE_ATTACK_WON" | |
Badge { | |
BadgeType: BADGE_BATTLE_ATTACK_WON | |
BadgeRanks: 4 | |
Targets: "\nd\350\007" | |
} | |
} | |
Items { |
// Start `node d3-server.js` | |
// Then visit http://localhost:1337/ | |
// | |
var d3 = require('d3'), | |
http = require('http') | |
http.createServer(function (req, res) { | |
// Chrome automatically sends a requests for favicons | |
// Looks like https://code.google.com/p/chromium/issues/detail?id=39402 isn't | |
// fixed or this is a regression. |
/* | |
This script counts all photos that are available on Flickr and Panoramio for a specific geo fence and returns a JSON object with the data. | |
For convenience it's embedded in a little node.js server so that you can upload it to your server and use it as an API. | |
Here's an example url with all query attributes prefilled. Please use your own Flickr API key! | |
The location is the Berlin TV Tower (http://en.wikipedia.org/wiki/Fernsehturm_Berlin) | |
Example URL: http://piccounter-philippschmitt.rhcloud.com/?lat=52.520732&lon=13.409537&latRes=0.00015&lonRes=0.0003&flickrKey=60d03369d3e92b4578c8f2df2de5af66 | |
render | |
for each particle | |
x, y = particle.position | |
color = sample( colorMap, x, y ) | |
noise = sample( noiseMap, x, y ) | |
angle = noise * PI * 2 | |
particle.velocity.add( cos(angle), sin(angle) ) |
All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout*. This is also called reflow or layout thrashing, and is common performance bottleneck.
elem.offsetLeft
, elem.offsetTop
, elem.offsetWidth
, elem.offsetHeight
, elem.offsetParent
elem.clientLeft
, elem.clientTop
, elem.clientWidth
, elem.clientHeight
elem.getClientRects()
, elem.getBoundingClientRect()
/*! | |
* quantize.js Copyright 2008 Nick Rabinowitz. | |
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php | |
*/ | |
// fill out a couple protovis dependencies | |
/*! | |
* Block below copied from Protovis: http://mbostock.github.com/protovis/ | |
* Copyright 2010 Stanford Visualization Group | |
* Licensed under the BSD License: http://www.opensource.org/licenses/bsd-license.php |
license: gpl-3.0 |
#use case: converting image sequence to .mp4 video | |
#official documentation: https://trac.ffmpeg.org/wiki/Create%20a%20video%20slideshow%20from%20images | |
#description: | |
# An image sequence follows the pattern, defaultCanvas0-000000000.png (9 zeros) | |
# video codec is libx264 | |
# pixel format yuv420p | |
# output file is named out.mp4 | |
ffmpeg -i 'defaultCanvas0-%9d.png' -c:v libx264 -pix_fmt yuv420p out.mp4 | |
#if you want your image sequence to start on a different number than index 0, use the -start_number parameter |
#include <node.h> | |
#include <v8.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
using namespace v8; | |
Handle<Value> getRandomCoords2D(const Arguments& args) { | |
HandleScope scope; | |