uɐʎɹ ррoʇ uɐʎɹ bio photo

uɐʎɹ ррoʇ uɐʎɹ

Hello. Is is me you're looking for?
僕は猿ーロボット。
robotic life signs.
makes noise, hears sounds, intafon.
affe auf deux roues.

Email Github Github Gist Last.fm Soundcloud Flickr

The following is a drawing class that I’ve used for the past year or so. I’m kind of using this article to test out various ways of doing syntax coloring in this blog. I use MoveableType, and I’m currently looking for some plug-in that will allow me to automatically publish code in the blog and have it look correct. Unfortunately, the only one I’ve found so far MTColorer, I wasn’t able to get working. There are a few that my friend Mason and I have looked at for WordPress that work pretty well and (like many WordPress things) are easily configurable/hackable and free. The code that I’ve included below (as well as the other code so far in this blog) is colored using the Actionscript HIghlighter featured on Arul’s Blog, which allows you to paste in your code and hit a button to get the styled text. Arul’s code does a great job, but you have to visit his site to style your code, and then also provide a download link to the text file of your code if you want to provide just a plain text version. But hey, it works. He notes on the site that there is the possibility of releasing the code once he cleans it up, so maybe there will be something one can post on their own site sometime soon.

As for the code below, it is a simple drawing class that allows you to easily draw a generic box, a hairline box, and a filled rectangle. The main reason, however, that I created the class, is for those occasions where you may need a box that is not filled and is not made up of flash lines. If you’ve used Flash enough, you know that if you draw a 3 pixel line box, the corners are often rounded looking, which doesn’t fly unless that is what you want in your design. I have worked on several projects that were to use photos that needed a “frame” of a certain width. The drawing class drawFrame method basically draws 4 filled boxes to create a rectangular “frame” of a certain thickness, made entirely of “fill” rather than lines, so the corners are nice and sharp. Of the instances where I have used this class, I have used the drawFrame method 90% of the time. Enjoy.

/**
* Drawing
* @author – Ryan Todd
*
* PlasticStare PlasticWare Codebase Project (PWCB)
* This code is part of the PlasticStare PlasticWare codebase project. This work is Copyright (c) 2005 Ryan Todd, all rights reserved.
* Prior permission of the author is required in order to redistribute the source code or algorithms in a commercial product in any
* form — original or derivative, in any programming language. The source code of the equations may be distributed as part of a
* non-commercial product, provided that redistributions contain the copyright notice:
*
* This Code is Copyright (c) 2005 Ryan Todd, all rights reserved.
* This work is subject to the terms in http://www.plasticstare.com/codebase\_terms\_of_use.html.
*
*
* AUTHOR :: Ryan Todd
* AUTHOR SITE :: http://www.plasticstare.com/
* CREATED :: 2005/10/15
*
* Drawing – this can be used to draw boxes and sometime in the future, other shapes
*
* Version :: v.1.0.5.20051015 for Actionscript 2.0
*/

class com.plasticstare.utils.Drawing{

public function Drawing() {

}

// drawHairlineBox – draws a box at in the specified movieclip with the specified rect and color. the line
// of the box is of hairline thickness
public static function drawHairlineBox(\_mc:MovieClip,\_color:String, _rectArray:Array):Void {
\_mc.lineStyle( 0, Number(\_color), 100 );
Drawing.drawBox(\_mc,\_color, _rectArray);
}

// drawBox
public static function drawBox(\_mc:MovieClip,\_color:String, _rectArray:Array):Void {
\_mc.moveTo( \_rectArray[0], _rectArray[1] );
\_mc.lineTo( \_rectArray[2],_rectArray[1] );
\_mc.lineTo( \_rectArray[2],_rectArray[3] );
\_mc.lineTo( \_rectArray[0],_rectArray[3] );
\_mc.lineTo( \_rectArray[0],_rectArray[1] );
}

// drawFilledBox
public static function drawFilledBox(\_mc:MovieClip,\_color:String,\_alpha:Number,\_rectArray:Array):Void {
_mc.lineStyle(0,0×000000,0);
\_mc.beginFill (Number(\_color),_alpha);
//
\_mc.moveTo( \_rectArray[0],_rectArray[1] );
\_mc.lineTo( \_rectArray[2],_rectArray[1] );
\_mc.lineTo( \_rectArray[2],_rectArray[3] );
\_mc.lineTo( \_rectArray[0],_rectArray[3] );
\_mc.lineTo( \_rectArray[0],_rectArray[1] );
//
_mc.endFill();
}

// drawFrame – essentially draws 4 boxes inside the specified rect of the color specified. these boxes
// align along the inside of the top, bottom, left, and right of the rect and have the thickness (from the
// rect border to the inner side of the box) specified
public static function drawFrame(\_mc:MovieClip,\_color:String, \_rectArray:Array, \_thickness):Void {
var topb:Array = [\_rectArray[0],\_rectArray[1],\_rectArray[2],\_rectArray[1]+_thickness];
var botb:Array = [\_rectArray[0],\_rectArray[3]-\_thickness,\_rectArray[2],_rectArray[3]];
var lftb:Array = [\_rectArray[0],\_rectArray[1],\_rectArray[0]+\_thickness,_rectArray[3]];
var rgtb:Array = [\_rectArray[2]-\_thickness,\_rectArray[1],\_rectArray[2],_rectArray[3]];
\_mc.lineStyle( 0, Number(\_color), 0 );
_mc.moveTo(topb[0],topb[1]);
\_mc.beginFill(Number(\_color),100);
Drawing.drawBox(\_mc,\_color, topb);
\_mc.endFill(Number(\_color),100);
_mc.moveTo(botb[0],botb[1]);
\_mc.beginFill(Number(\_color),100);
Drawing.drawBox(\_mc,\_color, botb);
\_mc.endFill(Number(\_color),100);
_mc.moveTo(lftb[0],lftb[1]);
\_mc.beginFill(Number(\_color),100);
Drawing.drawBox(\_mc,\_color, lftb);
\_mc.endFill(Number(\_color),100);
_mc.moveTo(rgtb[0],rgtb[1]);
\_mc.beginFill(Number(\_color),100);
Drawing.drawBox(\_mc,\_color, rgtb);
\_mc.endFill(Number(\_color),100);
}

}