flash on 2013-1-11
...
@author lizhi http://game-develop.net/
♥0 |
Line 28 |
Modified 2013-01-11 16:40:31 |
MIT License
archived:2017-03-20 15:33:43
ActionScript3 source code
/**
* Copyright lizhi ( http://wonderfl.net/user/lizhi )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bqsg
*/
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Shape;
import flash.display.Sprite;
/**
* ...
* @author lizhi http://game-develop.net/
*/
public class TestC extends Sprite
{
public function TestC()
{
//http://research.microsoft.com/en-us/um/people/cloop/loopblinn05.pdf
var bmd:BitmapData = new BitmapData(400, 400, false, 0);
for (var x:int = 0; x < bmd.width; x++ ) {
for (var y:int = 0; y < bmd.height; y++ ) {
var u:Number = x / (bmd.width / 2 + bmd.width / 2 * y / bmd.height) / (2 - y / bmd.height);
var v:Number = y / bmd.height;
var d:Number = u * u - v;
bmd.setPixel(x, y, 0xff * d);
if (d < (.7/bmd.width) && d > -(.7/bmd.height)) {
bmd.setPixel(x, y, 0xffff);
}else {
bmd.setPixel(x, y, 0);
}
}
}
addChild(new Bitmap(bmd));
}
}
}