Perlin Meets Langton
Hi everyone
I just completed an experiment which turned out to be much cooler than I expected, so I am sharing it! Basically, a thousand "ants" are wandering around a perlin noise landscape. If they move from lighter to darker pixels they turn counter-clockwise. If they move from darker to lighter pixels, they turn clockwise.
You can see them here. Source will be posted later today.
KirupaForum > Talk > Source/Experiments
Posted on: 10-29-2008, 10:52 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Preloading More Than Meets The Eye? :D
sorry for the somewhat stupid topic
aaaanyway, I used this tutorial to create a preloader with loading bar http://www.kirupa.com/developer/mx/p...epreloader.htm, which is great. It works fine, looks fine etc. Problem: my main swf file is really very small, and the navigation system and other contents are separate swfs and load into it individually. How do I get my preloader to preload more than just my main swf (ie. all the other smaller ones)?
Hope that makes sense. Just ask if you need me to clarify!
Thanks for any help!
Flash Meets PHP - Evil Or Friendly?
Ahoy.
I have worked with PHP scripts maybe once before in my lifetime, so I am completely unsure of it's capabilities, it's compatability, or anything else. I was a Flash guru back in the day, but I haven't touched it in several months.
My question is, can I use PHP to make my life easier with flash? I want to have external text documents, say, like a update posting or something for my website, so I can just add the little bit I want to the text file, and have flash import that from my server and put it on my page without me having to change my FLA everytime I want to make a change.
And if I can do this in flash, does anyone know how I could do this with HTML/DHTML?
Basically, I'm going to teach myself yet another programming language *groan* in about a weeks time (PHP). *I did it with PERL, why not PHP?* Just sort of hoping that somebody out there has any idea on this stuff. Thanks a bunch.
Bluetooth Meets Macromedia Flash
hi, i am an flashkit user from europe. i checked the new bluetooth features, here is my first tutorial.its magic
Control your Flash movies with any Bluetooth device, you can send datas from pda, mobile phone or desktop pc.
You can beam pictures, sounds, texts and many more from any wireless bt device to your running flash application. Beam the datas to your website..and and and. Your flash application can run on the desktop pc or a mobile device, like a pocket pc. its incredible, what flash can do, welcome to a new step of flash. you need no special software, i checked it on this devices and it works great.
Sony Ericsson T68i BT Mobile Phone
Sony Ericsson T610 BT Mobile Phone
Siemens mobile S55 BT Mobile Phone
Series 60 Phones, like Nokia 3650,7650, NGage, Siemens SX1 and more
Pocket PC iPAQ 3970 BT
Desktop PC BT Dongle
FLASHmobile.de - Macromedia Flash on mobile devices
EUROPE (Germany)
Tutorial BT Flash OBEX
Dynamic Text Meets Html
I am loading an external txt file into a dynamic text box and i would like to make it so certain things are bold/caps/linkable/italic. whats the easiest way to get this done. I have tried to write it in html and the make the dynamic text box render as html and it just gives me a blank screen
Array Meets Dynamic Text Field
So an array walks into a dynamic text field and says.. oh wait..
I have an array that I am trying to output into a dynamic text field via this function:
ActionScript Code:
Barcelona = ["Barcelona:", "Apple", "25 - ", "2"];Output_Array = function(array_name){ for(i=0; i<array_name.length; i++) { output_txt.text += array_name[i] output_txt.text += " " }}
It outputs the array just fine, but what I want to do is add in a line break here and there to make it more beautiful. In the dynamic text field properties there is an option for "Render text as HTML". With the option checked I tried adding in <br> and/or <p> HTML tags but all it does is prints out the "<br>" instead of making a new line. (I also have the text field set to Multiline.)
Is there anyway to get it to have a line break?
Perlin Noise
I am trying to use perlinNoise to create an animated water effect, the code I have written seems to work once (it distorts image) but then does nothing. I also receive the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/enterFrame()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/enterFrame()
The code is as follows;
Code:
import flash.display.BitmapData;
import flash.display.Loader;
import flash.events.MouseEvent;
import flash.filters.DisplacementMapFilter;
import flash.geom.Point;
import flash.net.URLRequest;
// Load an image onto the Stage.
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("http://www.helpexamples.com/flash/images/image3.jpg");
loader.load(url);
this.addChild(loader);
var mapImage:BitmapData;
var displacementMap:DisplacementMapFilter;
// This function is called when the image finishes loading.
function setupStage(event:Event):void
{
// Center the loaded image on the Stage.
loader.x = (stage.stageWidth - loader.width) / 2;
loader.y = (stage.stageHeight - loader.height) / 2;
// Create the displacement map image.
mapImage = new BitmapData(loader.width, loader.height, false, 0);
// Create the displacement filter.
displacementMap = new DisplacementMapFilter();
displacementMap.mapBitmap = mapImage;
displacementMap.mapPoint = new Point(0, 0);
displacementMap.componentX = BitmapDataChannel.RED;
displacementMap.scaleX = 250;
loader.filters = [displacementMap];
}
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, setupStage);
addEventListener(Event.ENTER_FRAME, enterFrame);
var i:Number = 1;
function enterFrame(e:Event)
{
var templist:Array = new Array();
templist = loader.filters;
var offset:Array = new Array();
offset[1] = new Object();
offset[1].x = i;
offset[1].y = i/2;
mapImage.perlinNoise(100,60,2,523,false,false,7,true,offset);
templist.mapBitmap = mapImage;
i++;
loader.filters = templist;
}
Cheers
Is Stainless Possible In Perlin?
Does anybody here know the formula to make a stainless steel texture in the perlin distortion method of the BitmapData API? I can make wood grain all day long but theres gotta be a formula to make stainless work, i've been toying with it for hours
? Possible To Mask Perlin Noise ?
Hi,
I am wondering what the process is to mask perlin noise, so that only a small area of the stage is displaying the noise.
The noise should only interact with the top half of the frame, with a transparency gradient slowly masking the noise until there's none at the bottom of the frame.
Any idea how to go about this?
Thanks!
Perlin Displacement Wave
Hey everyone,
So I was recently working on a project for work where I had some time to mess around with displacement effects. After reading a post by Ordinathorreur (http://www.kirupa.com/forum/showthread.php?t=204877) I was inspired to try and make a wave effect to fade in and out text (but can be used on any MovieClip). So here's my first version of the PerlinDisplace class which so far only has the pubilc method "wave" shown here. I'm kinda new to writing classes so let me know if you see any room for improvement!
SWF
FLA
Oh and for the next version I'm going to add more control for the fade timing and a few other things when constructing the class. I'll post again here when its ready-
I Have A Question About Perlin Noise
I see references to it being processor intensive. What happens to potential viewers who have older computers? Does it crash or just slow down?
What does it do to the rest of a page that it resides on?
[AS2 F8] Multiple Perlin Noise Hack?
I'm on a project right now that requires F8 or lower - and I need to have 2 instances of Perlin Noise in the same swf. Anyone who is at all familiar with PN will note that one instance alone is hard enough on your processor - any more than that is murder. I've dialed down my existing code to barebones - only one octave, framerate is low, etc... and I still can't seem to get two in there without pushing my twin dual-core 3MHZ setup to use 60-70% of it's available brain.
My animation is simple - fill up an area with water. The pour stream needs to run perlin vertically, and the 'fill' graphic that rises up over time needs it horizontally. I even tried setting it up so that both graphics use one instance of PN, even if it looked bad, but as soon as I put any kind of animation inside of the MC that I am applying PN to, it just doesn't do anything.
Anyone have any tips/examples of successful multiple perlin noise applications?
Thanks in advance.
Perlin Noise With Loaded Bitmap
does anyone have an example they've seen/done that could demonstrate how to use perlin noise with a loaded bitmap (png)? I seem to be able to make tons of nonsense with a rectangle but would love to apply it to a bitmap image with edges that weren't hard and and shape that was more organic. thanks
Lets Make Some (perlin) Noise
This thread sort of continues from this one but concentrates on some of the funky stuff we can do with the new Flash 8 perlin noise function, like create clouds, wood, water and other cool new things.
Edit: Please experiment and add your creation! You can find a playground .fla a couple of posts down...
Here's a perlin noise generated displacement map warping an image:
ActionScript Code:
import flash.display.BitmapData;import flash.geom.Point;import flash.filters.DisplacementMapFilter;import flash.filters.DropShadowFilter;Stage.scaleMode="noScale";// Perlin noise variables, I encourage you to play around with these...var baseX :Number = 200;var baseY :Number = 200; var nOctaves :Number = 1; var randomSeed :Number = Math.random()*10;var bStitch :Boolean = false;var bFractalNoise :Boolean = true;var nChannels :Number = 1;var bGreyScale :Boolean= false;// Offset array for perlin functionvar p1 = new Point(45, 34);var p2 = new Point(50, 60);perlinOffset = new Array(p1, p2);// Create the bitmapdata we are going to change with the perinNoise function bmp = new flash.display.BitmapData(400,300,true,0x00000000);onEnterFrame = function (){ // change the values in the perlinOffset to animate each perlin layer perlinOffset[0].y-=2; perlinOffset[0].x-=2; perlinOffset[1].x+=1; perlinOffset[1].y+=1; // apply perlin noise to our bitmapdata bmp.perlinNoise(baseX, baseY, nOctaves, randomSeed, bStitch, bFractalNoise, nChannels, bGreyScale, perlinOffset); // // Uncomment the following line to see the generated perlin noise //_root.attachBitmap(bmp, 1, "auto", true); // // Now use the bitmapdata in bmp as a base for the distortion dmf = new DisplacementMapFilter(bmp, new Point(0, 0), 1, 1, 20, 20, "color"); // and apply it to our pic (instance name sourcePic) sourcePic.filters = [dmf];}
Pre Rendering A Perlin Noise Animation
Is there a way to pre-render a BitmapData.perlinNoise moving animation into a seamless loop of 10-12 frames from which copypixels could be used on the resultant sprite strip to produce fast resuilts?
Generating Clouds With Perlin Noise
Hi guys,
I am trying to generate some clouds with the perlin noise function.
Currently, i have the follow:
ActionScript Code:
var channel:uint = 1 | 2 | 4 | 8;var xpos:Number = Math.floor(Math.random()*100);var ypos:Number = Math.floor(Math.random()*100);var seed:Number = Math.floor(Math.random()*100);var p:Point = new Point(xpos, ypos);var offsetArray:Array = [p, p, p, p, p];var bitmap:BitmapData = new BitmapData(300, 300, true, 0xFFFFFFFF);bitmap.perlinNoise(300, 300, 10, seed, false, true, channel, false, offsetArray);
With this, I get a cloud like bitmap, but i have all the colors in it (red blue and green). What i'd like to do is have a blue background and white clouds.
How would i go about doing that?
Thanks
Perlin Noise Fire Effects
Hey there...
Would someone please explain to me the basics of how to use perlin noise and displacment filters to create those fancy fire effects. I can't find any good source codes / tutorials on the net and my brain is aching... i cant seem to work it out!
Here is my favourite example of the fire - http://www.kaourantin.net/2005/08/li...ect-using.html
Any light shed would be greatly appreciated!
Trouble With Accurately Coloring Perlin Noise
Hi there, I'm having trouble with fine tuning the color of a perlin noise layer. The bitmap data parameters don't give you many color options so I thought I'd try using a colour matrix filter, but it's notoriously fiddly, and I wasted hours trying to get the colour I wanted to no avail. There has to be an easier way. Since I'm a newby I thought I'd put it out there and hope someone can help me. You'll see from the following code that I've tried to juggle the numbers in the color matrix filter, but I just can't seem to crack it. Too many options, perhaps. Anyway, if there's another method I'd appreciate it if anyone could help me. If you could be really specific about the syntax and assume I know very little, I'd appreciate it.
Thanks in advance.
Peter
Code:
import flash.display.BitmapData;
import flash.geom.Point;
import flash.filters.BitmapFilter;
import flash.filters.ColorMatrixFilter;
var myBitmapData:BitmapData = new BitmapData(Stage.width, Stage.height, false, 0xFFFFFF);
var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var randomNum:Number = Math.floor(Math.random()*10);
mc.attachBitmap(myBitmapData, this.getNextHighestDepth());
var point1:Point = new Point(0,0);
var point2:Point = new Point(50,10);
var perlinOffset:Array = [point1, point2];
mc.onEnterFrame = function () {
perlinOffset[0].x -= 20;
perlinOffset[1].y += 20;
myBitmapData.perlinNoise (600, 600, 1, randomNum, true, true, 4, false, perlinOffset);
}
mc.cacheAsBitmap = true;
var matrix:Array = new Array();
matrix = matrix.concat([0, 0 , 1, 0, 0]); // red
matrix = matrix.concat([1, 0, 0, 1, 0]); // green
matrix = matrix.concat([7, 6, 0, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, .75, 0]); // alpha
var filter:BitmapFilter = new ColorMatrixFilter(matrix);
mc.filters = new Array(filter);
Senoculars 'Perlin Flag Wave' To AS2 Class
I've been trying to encapsulate Senoculars brilliant PerlinNoise Flag Wave example into a self contained AS2 class.
The original Fla example is here:
http://www.senocular.com/flash/source.php?id=0.188
I've tried to remove the need for having displacement Maps and bounding boxes in the target movieClip, by dynamically drawing them within the class itself.
I have so far succeeded and the effect works almost perfectly. However, the original example uses the alpha values of the displacement map to determine where, and how much displacement should take place. In my version though, I can't seem to tie the alpha values to the displacement. The noise happens uniformly across the displacement map, no matter how much alpha there is. (Should be none from the left edge where there is 100% alpha).
My Class is contained below, and still needs a lot of refactoring and openness to dynamic values, but if anyone can help me figure out why the displacement seems uniform, I'd very much appreciate it.
ActionScript Code:
/** * @author d.robert hall */ import com.bourre.commands.Delegate;import com.bourre.log.PixlibStringifier;import com.bourre.transitions.FPSBeacon;import com.bourre.transitions.IFrameListener;import flash.display.BitmapData;import flash.filters.DisplacementMapFilter;import flash.geom.Matrix;import flash.geom.Point; class com.skivecreative.effects.FlagRipple implements IFrameListener{ private var speed:Number; private var channel:Number; private var baseX:Number; private var baseY:Number; private var octs:Number; private var seed:Number; private var stitch:Boolean; private var fractal:Boolean; private var gray:Boolean; private var flapX:Number; private var flapY:Number; private var mode:String; private var offset:Point; private var displaceBitmap:BitmapData; private var displaceFilter:DisplacementMapFilter; private var ramp:MovieClip; private var noiseBitmap:BitmapData; private var shift:Matrix; private var onEnterFrameHandler:Function; private var target:MovieClip; private var displace:MovieClip; private var perlin:MovieClip; private var ripple:MovieClip; private var maxWidth:Number; private var maxHeight:Number; private var clampBox:MovieClip; /* CONSTRUCTOR ********************************************************************************/ public function FlagRipple( target:MovieClip, maxWidth:Number, maxHeight:Number ) { this.target = target; this.maxWidth = maxWidth; this.maxHeight = maxHeight; speed = 3; // speed at which noise is shifted (causes flap) channel = 1; // red - red used to displace pixels along baseX = 80; // size of noise in x axis baseY = 0; // size of noise in y axis octs = 1; // noise functions for noise (smaller = faster) seed = 20; // random seed for noise stitch = true; // stitching makes the noise wrap making it easy to repeat fractal = true; // use fractal noise gray = false; // grayscale is not used because the red channel is flapX = 0; // power of pixel displacement along x axis flapY = 20; // power of pixel displacement along y axis mode = "clamp"; // clamp the image so none of the original is seen offset = new Point( 0, 0 ); // displacment map offset init(); } /* PUBLIC METHODS *****************************************************************************/ public function init() { ripple = target.ripple_mc; drawDisplacementMap(); setClampBox(); displaceFilter = new DisplacementMapFilter( displaceBitmap, offset, channel, channel, flapX, flapY, mode ); shift = new Matrix(); noiseBitmap = new BitmapData( 500, 1 ); noiseBitmap.perlinNoise( baseX, baseY, octs, seed, stitch, fractal, channel, gray ); FPSBeacon.getInstance().addFrameListener( this ); onEnterFrameHandler = Delegate.create( this, update ); } public function onEnterFrame () : Void { onEnterFrameHandler(); } public function flush () : Void { ripple.removeMovieClip(); ripple = target.ripple_mc; ripple.swapDepths( target.getNextHighestDepth() ); setClampBox(); } /* PRIVATE METHODS ****************************************************************************/ private function setClampBox () : Void { clampBox = ripple.createEmptyMovieClip( "clampBox", ripple.getNextHighestDepth() ); clampBox._x = -( maxWidth / 2 ); clampBox._y = -( maxHeight / 2 ); clampBox.moveTo( 0, 0 ); clampBox.lineStyle( 1, 0xFF0000, 0 ); clampBox.lineTo( 0, maxHeight ); clampBox.lineTo( maxWidth, maxHeight ); } private function drawDisplacementMap () : Void { displace = target.createEmptyMovieClip( "displace_mc", target.getNextHighestDepth() ); ramp = displace.createEmptyMovieClip( "ramp", displace.getNextHighestDepth() ); displace._x = -60; displace._y = -25; var dFillType:String = "linear"; var dColors:Array = [0x800000, 0x800000]; var dAlphas:Array = [100, 0]; var dRatios:Array = [255, 0]; var dMatrix:Object = {matrixType:"box", x:0, y:0, w:180, h:50, r:0/180*Math.PI}; ramp.lineStyle(1, 0x000000, 0); ramp.beginGradientFill( dFillType, dColors, dAlphas, dRatios, dMatrix ); ramp.moveTo( 0, 0 ); ramp.lineTo( 180, 0 ); ramp.lineTo( 180, 50 ); ramp.lineTo( 0, 50 ); ramp.lineTo( 0, 0 ); ramp.endFill(); perlin = displace.createEmptyMovieClip( "perlin", 1 ); displaceBitmap = new BitmapData( ramp._width, ramp._height ); displace._visible = false; } private function update () : Void { shift.translate( speed, 0 ); perlin.clear(); perlin.beginBitmapFill( noiseBitmap, shift ); perlin.moveTo( 0, 0 ); perlin.lineTo( ramp._width, 0 ); perlin.lineTo( ramp._width, ramp._height ); perlin.lineTo( 0, ramp._height ); perlin.lineTo( 0, 0 ); perlin.endFill(); displaceBitmap.draw( displace ); ripple.filters = [displaceFilter]; } /* DEFAULT ************************************************************************************/ public function toString() : String { return PixlibStringifier.stringify( this ); } public function destroy() : Void { FPSBeacon.getInstance().removeFrameListener( this ); }}
Perlin Noise Distort By Sekasi - Question
http://www.erikhallander.com/blog/2008/ ... ntmap.html if you haven't been to his blog check it out. AMAZING stuff is happening over there. Anyways I was wondering if anyone would know how to use this class as a fade in rather then a fade out. Thanks for your time.
Tiny Challenge Meets "how To" :)
Hi!
I need to do something that would involve some minor AI and i was wondering what would be the best way for me to do it.
Let me explain:
In a regular stage, i would have a certain number of mcs, specificied by a variable.
These mcs would be cars and would be wandering around the stage in a random movement and when they collided with each other, they would change direction and, when near the bounds of the stage, 1 of 2 things would happen: either they hit the "wall", reverse and turn to change the direction, or they would turn before hitting the wall.
On top of this, there would be a target, like a circle, where all of them should go eventually. Lets think of it like a parking space ... they would wander around and at some point, go to the circle and stop.
It seems easy, but since they're cars, the movement can't be that random, because they can't turn 90º.
I was messing around with flash and made a car move randomly and rotate so that it faces the direction it's going, but it isn't that great, because of the turning
Check the attachment to see the example.
What do you think is the best way to do this?
Fade Up Meets Fade Down
I'm trying to get multiple mc's to fade up and fade down. I don't know what I have to do to get more than one to work at a time. right now, my stage code looks like this...
fscommand ("fullscreen", "false");
fscommand ("allowscale", "false");
stop()
//don't use the hand icon
contact.useHandCursor=false;
//handle the onEnterFrame event
contactfadein_mc.onEnterFrame=function()
{
if (fade){
this.nextFrame();
}else{
this.prevFrame();
}
};
my contactfadein_mc.onEnterFrame=function() line is one of 6 mc's I want in there. where should I add my other codes? thanks - Chris
|