Skip to content

Instantly share code, notes, and snippets.

View basecode's full-sized avatar

Tobi Reiss basecode

  • Adobe
  • Basel
View GitHub Profile
@basecode
basecode / CGGeometry+Additions.h
Created July 19, 2012 19:11
CGGeometry+Additions
// CGGeometry+Additions.h
// Copyright (c) 2012 Tobias Reiss (MIT License)
#import <CoreGraphics/CGGeometry.h>
CG_INLINE CGRect CGRectScale(CGRect rect, CGFloat mult) {
CGPoint origin = rect.origin;
CGSize size = rect.size;
return CGRectMake(origin.x * mult, origin.y * mult, size.width * mult, size.height * mult);
}
@basecode
basecode / myTestConfig.js
Created July 26, 2012 00:15
A Test JSON file
{"BackgroundColor":"#000"}
@basecode
basecode / filter_foreignobject.js
Created August 2, 2012 22:46
SVGFilter + SVGForeignObjectElement
<svg width="500" height="500" style="background-color:orange;" version="1.1" xmlns="http://www.w3.org/2000/svg">
<defs>
<filter id="dropShadowStack">
<feGaussianBlur stdDeviation="3"/>
<feOffset dx="3" dy="3" result="offsetblur"/>
<feFlood flood-color="#720"/>
<feComposite in2="offsetblur" operator="in"/>
<feMerge>
<feMergeNode/>
<feMergeNode in="SourceGraphic"/>
@basecode
basecode / inline-worker-blob.html
Last active December 14, 2015 22:48
A simple example of spawning an inline worker using Blob API.
<html>
<body>
<script id="worker" type="text/worker">
onmessage = function(e) { postMessage('worker: ' + e.data); }
</script>
<script type="text/ecmascript">
var blob = new Blob([
document.querySelector('#worker').textContent
@basecode
basecode / css-animation-off-ui-thread.html
Last active December 15, 2015 17:49
CSS animations off the UI thread
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width">
<title>CSS animations</title>
<style>
.spin {
-webkit-animation: 3s rotate linear infinite;
animation: 3s rotate linear infinite;
background: red;
@basecode
basecode / debug_html_media_element.js
Last active December 21, 2015 08:49
Debug HTMLMediaElement
/**
* log events and properties
* from http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html
*/
(function(media) {
if (media instanceof HTMLMediaElement) {
console.log('Found', media);
} else {
console.log('Media not found');
}
@basecode
basecode / dom_renderer.md
Last active December 26, 2015 10:09
DOM Renderer

A quick draft of a "layered based" DOM renderer.

Why Layers?

A Layer, also referred to as "Stacking Context", describes a group of DisplayObjects that can be flattened and combined to one "Context". Why does that matter? Chances are supposed to be higher that continuous attribute changes due to animations can be applied much faster on a Layer that can potentially managed by GPU than on all children individually managed by GPU or even CPU. Especially when considering a frame-budget of only 16ms. Which means the animation could run at 60FPS.

When to create a Layer?

@basecode
basecode / di_requirejs.js
Last active December 31, 2015 20:09
Dependency injection using RequireJS. I don't like it!
// EntryPoint.js
define(function () {
return function EntryPoint(require) {
this.modul1 = new require("./Model1");
this.model2 = new require("./Model2");
};
});
// Model1.js
define(function () {
@basecode
basecode / rAF.js
Last active January 1, 2016 23:38 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@basecode
basecode / 7-things-react.md
Last active January 2, 2016 13:59
7 things I learned from React sourcecode. Website: http://facebook.github.io/react

It's all about Components.

  • Components can be created at runtime via createClass
  • Stringified and parsed
  • Existing DOM can be parsed via a "mount" algorithm.

DOM changes

  • React is event based and not "frame" based. It's not using a timer. DOM changes are cached until all events are done and flushed at once.
  • setState triggers DOM changes explicitly