NEU: Alle Visual Codes als Code Snippets für Flash CS5:
jetzt hier downloaden .

Sinusraster

Code Actionscript 2.0

Frame-Aktion

i = 1;
for (gy = 0; gy <= 8; gy = gy + 1) {
for (gx = 0; gx <= 8; gx = gx + 1) {
i = i + 1;
square0.duplicateMovieClip("square" + i, i);
_root["square" + i]._x = gx * 50;
_root["square" + i]._y = gy * 50;
_root["square" + i]._xscale = stretch(sine(gx * 22), 60, 30);
_root["square" + i]._yscale = stretch(sine(gx * 22), 60, 30);
}
}
square0._visible = 0;
function sine(x) {
// sine between 0 und 360°
s = Math.sin(x * 2 * Math.PI / 360);
return s;
}
function stretch(value, center, amplitude) {
// scales and shifts value
st = int(value * amplitude + center);
return st;
}

Code Actionscript 3.0

var Squares:Array = new Array(); var i = 1; for (var gx = 0; gx <= 8; gx = gx + 1) { for (var gy = 0; gy <= 8; gy = gy + 1) { i = i+1; //important: square has to be exported for actionscript //go to "linkage" in library menu Squares[i] = new squareObject(); Squares[i].x = gx * 50; Squares[i].y = gy * 50; Squares[i].scaleX = stretch(sine(gx * 22), 60, 30)/100; Squares[i].scaleY = stretch(sine(gx * 22), 60, 30)/100; addChild(Squares[i]); } } square0.visible = 0; function sine(x) { // sine between 0 und 360° var s = Math.sin(x * 2 * Math.PI / 360); return s; } function stretch(value, center, amplitude) { // scales and shifts value var st = int(value * amplitude + center); return st; }

Infos

Ein Grundelement wird auf einem 8x8 Raster angeordnet. Die jeweilige Grösse der Quadrate wird durch eine wellenförmige Sinusfunktion bestimmt. Die Funktionen sinus und stretch dienen der besseren Lesbarkeit. Die Funktion sine rechnet Winkel von Grad ins Bogenmass um. Die Funktion stretch skaliert und verschiebt die Sinuswerte, die zwischen -1 und 1 liegen.

verwandt mit: Sinus-Funktion

Download

Right click: Flashfile AS 2.0 | Flashfile AS 3.0 | SWF-File


Share