/** * 25-Line ActionScript Contest Entry * * '' * `||''|, .|''|, || ('''' .|''|, * || || || || || `'') ||..|| * .|| ||. `|..|' .||. `...' `|... * * * '||` * || * .|'', .|''|, || '|| ||` '||),,(|, `||''|, * || || || || || || || || || || || * `|..' `|..|' .||. `|..'|. .|| ||. .|| ||. * * * Project: Noise Column * Author: Mike Creighton (http://mikecreighton.com) * Date: 2008-11-16 * * 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=800, height=800, backgroundColor=0x202020, frameRate=30)] stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // 25 lines begins here! // // ----------------------------------------------------------------------------- // Usage Instructions: // Works best with microphone. Just put your lips together and blow. // Will also work without microphone. // ----------------------------------------------------------------------------- import fl.motion.Color; var mic : Microphone = Microphone.getMicrophone(); var inc : Number = Math.PI / 2; Security.showSettings("2"); mic.setLoopBack(true); var levels : Number = 0; var bmpData : BitmapData = new BitmapData(800, 1200, true, 0x00000000); var noiseData : BitmapData = new BitmapData(200, 200, true, 0x00000000); var noiseOffset : Point = new Point(Math.round(Math.random() * 100), Math.round(Math.random() * 100)); var triCommands : Vector. = new Vector.(); this.triCommands.push(GraphicsPathCommand.MOVE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO, GraphicsPathCommand.LINE_TO ); var triPoints : Vector. = new Vector.(); this.addChild(new Bitmap(bmpData)); function update() : void { inc+=0.01; levels = Math.abs( (this.mic == null || this.mic.activityLevel == -1 ? Math.abs(Math.cos(inc)) : this.mic.activityLevel / 100) < levels ? levels - 0.01 : (this.mic == null || this.mic.activityLevel == -1 ? Math.abs(Math.cos(inc)) : this.mic.activityLevel / 100)); this.noiseOffset.x++; this.noiseData.perlinNoise(50, 50, 1, 50, true, false, 7, true, [this.noiseOffset]); var sketch : Sprite = new Sprite(); this.bmpData.scroll(0, -(1 + levels * 2)); sketch.graphics.lineStyle(2 + levels, Color.interpolateColor(0x707070, 0xB41446, levels), 0.2); this.triPoints.splice( 0, 34, 330 - this.noiseData.getPixel(199, 100)/0xFFFFFF * 620 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 0)/0xFFFFFF * 100 * (0.2 + levels * 0.8), 350 - this.noiseData.getPixel(199, 102)/0xFFFFFF * 500 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 5)/0xFFFFFF * 130 * (0.2 + levels * 0.8), 370 - this.noiseData.getPixel(199, 104)/0xFFFFFF * 290 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 10)/0xFFFFFF * 175 * (0.2 + levels * 0.8), 390 - this.noiseData.getPixel(199, 106)/0xFFFFFF * 80 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 15)/0xFFFFFF * 200 * (0.2 + levels * 0.8), 410 + this.noiseData.getPixel(199, 108)/0xFFFFFF * 80 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 20)/0xFFFFFF * 200 * (0.2 + levels * 0.8), 430 + this.noiseData.getPixel(199, 110)/0xFFFFFF * 290 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 25)/0xFFFFFF * 175 * (0.2 + levels * 0.8), 450 + this.noiseData.getPixel(199, 112)/0xFFFFFF * 500 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 30)/0xFFFFFF * 130 * (0.2 + levels * 0.8), 470 + this.noiseData.getPixel(199, 114)/0xFFFFFF * 620 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 35)/0xFFFFFF * 100 * (0.2 + levels * 0.8), 505 + this.noiseData.getPixel( 0, 100)/0xFFFFFF * 550 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 150)/0xFFFFFF * 100 * (0.2 + levels * 0.8), 475 + this.noiseData.getPixel( 0, 102)/0xFFFFFF * 510 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 155)/0xFFFFFF * 130 * (0.2 + levels * 0.8), 445 + this.noiseData.getPixel( 0, 104)/0xFFFFFF * 260 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 160)/0xFFFFFF * 175 * (0.2 + levels * 0.8), 415 + this.noiseData.getPixel( 0, 106)/0xFFFFFF * 70 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 165)/0xFFFFFF * 200 * (0.2 + levels * 0.8), 385 - this.noiseData.getPixel( 0, 108)/0xFFFFFF * 70 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 170)/0xFFFFFF * 200 * (0.2 + levels * 0.8), 355 - this.noiseData.getPixel( 0, 110)/0xFFFFFF * 260 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 175)/0xFFFFFF * 175 * (0.2 + levels * 0.8), 325 - this.noiseData.getPixel( 0, 112)/0xFFFFFF * 510 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 180)/0xFFFFFF * 130 * (0.2 + levels * 0.8), 295 - this.noiseData.getPixel( 0, 114)/0xFFFFFF * 550 * (0.2 + levels * 0.8), 765 + this.noiseData.getPixel( 0, 185)/0xFFFFFF * 100 * (0.2 + levels * 0.8), 330 - this.noiseData.getPixel(199, 100)/0xFFFFFF * 620 * (0.2 + levels * 0.8), 750 - this.noiseData.getPixel(199, 0)/0xFFFFFF * 100 * (0.2 + levels * 0.8) ); sketch.graphics.drawPath(this.triCommands, this.triPoints); this.bmpData.draw(sketch); } setInterval(this.update, 33); // ----------------------------------------------------------------------------- // // 25 lines ends here!