/** * 25-Line ActionScript Contest Entry * * Project: The Holictic Cube Of Life, The Universe, Self, And Everything * Author: Daniil Tutubalin, Tomsk, Russia * Email: tutubalin@gmail.com * Date: 11/25/2008 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ // 3 free lines! Alter the parameters of the following lines or remove them. // Do not substitute other code for the three lines in this section [SWF(width=600, height=600, backgroundColor=0x404080, frameRate=30)] stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; var data = [{x:-100,y:-100,z:-100},{x:-100,y:100,z:-100,rotationX:90},{x:-100, y:-100, z:100, rotationY:90},{x:100, y:-100, z:100, rotationY:180},{x:-100, y:-100, z:100, rotationX:-90},{x:100, y:-100, z:-100, rotationY:-90}]; addChild(new Sprite()).x = getChildAt(0).y = 300; var cube = getChildAt(0)["addChild"](new Sprite()); for (var i=0; i<6; i++) { cube.addChild(new Sprite()).addChild((new Bitmap(i==1?new BitmapData(100,100,false,0):new BitmapData(200,200,false,0)))); for (var s in data[i]) cube.getChildAt(i)[s] = data[i][s]; } cube.getChildAt(4)["addChild"](new Video(200,200)).attachCamera(Camera.getCamera()); cube.getChildAt(1).getChildAt(0).scaleX = cube.getChildAt(1).getChildAt(0).scaleY = 2; stage.addEventListener(Event.ENTER_FRAME, function(e) { cube.getChildAt(3).getChildAt(0).bitmapData.copyPixels(cube.getChildAt(0).getChildAt(0).bitmapData, cube.getChildAt(3).getChildAt(0).bitmapData.rect, new Point()); cube.rotationY = 300-mouseY-mouseX-i+(cube.rotationX=mouseY-300); getChildAt(0).rotationY = getChildAt(0).x = getChildAt(0).y = 0; for (var j=0; j<6; j++) cube.getChildAt(j).visible = (cube.getChildAt(j).local3DToGlobal(new Vector3D()).x-cube.getChildAt(j).local3DToGlobal(new Vector3D(100)).x)*(cube.getChildAt(j).local3DToGlobal(new Vector3D()).y-cube.getChildAt(j).local3DToGlobal(new Vector3D(0,100)).y)>(cube.getChildAt(j).local3DToGlobal(new Vector3D()).y-cube.getChildAt(j).local3DToGlobal(new Vector3D(100)).y)*(cube.getChildAt(j).local3DToGlobal(new Vector3D()).x-cube.getChildAt(j).local3DToGlobal(new Vector3D(0,100)).x); getChildAt(0).rotationY = i+(getChildAt(0).x = getChildAt(0).y = 300); cube.getChildAt(0).getChildAt(0).bitmapData.perlinNoise(200,200,2,0,false,false,7,false); cube.getChildAt(0).getChildAt(0).bitmapData.draw(getChildAt(0), new Matrix(0.3,0,0,0.3,100,100)); for (j=0; j<6; j++) cube.getChildAt(j).visible = (cube.getChildAt(j).local3DToGlobal(new Vector3D()).x-cube.getChildAt(j).local3DToGlobal(new Vector3D(100)).x)*(cube.getChildAt(j).local3DToGlobal(new Vector3D()).y-cube.getChildAt(j).local3DToGlobal(new Vector3D(0,100)).y)>(cube.getChildAt(j).local3DToGlobal(new Vector3D()).y-cube.getChildAt(j).local3DToGlobal(new Vector3D(100)).y)*(cube.getChildAt(j).local3DToGlobal(new Vector3D()).x-cube.getChildAt(j).local3DToGlobal(new Vector3D(0,100)).x); if (i%1000 == 6) cube.getChildAt(1).getChildAt(0).bitmapData.noise(int(Math.random()*int.MAX_VALUE),0,8,7,true); else cube.getChildAt(1).getChildAt(0).bitmapData.applyFilter(cube.getChildAt(1)["getChildAt"](0).bitmapData, new Rectangle(0,0,100,100), new Point(), new ConvolutionFilter(3, 3, [3,3,3,3,2,3,3,3,3],255,0,true,false,0,1)); cube.getChildAt(1).getChildAt(0).bitmapData.threshold(cube.getChildAt(1)["getChildAt"](0).bitmapData, new Rectangle(0,0,100,100), new Point(), "==",8, 0xFFFFFFFF, 0xFC); cube.getChildAt(1).getChildAt(0).bitmapData.threshold(cube.getChildAt(1)["getChildAt"](0).bitmapData, new Rectangle(0,0,100,100), new Point(), "!=",0xFFFFFFFF, 0); cube.getChildAt(2).getChildAt(0).bitmapData.perlinNoise(100,100,3,0,false,false,7,false,[new Point(i++,0),new Point(i*2,0),new Point(i*3,0)]); cube.getChildAt(5).getChildAt(0).bitmapData.fillRect(new Rectangle(Math.sin(i/70)*100+100,Math.cos(i/50)*100+100,3,3),(int(Math.sin(i/87)*128)<<16)+(int(Math.sin(i/100+Math.PI*2/3)*128)<<8)+(int(Math.sin(i/130+Math.PI*4/3)*128))+0x808080); cube.getChildAt(5).getChildAt(0).bitmapData.draw(cube.getChildAt(5).getChildAt(0).bitmapData,new Matrix(0.9751040819724653,0.0978367483138916,-0.0978367483138916,0.9751040819724653,12.27326663414263,-7.294083028635697),null,"lighten",null,true); cube.getChildAt(5).getChildAt(0).bitmapData.applyFilter(cube.getChildAt(5).getChildAt(0).bitmapData,new Rectangle(0,0,200,200),new Point(),new BlurFilter(2,2)); });