Sick. Ear infection. Will post more later. Argh.
Author: John Winkelman
Flash Stuff Here. Move Along…
In the middle of a cool project which is right on the cusp of being designered into oblivion, I discovered a nifty way to make things “snap to” a grid. Copy-and-paste into Flash MX/MX2004.
var gridSize = 20; // size of grid
var nodeSize = 20; // size of individual nodes
var nodes = 50; // number of nodes
var radius = Stage.height/3; // radius of drawn circle
var centerX = Stage.width/2; // center horizontally
var centerY = Stage.height/2; // center vertically
var steps = (Math.PI*2) / nodes; // math stuff
var i=0;
this.onEnterFrame = function() {
if(i < nodes) {
var m = _root.createEmptyMovieClip("node"+i,i);
m.lineStyle(0,0x000000,100);
m.beginFill(0x000000,10);
m.moveTo(0,0);
m.lineTo(nodeSize,0);
m.lineTo(nodeSize,nodeSize);
m.lineTo(0,nodeSize); m.lineTo(0,0);
m.endFill();
var mx = centerX + radius*Math.cos(steps*i); // horizontal snap
if(mx%gridSize != 0) mx += (Math.floor(gridSize/2) - (mx%gridSize));
var my = centerY + radius*Math.sin(steps*i); // vetical snap
if(my%gridSize != 0) my += (Math.floor(gridSize/2) - (my%gridSize));
m._x = mx;
m._y = my;
i++;
radius += .1;
} else {
this.onEnterFrame = null;
}
}
It’s the modulus (mx % gridSize) which makes it cool. The Math.floor() which follows could also easily be Math.round() or Math.ceil(), depending on the constraints of the project.
People Who Spammed Me This Week
Banged A. Outmaneuvered
Stockades U. Khufu
Bridegrooms O. Serviles
Conjugates B. Pulleys
Posh G. Brooches
Horne P. Tatar
Bogies R. Jarred
Inhabit B. Haynes
Conclave B. Frenzied
Flexibility J. Carries
Piranhas I. Canned
Hyperbolae P. Unsnarling
Aristocrat L. Banality
Blast From the Past
Today while researching The Brain I stumbled across the first website I ever visited on a regular basis: Justin’s Links from the Underground . It was through his site that I discovered all of the weirdness the web had to offer, circa 1996. I am quite happy that his site (which by now must be one of the oldest in the world) is still up and running. W00T for Justin!
Profiting from Spam II
People who have recently sent me spam:
Cohesion Q. Stepped
Mathematician H. Melva
Pastimes E. Yea
Northeastern M. Temporizes
Armaments B. Bodyguards
Disposable O. Craftsmanship
Despairingly L. Hooky
Way I see it, putting these names in my blog will bring search engines to me, particularly those seekers of Mathematician Bodyguards and Northeastern Hooky. A win-win situation, if ever there was one!
Extruding Into Meatspace
I spend a lot of time at Mathworld looking at some of the amazing interactive geometry examples therein , and wishing I had the time to learn to do similar things. So when I come across someone who has built real-world versions , it makes me want to hang up my programming spurs and find work in the food service industry.
Nah, not really. But BOY would it be cool to have one of those.
(link found at Transphormetic )
I :heart: My Camera
Not Dead…Only Working
Where have I been? Making one of these in Flash.
New Toy
The above photo was taken with my new camera , from a distance of 7 feet.





