cparnot / asciimage Goto Github PK
View Code? Open in Web Editor NEWCreate UIImage / NSImage instances with NSString and ASCII art
License: MIT License
Create UIImage / NSImage instances with NSString and ASCII art
License: MIT License
Paths need not be contiguous and having composite paths are necessary to have shapes with holes in them. Personally, I think all paths in one ASCII representation should be part of one path and you would use multiple paths/representations for separate shapes. But if you want to work it all into a single rep then that's your choice.
See comment from @milen-me : #6 (comment)
I think it makes more sense to have the parsing code in a NSBezierPath category. You can keep the API on NS/UIImage as a wrapper around this but it allows this to be used in other drawing contexts.
I started using ASCIIImage with some Apple Watch code and noticed that the automatic scaling done by the current code will be done based on the current device scale, which can be wrong if running in the watch extension. For instance, if running on iPhone 6+, you'll get a 3x image, when you actually need 2x.
There are methods normally exposed only for tests that have a scaleFactor parameter that can be used as a workaround, but the naming can be confusing and there is the issue #1 that needs to be taking into account.
At the moment, Bezier paths created for ellipses are sized so that filling them gets all the way to the pixel borders. As a result, when using stroke for drawing, they are not pixel-aligned like all the other shapes. The rect for ellipses simply need to be inset 0.5 points. When rendered as pure fill, we need to issue a fill
and a stroke
, just like for polygons.
The aim of this issue is to get the discussion started on a point that, I think we all agree, would be pretty useful: finding some implementation-independent method to define context/path metadata (i.e. both default and per-path overrides of fill color, stroke color and stroke width, aliasing/anti-aliasing, and open/closed path choices).
A possibility would be a JSON or YAML snippet holding a simple map having keys default
, element0
, ... elementN
(or something similar), and with values maps of the properties to their values.
This does have the downside that more sophisticated selections (e.g. "if index is less than 2 or higher than 16") are not possible; a solution would be to allow keys in the hash to be arrays or ranges or something similar.
It would be wonderful to have ASCIImage as an Xcode plug-in, perhaps utilising Monodraw - http://monodraw.helftone.com
So a user could:
• hit a key-combo
• draw image
• hit return
• have a ASCIIImage method written, with perfect iOS 8 style lines
The endless tyranny of relying on designers and photoshop would be finished. The dawn bell would mark the hour of liberation, and the soothing light of justice would flood over the horizon. In the far future, when our own humble sun explodes, and when giant spaceships send our descendants into space to populate the universe, they will carry with them the memory of when ASCIIImage was made into an Xcode plugin. Something like that anyway.
Might be useful, if same image needs to be used in several source files.
+ (PARImage *)imageWithASCIITextFile:(NSString *)textFile color:(PARColor *)color shouldAntialias:(BOOL)shouldAntialias {
NSString *type = @"txt";
NSString *separation = @"\n";
NSString *fileText = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:textFile ofType:type] encoding:NSUTF8StringEncoding error:nil];
NSArray *rep = [[NSArray alloc] initWithArray:[fileText componentsSeparatedByString:separation]];
return [self imageWithASCIIRepresentation:rep contextHandler:[self contextHandlerForImageWithColor:color shouldAntialias:shouldAntialias]];
}
Perhaps this is beyond the realm of ASCIIImage, but it would be awesome to be able to animate between two (or more) ascii images. It would make the creation of things like this easier:
https://github.com/jonathantribouharet/JTHamburgerButton
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.