Click here to Skip to main content
Licence 
First Posted 20 May 2002
Views 61,640
Bookmarked 12 times

ASCII Animation (Just for fun)

By | 20 May 2002 | Article
Draw and animate ASCII characters to a window using this COM object.

Introduction

Asciimation is short for ASCII animation. Kind of a poor man's DirectX or Window's GDI. Here I present a small COM library for you creative types to try your hand at this new art form.

What's the point?

There is none, I did this for fun. I was inspired by Star Wars Asciimation and thought, I could make that a little easier on would be ASCII artists.

The IAsciiAPI interface methods

Initialize(DWORD hwnd, [out, retval] VARIANT_BOOL* bInitialized);
SetBackColor(int R, int G, int B);
SetBackMode(int nMode);
SetForeColor(int R, int G, int B);
GetWidth([out, retval] int* width);
GetHeight([out, retval] int* height);
ClearScreen();
DrawString(BSTR bstrString, int x, int y);
Circle(int x, int y, int radius, int step, short nAsciiCode, 
    VARIANT_BOOL bFilled);
Arc(int x, int y, int radius, int degfrom, int degto, int step, 
    short nAsciiCode, VARIANT_BOOL bFilled);
Rectangle(int left, int top, int right, int bottom, short nAsciiCode, 
    VARIANT_BOOL bFilled);
CharBlit(BSTR bstrCharArray, int Width, int Height, int DestX, 
    int DestY, short nAsciiMask);

Initialize

Send this method the HWND of the window to draw the Asciimation on. Without this, it has no where to draw to. I thought about making Asciimation a control, but I thought it would be better to make it more API like.

SetBackMode

Sets the nBackMode member variable which is used to set the background mode of the text (OPAQUE or TRANSPARENT).

SetBackColor

Sets the crBackColor member variable which is used to set the background color of the text.

SetForeColor

Sets the crForeColor member variable which is used to set the color of the text.

GetWidth

Returns the number of characters that will fit in the width of the window.

GetHeight

Returns the number of characters that will fit in the height of the window.

ClearScreen

Draws spaces across the width and height of the window using the current background mode and background color.

DrawString

Draws an array of character on the window at the given coordinates.

Circle

Draws a circle of characters, using the nAsciiCode parameter, with the center at (x,y) and a radius of radius. The step parameter will draw a broken circle, drawing characters only every step degrees. To fill the circle, set bFilled = VARIANT_TRUE, otherwise set it to VARIANT_FALSE.

Arc

Draws an arc of characters, using the nAsciiCode parameter, with the center at (x,y) and a radius of radius, from degfrom degrees to degto degrees. The step parameter will draw a broken arc, drawing characters only every step degrees.

Rectangle

Draws a rectangle of characters with corners at (left, top) - (right, bottom) using the nAsciiCode parameter. To fill the rectangle, set bFilled = VARIANT_TRUE, otherwise set it to VARIANT_FALSE.

CharBlit

Draw the bstrCharArray array of characters to the window at (DestX, DestY). All characters will display in a Width X Height rectangle except for nAsciiMask character, which will not be drawn at all.

Conclusion

If you found this code useful in any way, that's awesome! If not, too bad, but I hope you can have some fun with it.

Here are a couple of screen shots from the demo project:

If you have ideas on improving or adding methods to Asciimation, feel free to drop me an e-mail or a message here, or take the initiative and modify the code yourself.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Jason Henderson

Software Developer (Senior)

United States United States

Member

I live in the middle of no where in Illinois, USA. I am married and have four children.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalmissing file PinmemberChris Losinger10:48 21 May '02  
GeneralRe: missing file PinmemberJason Henderson10:55 21 May '02  
GeneralRe: missing file Pinmemberlucy11:43 21 May '02  
GeneralRe: missing file Pinmemberlucy11:46 21 May '02  
GeneralRe: missing file PinmemberChristian Graus16:29 21 May '02  
GeneralRe: missing file PinmemberJason Henderson16:43 21 May '02  
GeneralRe: missing file Pinmemberlucy2:44 22 May '02  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 21 May 2002
Article Copyright 2002 by Jason Henderson
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid