Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

Re: Video to ASCII effect

Cow Forums : Adobe After Effects Expressions
VIEW POSTS   •   ADD A NEW POST   •   SEARCH   •   CHANGE FORUM
Respond to this post   •   Return to posts index   •   Read entire thread


Re: Video to ASCII effect
by Patrick Deen on Nov 6, 2007 at 1:30:39 pm

You've probably set your character size too small if you only see the bounding boxes ;-)

I've commented Dan's expression for you. Hope it helps you to understand it :-)

One other thing, you can make your own set of characters ranging from light to dark. I wasn't really fond of the "@" as the darkest character so I've altered the desity string to suit my taste.

Here's the commented expression;

density = " .'`,^:" + '";~-_+<>i!lI?/|()1{}[]rcvunxzjftLCJUYXZO0Qoahkbdpqwm*WMB8&%$#@';

/* "density" is just a string ordered with characters from light to dark (" " is white and "@" is black).You can access each character from this string as an array. "density[1]" would be "." since array entries start counting by zero (desity[0] = " ") */

target = thisComp.layer(index -1);

/* the target variable will hold the reference to the layer above the texts layer where you've added this expression */

cols = 80; //number of characters/columns that make up the width of the grid
rows = 60; //number of characters/rows that make up the height of the grid

w = thisComp.width/cols;
// dividing the width by the number of columns gives you the width of each "cell" in the grid

h = thisComp.height/rows;
// dividing the height by the number of columns gives you the height of each "cell" in the grid

s = "" // this declares an empty variable to hold the string that makes up your ascii art

// Next comes a nested loop that makes it all happen...

for (var i = 0; i < rows; i++){ // adding the rows

/* the value of "i" is zero, repeat this action while "i" is smaller than the number of rows, increment "i" with one after each execution of the embedded script */

//the real nested loop

for(var j = 0; j < cols; j++){ // adding the columns to the row

/* the value of "j" is zero, repeat this action while "j" is smaller than the number of columns, increment "j" with one after each execution of the script */

center = [w/2 + j*w, h/2 + i*h];

// divide the width/height of the cell in half and add j times the width/height to that value results in the centre-point of each cell

sample = target.sampleImage(center,[(w-1)/2,(h-1)/2]);

// uses the "center" variable for the position and sets the size of the point to be sampled based on the size of your grid-cells. sample will hold an array of three numbers between 0 and 1 (1=white and 0=black)

s += density[Math.round(linear(sample[0],0,1,0,density.length - 1))];

// the variable "s" is incremented with a character from the "desity" string. The expression between the straight brackets uses the first value of the sampled color in the sample variable to produce an integer/rounded number which is used to select the character to add to the string "s"
}
s += "r"; // After a row is completed this adds a new line to the text until all rows are built.
}
s // in the end the completed string is echoed by this simple notation and this is what shows up on the text layer.


Respond to this post   •   Return to posts index   •   Read entire thread


Current Message Thread:




Note: If you are a registered user please click here to login before posting.

Your post will not be accepted if your name and email address are not registered in our database. Click here if you do not have an account.

Name
E-Mail Address
Subject
E-Mail me when someone responds
Just This Message   Entire Thread   None  

Message:



Note: The following are HTML characters and may cause parts of your post to disappear if not used correctly: < > &
To include any portion of the post in your response, highlight the desired text and hit the "Q" key. Read more...



Please post Expressions Code in the box below:


Add your message signature


 


Note: By clicking "Post Direct" button above, you are agreeing to the Creative Cow's Code of Conduct.



FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]