Skip to content

Instantly share code, notes, and snippets.

View claus's full-sized avatar
🎅

Claus Wahlers claus

🎅
View GitHub Profile
// ok i want a root <a> node that has two children: a <b> node and a random text node
// the random text node should be automatically escaped if appropriate:
// <a>
// <b/>
// a &lt; b
// </a>
var txt:String = "a < b";
var xml:XML = <a/>;
xml.appendChild(<b/>);
// Visualization/simulation of resolution independent rendering of curves in OpenGL
// See http://www.mdk.org.pl/2007/10/27/curvy-blues
for(var px:Number = 0; px <= 400; px += 4) {
for(var py:Number = 0; py <= 400; py += 4) {
drawPixel(px, py);
}
}
// triangle edges
// Draws the first glyph of the first embedded font in a SWF
// Visualizes on and off curve points
import com.codeazur.as3swf.SWF;
import com.codeazur.as3swf.tags.TagDefineFont3;
import com.codeazur.as3swf.exporters.AS3GraphicsDataShapeExporter;
import flash.display.IGraphicsData;
import flash.display.GraphicsPath;
import flash.display.GraphicsPathCommand;
import flash.geom.Point;
// Move point on quad Bezier
// (De Casteljau's Algorithm)
import flash.geom.Point;
import flash.display.Shape;
import flash.events.Event;
var tangent:Shape = new Shape();
addChild(tangent);
/*
Implements different bin packer algorithms that use the MAXRECTS data structure.
See http://clb.demon.fi/projects/even-more-rectangle-bin-packing
Author: Jukka Jylänki
- Original
Author: Claus Wahlers
- Ported to ActionScript3
<?xml version="1.0" encoding="utf-8"?>
<!--
Show the compile date of a SWF.
See http://wahlers.com.br/claus/blog/undocumented-swf-tags-written-by-mxmlc/
-->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="600" minHeight="400"
// Records a local webcam feed and converts the recording to SWF.
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.media.Camera;
import flash.media.Video;
@claus
claus / DumpText.as
Created April 14, 2011 23:51
Dump all static text contained in a SWF (using as3swf)
package
{
import flash.display.MovieClip;
import com.codeazur.as3swf.SWF;
import com.codeazur.as3swf.tags.ITag;
import com.codeazur.as3swf.tags.TagDefineText;
import com.codeazur.as3swf.data.SWFTextRecord;
import com.codeazur.as3swf.data.SWFGlyphEntry;
import com.codeazur.as3swf.tags.TagDefineFont2;
package
{
import flash.utils.ByteArray;
import flash.display.Loader;
import flash.display.Stage;
import flash.display.MovieClip;
import com.codeazur.as3swf.SWF;
import com.codeazur.as3swf.tags.ITag;
import com.codeazur.as3swf.tags.TagDefineEditText;
@claus
claus / gist:940180
Created April 25, 2011 05:07
as3potrace usage example
var gd:Vector.<IGraphicsData> = new Vector.<IGraphicsData>();
gd.push(new GraphicsStroke(1, false, LineScaleMode.NONE, CapsStyle.ROUND, JointStyle.ROUND, 3, new GraphicsSolidFill(0x00ff00, 1)));
var potrace:POTrace = new POTrace();
potrace.backend = new GraphicsDataBackend(gd);
potrace.potrace_trace(bitmap.bitmapData);
graphics.drawGraphicsData(gd);