Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 285 lines (197 sloc) 16.972 kB
511ae14 @ByteProject added markdown read me
ByteProject authored
1 # AnsiLove.framework
2
2b39f36 @ByteProject sometimes, less is more in a documentation
ByteProject authored
3 This is Cocoa framework I consider as modern approach of bringing back the good old days™. It's capable of rendering ANSi / ASCII art and it also handles SAUCE records. There are two classes responsible for all the magic: `ALAnsiGenerator` and `ALSauceMachine`. The former, `ALAnsiGenerator` creates PNG images from ANSi source files. What with one thing and another, PNG images are read-only. So if you're looking for something that generates output in real textmode, maybe as a NSAttributedString instance, you're wrong. However, if you're seeking the most complete and accurate rendering of ANSi art sources available these days, you came to the right place. While `ALAnsiGenerator` acts more like a Cocoa layer, there is a specifc library under the surface. It's called [AnsiLove/C](https://github.com/ByteProject/AnsiLove-C) and we spent countless hours developing it. The latter, `ALSauceMachine` is reading SAUCE records and returns these values as Objective-C properties.
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
4
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
5 # Version info
6
19b56ac @ByteProject new framework version is 2.0.3 (20)
ByteProject authored
7 Current framework release: `2.0.3` - rendering library: [AnsiLove/C](https://github.com/ByteProject/AnsiLove-C) `1.0.248`
511ae14 @ByteProject added markdown read me
ByteProject authored
8
9 # Features
10
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
11 Rendering of all known ANSi / ASCII art file types:
12
13 - ANSi (.ANS)
14 - Binary (.BIN)
15 - Artworx (.ADF)
16 - iCE Draw (.IDF)
17 - Xbin (.XB) [details](http://www.acid.org/info/xbin/xbin.htm)
18 - PCBoard (.PCB)
19 - Tundra (.TND) [details](http://sourceforge.net/projects/tundradraw)
20 - ASCII (.ASC)
21 - Release info (.NFO)
22 - Description in zipfile (.DIZ)
23
24 Files with custom suffix default to the ANSi renderer (e.g. ICE or CIA).
25
26 AnsiLove.framework is capabable of processing:
27
28 - SAUCE records
29 - DOS and Amiga fonts (embedded binary dump)
30 - iCE colors
31
32 Still not enough?
33
34 - Output files are highly optimized 4-bit PNGs.
35 - You can use custom objects for adjusting output results.
36 - Built-in support for rendering Amiga ASCII.
37 - Everything's Mac App Store conform and sandboxing compliant.
16c6415 @ByteProject raiders of the lost typo...!
ByteProject authored
38 - This is an Automatic Reference Counting (ARC) project.
511ae14 @ByteProject added markdown read me
ByteProject authored
39
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
40 # Documentation
41
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
42 Let's talk about using the framework in your own projects. First of all, AnsiLove.framework is intended to run on `OS X`, it won't work on `iOS`. Yeah, sorry for that. Not even my fault, it's simply not possible at this point. You have to download the sources and compile the framework. At least OS X Lion and Xcode 4.x are necessary for this purpose. The project contains two build targets, the framework itself and a test app `AnsiLoveGUI`, the latter is optional. Select `AnsiLoveGUI` from the Schemes dropdown in Xcode if you desire to compile that one too. The test app is a good example of implementing AnsiLove.framework, it does not contain much code and what you find there is well commented. So `AnsiLoveGUI` might be your first place to play with the framework after reading this documentation. Being an ARC framework, the test app is a pure ARC project as well. What else.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
43
44 ## Adding the framework to your projects
45
c9681bb @ByteProject corrected to minor typos and a dead hyperlink
ByteProject authored
46 Place the compiled framework in a folder inside your project, I recommend creating a `Frameworks` folder, if not existing. In Xcode go to the File menu and select `Add Files to "MyProject"`, select the AnsiLove.framework you just dropped in the `Frameworks` folder and then drag the framework to the other frameworks in your project hierarchy. The last steps are pretty easy:
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
47
48 - In the project navigator, select your project
49 - Select your target
50 - Select the `Build Phases` tab
51 - Open `Link Binaries With Libraries` expander
52 - Click the `+` button and select AnsiLove.framework
53 - Hit `Add Build Phase` at the bottom
c9681bb @ByteProject corrected to minor typos and a dead hyperlink
ByteProject authored
54 - Add a `Copy Files` build phase with `Frameworks` as destination
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
55 - Once again select AnsiLove.framework
56
57 Now AnsiLove.framework is properly linked to your target and will be added to compiled binaries.
58
59 ## Implementing the framework in your own sources
60
61 Go to the header of the class you want to use the framework with. Import the framework like this:
62
63 #import <Ansilove/AnsiLove.h>
64
65 To transform any ANSi source file into a beautiful PNG image, there is only one method you need to know:
66
67 + (void)createPNGFromAnsiSource:(NSString *)inputFile
68 outputFile:(NSString *)outputFile
69 font:(NSString *)font
70 bits:(NSString *)bits
71 iceColors:(NSString *)iceColors
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
72 columns:(NSString *)columns
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
73
74 You can call said method like this:
75
76 [ALAnsiGenerator createPNGFromAnsiSource:self.myInputFile
77 outputFile:self.myOutputFile
78 font:self.myFont
79 bits:self.myBits
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
80 iceColors:self.myIceColors
81 columns:self.myColumns];
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
82
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
83 Keep in mind that ALAnsiGenerator needs all it's objects as `NSString` instances. You can work internally with numeric types like `NSInteger` or `BOOL` but you need to convert them to strings before you pass these values to ALAnsiGenerator. For example, `iceColors` (I'm going to explain all objects in detail below) can only be `0` or `1`, so it's perfect to have that as `BOOL` type in your app. I did this in `AnsiLoveGUI` as well. To pass this value to ALAnsiGenerator you can do it something like this:
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
84
85 NSString *iceColors;
86 BOOL shouldUseIceColors;
87
88 if (shouldUseIceColors == NO) {
89 self.iceColors = @"0";
90 }
91 else {
92 self.iceColors = @"1";
93 }
94
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
95 Note that generally all objects except `inputFile` are optional. You can either decide to pass `nil` (AnsiLove.framework will then work with it's default values) or pass empty strings like:
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
96
97 self.myFontString = @"";
98
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
99 AnsiLove.framework will silently consume `nil` and empty string values but it will rely on it's built-in defaults in both cases. Clever? Sure. So much for the basics, let's head over to the details. `createPNGFromAnsiSource:` seems like a pretty simple method but in fact it's so damn powerful if you know how to deal with objects you pass and that is what I'm going to teach you now.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
100
101 ## (NSString *)inputFile
102
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
103 The only necessary object you need to pass to ALAnsiGenerator. Well, that's logic. If there is no input file, what should be the output? I see you get it. Here is an example for a proper `inputFile` string:
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
104
105 /Users/Stefan/Desktop/MyAnsiArtwork.ans
106
46da767 @ByteProject another refinement...
ByteProject authored
107 I recommend treating this string case-sensitive. As you can see, that string explicitly needs to contain the path and the file name. That's pretty cool because it means you can work either with `NSStrings` or `NSURLs` internally. Just keep in mind that any `NSURL` needs to be converted to a string before passing to ALAnsiGenerator. NSURL has a method called `absoluteString` that can be used for easy conversion.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
108
109 NSURL *myURL;
110 NSString *urlString = [myURL absoluteString];
111
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
112 But AnsiLove.framework is even more flexible and it will automatically resolve any tilde in `inputFile` string instances. Now you know that this is a proper `inputFile` string, too:
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
113
114 ~/Desktop/MyAnsiArtwork.ans
115
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
116 Simple, elegant, comfortable, just working? You decide.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
117
118 ## (NSString *)outputFile
119
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
120 Formatting of string `outputFile` is identical to string `inputFile`. Only one difference: `outputFile` is optional. If you don't set this object, the framework will use the same path / file name you passed as `inputFile` string, but it will add .PNG as suffix. However, if you plan to write your PNG into a different directory and / or under a different filename, go ahead and customize this object.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
121
122 ## (NSString *)font
123
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
124 AnsiLove.framework comes with two font families both originating from the golden age of ANSi artists. These font families are `PC` and `AMIGA`, the latter restricted to 8-bit only. Let's have a look at the values you can pass as `font` string.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
125
126 `PC` fonts can be (all case-sensitive):
127
128 - `80x25` (code page 437)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
129 - `80x50` (code page 437, 80x50 mode)
130 - `baltic` (code page 775)
131 - `cyrillic` (code page 855)
132 - `french-canadian` (code page 863)
133 - `greek` (code page 737)
134 - `greek-869` (code page 869)
135 - `hebrew` (code page 862)
136 - `icelandic` (Code page 861)
137 - `latin1` (code page 850)
138 - `latin2` (code page 852)
139 - `nordic` (code page 865)
140 - `portuguese` (Code page 860)
5ce9aa4 @ByteProject added Terminus to font string documentation, new license information
ByteProject authored
141 - `russian` (code page 866)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
142 - `terminus` (modern font, code page 437)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
143 - `turkish` (code page 857)
144
145 `AMIGA` fonts can be (all case-sensitive):
146
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
147 - `amiga` (alias to Topaz)
148 - `microknight` (Original MicroKnight version)
4ecede8 @ByteProject can't believe there was a wrong font flag in docs, fixed now
ByteProject authored
149 - `microknight+` (Modified MicroKnight version)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
150 - `mosoul` (Original mO'sOul font)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
151 - `pot-noodle` (Original P0T-NOoDLE font)
152 - `topaz` (Original Topaz Kickstart 2.x version)
dcd2cc8 @ByteProject updated two AnsiLove font string values
ByteProject authored
153 - `topaz+` (Modified Topaz Kickstart 2.x+ version)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
154 - `topaz500` (Original Topaz Kickstart 1.x version)
dcd2cc8 @ByteProject updated two AnsiLove font string values
ByteProject authored
155 - `topaz500+` (Modified Topaz Kickstart 1.x version)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
156
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
157 If you don't set a `font` object either passing `nil` or an empty string to ALAnsiGenerator, the AnsiLove.framework will generate the PNG with `80x25`, which is the default DOS font.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
158
159 ## (NSString *)bits
160
161 Bits can be (all case-sensitive):
162
163 - `8` (8-bit)
164 - `9` (9-bit)
165 - `ced`
166 - `transparent`
167 - `workbench`
168
169 Setting the bits to `9` will render the 9th column of block characters, so the output will look like it is displayed in real textmode.
170
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
171 Setting the bits to `ced` will cause the input file to be rendered in black on gray, and limit the output to 78 columns (only available for `.ans` files). Used together with an `AMIGA` font, the output will look like it is displayed on Amiga.
172
173 Setting the bits to `workbench` will cause the input file to be rendered using Amiga Workbench colors (only available for `.ans` files).
174
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
175 Settings the bits to `transparent` will produce output files with transparent background (only available for `.ans` files).
176
177 ## (NSString *)iceColors
178
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
179 Setting `iceColors` to `1` will enable iCE color codes. On the opposite `0` means that that `iceColors` are disabled, which is the default value. When an ANSi source was created using iCE colors, it was done with a special mode where the blinking was disabled, and you had 16 background colors available. Basically, you had the same choice for background colors as for foreground colors, that's iCE colors. But now the important part: when the ANSi source does not make specific use of iCE colors, you should NOT enable them. The file could look pretty weird in normal mode. So in most cases it's fine to turn iCE colors off.
180
181 ## (NSString *)columns
182
183 `columns` is only relevant for ANSi source files with `.BIN` extension and even for those files optional. In most cases conversion will work fine if you don't set this flag, the default value is `160` then. So please pass `columns` only to `.BIN` files and only if you exactly know what you're doing. A KITTEN MAY DIE SOMEWHERE.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
184
185 ## Supported options for each file type
186
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
187 Here's a simple overview of which file type supports which object:
188
189 ___________________________________________
190 | | | | | |
191 | | columns | font | bits | icecolors |
192 |_____|_________|_______|_______|___________|
193 | | | | | |
194 | ANS | | X | X | X |
195 |_____|_________|_______|_______|___________|
196 | | | | | |
197 | PCB | | X | X | X |
198 |_____|_________|_______|_______|___________|
199 | | | | | |
200 | BIN | X | X | X | X |
201 |_____|_________|_______|_______|___________|
202 | | | | | |
203 | ADF | | | | |
204 |_____|_________|_______|_______|___________|
205 | | | | | |
206 | IDF | | | | |
207 |_____|_________|_______|_______|___________|
208 | | | | | |
209 | TND | | X | X | |
210 |_____|_________|_______|_______|___________|
211 | | | | | |
212 | XB | | | | |
2b688b2 @ByteProject cosmetically change, table not displayed properly
ByteProject authored
213 |_____|_________|_______|_______|___________|
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
214
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
215 ## Rendering Process Feedback
3e5a24e @ByteProject added output file example section
ByteProject authored
216
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
217 AnsiLove.framework will post a notification once processing of given source files is finished. In most cases it's pretty important to know when rendering is done. One might want to present an informal dialog or update the UI afterwards. For making your app listen to the `AnsiLoveFinishedRendering` note, all you need is adding this to the `init` method of the class you consider as relevant:
218
219 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
220 [nc addObserver:self
221 selector:@selector(addYourCustomSelectorHere:)
222 name:@"AnsiLoveFinishedRendering"
223 object:nil];
224
225 The test app `AnsiLoveGUI` has a simple implementation that posts a message to NSLog as soon as the rendering is completed.
3e5a24e @ByteProject added output file example section
ByteProject authored
226
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
227 ## Output file example
ac83b58 @ByteProject supplemented App Sandboxing informations
ByteProject authored
228
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
229 You may wonder how the rendered output looks like? You'll find an example [here](http://cl.ly/1D0o1M2t2Y190v33462F/o).
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
230
231 # Reading SAUCE records
232
16c6415 @ByteProject raiders of the lost typo...!
ByteProject authored
233 The framework's class for dealing with SAUCE records is `ALSauceMachine`. But before we continue, here's your opportunity to introduce yourself to the [SAUCE specifications](http://www.acid.org/info/sauce/s_spec.htm). Plenty values retrieved from SAUCE records can be passed as objects to `ALAnsiGenerator`, so it makes sense indeed to check for a SAUCE record before you start rendering. Anyway, it's just a hint. Convenient yes, but by no means necessary. Enough theory, here is how to use the class. First we need to create an instance of `ALSauceMachine`:
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
234
235 ALSauceMachine *sauce = [[ALSauceMachine alloc] init];
236
237 Now you can call `readRecordFromFile:`, this should be self-explanatory:
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
238
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
239 [sauce readRecordFromFile:myInputFile];
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
240
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
241 You probably guess that not all files contain SAUCE and you're right. Many ANSi files actually contain SAUCE (like [this file](http://sixteencolors.net/pack/acid-56/W7-R666.ANS)) and some just don't. So how do you know? I've implemented three handy BOOL values, they give you all the feedback you need:
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
242
243 BOOL fileHasRecord;
244 BOOL fileHasComments;
245 BOOL fileHasFlags;
246
af5f902 @ByteProject what the....!?
ByteProject authored
247 The first property, `fileHasRecord` stands above the others, which means if a file doesn't have a SAUCE record, it's evident it doesn't have SAUCE comments and objects. My advice: don't check `fileHasComments` and `fileHasFlags` if you already know there is no SAUCE record. Don't get my wrong, nothing will explode if you do so. But the answer will always be NO in that case so it's a waste of time. What if a file contains a SAUCE record on the other hand? It's nevertheless possible it doesn't have comments and objects. So if `fileHasRecord` is YES, you should try the other two BOOL values as well. Let's assume your class instance is still `*sauce` and you now checked for all three BOOL types, knowing the details. How to retrieve the SAUCE? Easy. `ALSauceMachine` stores the SAUCE record into properties, right at your fingertips:
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
248
249 NSString *ID;
250 NSString *version;
251 NSString *title;
252 NSString *author;
253 NSString *group;
254 NSString *date;
255 NSInteger dataType;
256 NSInteger fileType;
257 NSInteger tinfo1;
258 NSInteger tinfo2;
259 NSInteger tinfo3;
260 NSInteger tinfo4;
261 NSString *comments;
af5f902 @ByteProject what the....!?
ByteProject authored
262 NSInteger flags;
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
263
264 Now imagine you want to print SAUCE title and author in NSLog:
265
266 NSLog(@"This is: %@ by %@.", sauce.title, sauce.author);
267
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
268 That's it. If you feel like this introduction to AnsiLove.framework's SAUCE implementation left some of your questions unanswered, I suggest you take a closer look at `AnsiLoveGUI` (the sample app). It contains a full featured yet simple example how to use `ALSauceMachine`.
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
269
270 # App Sandboxing
271
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
272 The framework runs great in sandboxed apps. That is because I handcrafted it to be like that. No temporary exceptions, no hocus-pocus, just you on your lonely island. AnsiLove.framework comes with it's own tiny subsystem to achieve sandboxing compliance. Sounds like no big deal? Go sit on a tack. Actually that was the hardest part of the whole framework.
a1e5fb0 @ByteProject added 'Todo' section to documentation
ByteProject authored
273
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
274 # Why?
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
275
16c6415 @ByteProject raiders of the lost typo...!
ByteProject authored
276 AnsiLove.framework was created for my app [Ascension](http://byteproject.net/ascension).
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
277
278 # Credits
279
9db3aaa @ByteProject Pour la legende!
ByteProject authored
280 I'd like to thank my friends [Frederic Cambus](http://www.cambus.net) and [Brian Cassidy](http://blog.alternation.net/) for their ongoing support. Both had a major impact on [AnsiLove/C](https://github.com/ByteProject/AnsiLove-C) and thus on AnsiLove.framework. While Fred is also responsible for [AnsiLove/C's](https://github.com/ByteProject/AnsiLove-C) well-known ancestor [AnsiLove/PHP](http://ansilove.sourceforge.net/), significant parts of Brian's [libsauce](https://github.com/bricas/libsauce) breathe life into `ALSauceMachine`. Thanks fly out to the all you people around the world, downloading [Ascension](http://byteproject.net/ascension) more than hundred times a day since I released it. You are the reason I did this. Finally I bow to all the great ANSi / ASCII lovers and artists around the world. You are the artscene. You keep alive what was not meant to die years ago. YOU ARE ROCKSTARS!
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
281
282 # License
511ae14 @ByteProject added markdown read me
ByteProject authored
283
5ce9aa4 @ByteProject added Terminus to font string documentation, new license information
ByteProject authored
284 Ascension is released under a MIT-style license. See the file `LICENSE` for details.
Something went wrong with that request. Please try again.