![]() ![]() That was the key to jettisoning lockFocus. The code in the block should be the same code that you would use between the lockFocus and unlockFocus methods. On that page, it said something, albeit without examples, that I hadn’t seen before: While writing text2image I ran across Apple’s page recommending against lockFocus for creating image files. This means that a command-line script written using lockFocus will change its behavior depending on what kind of a monitor you’re using. That’s a problem, because lockFocus does things that only make sense when displaying to a screen, such as automatically changing the number of dots in the image depending on whether your screen is a retina screen. Most of the few remaining examples continue to use lockFocus probably because that’s what gets used most often for examples. They use lockFocus() to create the image. Almost all of the examples of creating images in Apple’s documentation and on sites such as stack overflow assume that you’re creating images to display to the screen. If you’ve read 42 Astounding Scripts, this is an image-oriented variation of my alignTabs script and makeHTMLTable script.īoth asciiArt and text2image take text and create images out of the text. It has pretty much only one use case, online outlets that accept images but not tables. It is both a more serious program than asciiArt and more frivolous. Originally for converting tabular data to an image I now use it for taking paragraphs and wrapping them and justifying them or aligning them right or center. I wrote another script more recently that takes standard input and converts it to an image of the text. But I’ve since extended the script to include color, color overlays, and random color, as well as sequential text instead of text chosen for its density. I wrote it to do basically what ascii art used to be, an ingenious method of greyscaling images at very low resolution. ![]() My favorite of these wee hour efforts is a script I wrote for 42 Astoundingly Useful Scripts and Automations for the Macintosh to turn photographs into ascii art. ![]() These are the kind of scripts that bring me back to ma jeuness of staying up into the morning hours programming. Among the coolest uses of command line scripts in Swift on the Macintosh are those that intermediate between images and text. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |