Skip to content

Instantly share code, notes, and snippets.

View sebmarkbage's full-sized avatar

Sebastian Markbåge sebmarkbage

View GitHub Profile
/*
---
name: ART.Wedge
description: Wedge shape for ART
authors: [Sebastian Markbåge](http://calyptus.eu)
provides: [ART.Wedge]
<html>
<head>
<script src="mootools.js"></script>
<script src="mootools-1.2.4.4-more.js"></script>
<script src="rx.js"></script>
<script src="rx.mootools.js"></script>
<script>
window.addEvent('domready', function() {
public static Messages.Decimal BuildDecimal(decimal d)
{
int[] bits = decimal.GetBits(d.Value);
if (bits[2] != 0 || bits[1] < 0) throw new Exception("Unrepresentable decimal number. Out of range.");
long value = (((long)bits[1]) << 32) | ((long)bits[0] & 0xFFFFFFFFL);
if ((bits[3] & 0x80000000) != 0) value = -value;
uint scale = ((uint)bits[3] >> 16) & 0xF;
var playhead, art, keyframe1, keyframe2;
addEvent('load', function(){
art = new ART(400, 400).inject(document.body);
playhead = new ART.Rectangle(200, 200)
.inject(art)
.fill('#00F');
// A nicer comparison of CoffeeScript syntax compared to manual ECMAScript Harmony style syntax
// Assignment:
let number = 42,
opposite = true
// Conditions:
if (opposite) number = -42
// Functions:
@sebmarkbage
sebmarkbage / Lightbox.css
Created August 8, 2010 00:10
Old Lightbox implementation by Leon Radley and Sebastian Markbåge at Calyptus Life AB
.Lightbox
{
position: absolute;
background: #fff;
border: 10px solid #fff;
width: 200px;
height: 200px;
top: 50%;
left: 50%;
margin: -100px;
el.set('contentEditable', true)
.addEvents({
keydown: function(e){ if (e.key == 'enter') e.preventDefault(); },
keypress: function(e){ if (e.event.which == 0 && e.code == 13) e.preventDefault(); },
blur: function(){ var text = this.get('text'); this.set('text', text); }
});
var myiframe = document.getElementById('#frame');
import 'MyLegacyClass' with { document: myiframe.contentWindow.document };
var frameBody = myiframe.contentWindow.document.body
new MyLegacyClass().toElement().inject(framebody); // Doesn't work without proper IoC
var readSVG = function(text, doc){
var svg = doc.documentElement;
var w = +svg.getAttribute('width'), h = +svg.getAttribute('height');
w = 500;
h = 400;
var art = new ART(w, h);
art.element.setAttribute('viewBox', svg.getAttribute('viewBox'));
@sebmarkbage
sebmarkbage / ART.Events.js
Created November 21, 2010 02:35
Extends ART.Element with listen/ignore event subscriptions.
/*
---
name: ART.Events
description: "Extends ART.Element with listen/ignore event subscriptions."
requires: [ART/ART.Element, More/Table]
provides: [ART.Events]
...
*/
ART.Element.implement({