Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 287 lines (198 sloc) 16.921 kB
511ae14 @ByteProject added markdown read me
ByteProject authored
1 # AnsiLove.framework
2
d55272e @ByteProject readme for framework release 2.0.0
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, `ALAnsiGenerator` is reading SAUCE records and returns these values as Objective-C 2.0 properties.
4
5 It's foundation is based on [libsauce](https://github.com/bricas/libsauce) by [Brian Cassidy](http://blog.alternation.net/).
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
6
7 # Version info
8
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
9 Current framework release: `2.0.0` - rendering library forked from: [AnsiLove/C](https://github.com/ByteProject/AnsiLove-C) `1.0.243`
511ae14 @ByteProject added markdown read me
ByteProject authored
10
11 # Features
12
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
13 Rendering of all known ANSi / ASCII art file types:
14
15 - ANSi (.ANS)
16 - Binary (.BIN)
17 - Artworx (.ADF)
18 - iCE Draw (.IDF)
19 - Xbin (.XB) [details](http://www.acid.org/info/xbin/xbin.htm)
20 - PCBoard (.PCB)
21 - Tundra (.TND) [details](http://sourceforge.net/projects/tundradraw)
22 - ASCII (.ASC)
23 - Release info (.NFO)
24 - Description in zipfile (.DIZ)
25
26 Files with custom suffix default to the ANSi renderer (e.g. ICE or CIA).
27
28 AnsiLove.framework is capabable of processing:
29
30 - SAUCE records
31 - DOS and Amiga fonts (embedded binary dump)
32 - iCE colors
33
34 Still not enough?
35
36 - Output files are highly optimized 4-bit PNGs.
37 - You can use custom objects for adjusting output results.
38 - Built-in support for rendering Amiga ASCII.
39 - Everything's Mac App Store conform and sandboxing compliant.
40 - This is a Automatic Reference Counting (ARC) project.
511ae14 @ByteProject added markdown read me
ByteProject authored
41
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
42 # Documentation
43
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
44 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
45
46 ## Adding the framework to your projects
47
c9681bb @ByteProject corrected to minor typos and a dead hyperlink
ByteProject authored
48 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
49
50 - In the project navigator, select your project
51 - Select your target
52 - Select the `Build Phases` tab
53 - Open `Link Binaries With Libraries` expander
54 - Click the `+` button and select AnsiLove.framework
55 - Hit `Add Build Phase` at the bottom
c9681bb @ByteProject corrected to minor typos and a dead hyperlink
ByteProject authored
56 - Add a `Copy Files` build phase with `Frameworks` as destination
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
57 - Once again select AnsiLove.framework
58
59 Now AnsiLove.framework is properly linked to your target and will be added to compiled binaries.
60
61 ## Implementing the framework in your own sources
62
63 Go to the header of the class you want to use the framework with. Import the framework like this:
64
65 #import <Ansilove/AnsiLove.h>
66
67 To transform any ANSi source file into a beautiful PNG image, there is only one method you need to know:
68
69 + (void)createPNGFromAnsiSource:(NSString *)inputFile
70 outputFile:(NSString *)outputFile
71 font:(NSString *)font
72 bits:(NSString *)bits
73 iceColors:(NSString *)iceColors
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
74 columns:(NSString *)columns
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
75
76 You can call said method like this:
77
78 [ALAnsiGenerator createPNGFromAnsiSource:self.myInputFile
79 outputFile:self.myOutputFile
80 font:self.myFont
81 bits:self.myBits
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
82 iceColors:self.myIceColors
83 columns:self.myColumns];
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
84
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
85 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
86
87 NSString *iceColors;
88 BOOL shouldUseIceColors;
89
90 if (shouldUseIceColors == NO) {
91 self.iceColors = @"0";
92 }
93 else {
94 self.iceColors = @"1";
95 }
96
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
97 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
98
99 self.myFontString = @"";
100
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
101 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
102
103 ## (NSString *)inputFile
104
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
105 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
106
107 /Users/Stefan/Desktop/MyAnsiArtwork.ans
108
46da767 @ByteProject another refinement...
ByteProject authored
109 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
110
111 NSURL *myURL;
112 NSString *urlString = [myURL absoluteString];
113
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
114 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
115
116 ~/Desktop/MyAnsiArtwork.ans
117
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
118 Simple, elegant, comfortable, just working? You decide.
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
119
120 ## (NSString *)outputFile
121
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
122 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
123
124 ## (NSString *)font
125
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
126 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
127
128 `PC` fonts can be (all case-sensitive):
129
130 - `80x25` (code page 437)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
131 - `80x50` (code page 437, 80x50 mode)
132 - `baltic` (code page 775)
133 - `cyrillic` (code page 855)
134 - `french-canadian` (code page 863)
135 - `greek` (code page 737)
136 - `greek-869` (code page 869)
137 - `hebrew` (code page 862)
138 - `icelandic` (Code page 861)
139 - `latin1` (code page 850)
140 - `latin2` (code page 852)
141 - `nordic` (code page 865)
142 - `portuguese` (Code page 860)
5ce9aa4 @ByteProject added Terminus to font string documentation, new license information
ByteProject authored
143 - `russian` (code page 866)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
144 - `terminus` (modern font, code page 437)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
145 - `turkish` (code page 857)
146
147 `AMIGA` fonts can be (all case-sensitive):
148
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
149 - `amiga` (alias to Topaz)
150 - `microknight` (Original MicroKnight version)
151 - `microknightplus` (Modified MicroKnight version)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
152 - `mosoul` (Original mO'sOul font)
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
153 - `pot-noodle` (Original P0T-NOoDLE font)
154 - `topaz` (Original Topaz Kickstart 2.x version)
155 - `topazplus` (Modified Topaz Kickstart 2.x+ version)
156 - `topaz500` (Original Topaz Kickstart 1.x version)
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
157 - `topaz500plus` (Modified Topaz Kickstart 1.x version)
158
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
159 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
160
161 ## (NSString *)bits
162
163 Bits can be (all case-sensitive):
164
165 - `8` (8-bit)
166 - `9` (9-bit)
167 - `ced`
168 - `transparent`
169 - `workbench`
170
171 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.
172
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
173 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.
174
175 Setting the bits to `workbench` will cause the input file to be rendered using Amiga Workbench colors (only available for `.ans` files).
176
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
177 Settings the bits to `transparent` will produce output files with transparent background (only available for `.ans` files).
178
179 ## (NSString *)iceColors
180
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
181 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.
182
183 ## (NSString *)columns
184
185 `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
186
187 ## Supported options for each file type
188
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
189 Here's a simple overview of which file type supports which object:
190
191 ___________________________________________
192 | | | | | |
193 | | columns | font | bits | icecolors |
194 |_____|_________|_______|_______|___________|
195 | | | | | |
196 | ANS | | X | X | X |
197 |_____|_________|_______|_______|___________|
198 | | | | | |
199 | PCB | | X | X | X |
200 |_____|_________|_______|_______|___________|
201 | | | | | |
202 | BIN | X | X | X | X |
203 |_____|_________|_______|_______|___________|
204 | | | | | |
205 | ADF | | | | |
206 |_____|_________|_______|_______|___________|
207 | | | | | |
208 | IDF | | | | |
209 |_____|_________|_______|_______|___________|
210 | | | | | |
211 | TND | | X | X | |
212 |_____|_________|_______|_______|___________|
213 | | | | | |
214 | XB | | | | |
2b688b2 @ByteProject cosmetically change, table not displayed properly
ByteProject authored
215 |_____|_________|_______|_______|___________|
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
216
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
217 ## Rendering Process Feedback
3e5a24e @ByteProject added output file example section
ByteProject authored
218
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
219 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:
220
221 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
222 [nc addObserver:self
223 selector:@selector(addYourCustomSelectorHere:)
224 name:@"AnsiLoveFinishedRendering"
225 object:nil];
226
227 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
228
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
229 ## Output file example
ac83b58 @ByteProject supplemented App Sandboxing informations
ByteProject authored
230
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
231 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
232
233 # Reading SAUCE records
234
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
235 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`, it absolutely makes sense to check for a SAUCE record before you start rendering. Anyway, it's just a hint. Convenient yes, but by no means necessary to check for SAUCE before you start rendering. 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
236
237 ALSauceMachine *sauce = [[ALSauceMachine alloc] init];
238
239 Now you can call `readRecordFromFile:`, this should be self-explanatory:
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
240
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
241 [sauce readRecordFromFile:myInputFile];
08ecbf2 @ByteProject added documentation for rendering process feedback
ByteProject authored
242
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
243 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
244
245 BOOL fileHasRecord;
246 BOOL fileHasComments;
247 BOOL fileHasFlags;
248
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
249 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 `fileHasobjects` 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
250
251 NSString *ID;
252 NSString *version;
253 NSString *title;
254 NSString *author;
255 NSString *group;
256 NSString *date;
257 NSInteger dataType;
258 NSInteger fileType;
259 NSInteger tinfo1;
260 NSInteger tinfo2;
261 NSInteger tinfo3;
262 NSInteger tinfo4;
263 NSString *comments;
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
264 NSInteger objects;
79c8b2b @ByteProject massive documentation update for ALSauceMachine
ByteProject authored
265
266 Now imagine you want to print SAUCE title and author in NSLog:
267
268 NSLog(@"This is: %@ by %@.", sauce.title, sauce.author);
269
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
270 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
271
272 # App Sandboxing
273
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
274 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
275
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
276 # Why?
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
277
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
278 AnsiLove.framwork was created for my app [Ascension](http://byteproject.net/ascension).
198c55f @ByteProject now THIS is what I call good documentation
ByteProject authored
279
280 # Credits
281
d55272e @ByteProject readme for framework release 2.0.0
ByteProject authored
282 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 significant influence on [AnsiLove/C](https://github.com/ByteProject/AnsiLove-C), which is a major part of AnsiLove.framework. 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 artists and lovers 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
283
284 # License
511ae14 @ByteProject added markdown read me
ByteProject authored
285
5ce9aa4 @ByteProject added Terminus to font string documentation, new license information
ByteProject authored
286 Ascension is released under a MIT-style license. See the file `LICENSE` for details.
Something went wrong with that request. Please try again.