Click here to Skip to main content
11,706,639 members (44,527 online)
Click here to Skip to main content

ASCII Animation (Just for fun)

, 20 May 2002 67.2K 1.1K 12
Rate this:
Please Sign up or sign in to vote.
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

Share

About the Author

Jason Henderson
Architect
United States United States
I have been a professional developer since 1996. I live in the middle of no where in Illinois, USA. I am married and have four children.

You may also be interested in...

Comments and Discussions

 
Generalmissing file Pin
Chris Losinger21-May-02 10:48
memberChris Losinger21-May-02 10:48 
GeneralRe: missing file Pin
Jason Henderson21-May-02 10:55
memberJason Henderson21-May-02 10:55 
GeneralRe: missing file Pin
lucy21-May-02 11:43
memberlucy21-May-02 11:43 
GeneralRe: missing file Pin
lucy21-May-02 11:46
memberlucy21-May-02 11:46 
GeneralRe: missing file Pin
Christian Graus21-May-02 16:29
memberChristian Graus21-May-02 16:29 
GeneralRe: missing file Pin
Jason Henderson21-May-02 16:43
memberJason Henderson21-May-02 16:43 
GeneralRe: missing file Pin
lucy22-May-02 2:44
memberlucy22-May-02 2:44 

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.

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