I'm spending a lot of time in Cocoa drawing and Core Graphics lately, working in Swift.
The API around the Core Graphics CGPattern object in Swift is a little challenging - it requires C callbacks and unsafe pointers for basic pattern-creation and drawing functionality. It also doesn't work exactly as I'd like it to; I want to have more of a 'brush' metaphor where I can vary the 'paint' flow of the pattern being used to draw a line or a curve. But I definitely want a pattern-like construct that I can apply different stroke and fill colors to in order to draw.
My solution is to use NSImage, which is really convenient because it's a high-level object in Swift that can easily be created in memory or loaded from a .png resource in the app bundle.
The approach: given an NSImage that represents your brush pattern, create a copy NSImage that is rendered in the desired stroke color, then use that copy to draw your desired lines and curves, or tile it along with clipping to fill an area. I'll include an example of drawing a line with varying density, and of filling an area with clipping and offset adjustment.
Saturday, November 30, 2019
Friday, November 29, 2019
Fractal Friday! 2019.11.29
It's Fractal Friday! As always you can click the images below to see them full-size.
This week's fractal images highlight two new features added to the application I'm developing: color cycles, and Nth-degree fractal expressions.
A color cycle is an an array of colors used to render the fractal pixels. The renderer cycles through them for each output value, rather than drawing a gradual shift of color. The result is a striped output that can be pretty dramatic, and sometimes psychedelic!
Here's the simplest case, using just two values (black and white) and cycling through them to render the Julia set:
Of course any two colors can be substituted. Here's a bit of Mandlebrot set in bumblebee colors, black and yellow:
A color cycle can use more than two colors; the renderer just uses them all before repeating. Here's an example with eight colors (plus black, used as the maximum did-not-escape color in the background). Also, this image is using the altered Julia set equation: instead of z^2 + C, this is z^3 + C evaluated recursively.
The app now generally supports z^N (where N is a positive integer) for Julia sets, and the different shapes that emerge are worth exploring. Here is an N=4 set, with a two-color cycle:
And finally an N=5 set centered on the origin, again with a two-color cycle:
All of the julia sets above used C = -0.223 + 0.745i, with breakout value at 1000.0 and max iterations set to 32.
Coming soon: screenshots of the application in development, and other types of mathematical graphics output. And more fractals, every Friday!
Follow Mathaesthetics on Twitter, Instagram, and Facebook for updates, and more mathematical art.
This week's fractal images highlight two new features added to the application I'm developing: color cycles, and Nth-degree fractal expressions.
A color cycle is an an array of colors used to render the fractal pixels. The renderer cycles through them for each output value, rather than drawing a gradual shift of color. The result is a striped output that can be pretty dramatic, and sometimes psychedelic!
Here's the simplest case, using just two values (black and white) and cycling through them to render the Julia set:
Of course any two colors can be substituted. Here's a bit of Mandlebrot set in bumblebee colors, black and yellow:
A color cycle can use more than two colors; the renderer just uses them all before repeating. Here's an example with eight colors (plus black, used as the maximum did-not-escape color in the background). Also, this image is using the altered Julia set equation: instead of z^2 + C, this is z^3 + C evaluated recursively.
The app now generally supports z^N (where N is a positive integer) for Julia sets, and the different shapes that emerge are worth exploring. Here is an N=4 set, with a two-color cycle:
And finally an N=5 set centered on the origin, again with a two-color cycle:
All of the julia sets above used C = -0.223 + 0.745i, with breakout value at 1000.0 and max iterations set to 32.
Coming soon: screenshots of the application in development, and other types of mathematical graphics output. And more fractals, every Friday!
Follow Mathaesthetics on Twitter, Instagram, and Facebook for updates, and more mathematical art.
Friday, November 22, 2019
Fractal Friday! 2019.11.22
This week's images are mostly from the same region, x-axis: (-1.308, 0.567), y-axis (-0.542, 1.351). I started with the Douady rabbit - setting C to -0.123 + 0.745i, with max iterations for these renderings set to 32 and the escape radius set to 1000.0.
Each of the following is produced by an adjustment to C (and aesthetic variation in the color mapping). This dragon-like picture comes from adding .1 to C (-0.023 + 0.745i):
From here, adding .1i to C (-0.023 + 0.845i) brings us these thick, jagged bolts:
Another little tweak of the real part of C, up to 0.027, transforms the set into this wonderful slender lighting:
I made one additional change, with the final C point set to 0.177 + 0.845i. The result was a set of elusive, scattered sparks - I zoomed in quite a bit to find a region I liked though the sparseness continues as one zooms in. This final picture shows the x-axis with range (-0.234, -0.206) and the y-axis range (0.5899, 0.624).
These images were all made with a new software program under development. You can follow us on Twitter, Instagram, and Facebook for updates, and more mathematical art!
Each of the following is produced by an adjustment to C (and aesthetic variation in the color mapping). This dragon-like picture comes from adding .1 to C (-0.023 + 0.745i):
From here, adding .1i to C (-0.023 + 0.845i) brings us these thick, jagged bolts:
Another little tweak of the real part of C, up to 0.027, transforms the set into this wonderful slender lighting:
I made one additional change, with the final C point set to 0.177 + 0.845i. The result was a set of elusive, scattered sparks - I zoomed in quite a bit to find a region I liked though the sparseness continues as one zooms in. This final picture shows the x-axis with range (-0.234, -0.206) and the y-axis range (0.5899, 0.624).
These images were all made with a new software program under development. You can follow us on Twitter, Instagram, and Facebook for updates, and more mathematical art!
Tuesday, November 19, 2019
Strawberry vector fields forever
My new vector field renderer prototype is chugging along, and combined with hooking up .png output to the app I was able to make a couple of little animations with it.
The vector function is a combination of trig and exponentiation (mixing up x and y to keep things interesting across the plane). These animated GIFs show a zoom in toward the origin.
I'm especially fond of this chromatic-circle vector field mode - the vector length controls the circle radius, while the angle is interpreted as hue color:
Here's the same function, field, and zoom, using a simple line representation of each vector (drawn from tail at evaluated point):
Can't wait to hook up the controls & file persistence so I can do some deeper exploration of vector fields and their aesthetic possibilities!
The vector function is a combination of trig and exponentiation (mixing up x and y to keep things interesting across the plane). These animated GIFs show a zoom in toward the origin.
I'm especially fond of this chromatic-circle vector field mode - the vector length controls the circle radius, while the angle is interpreted as hue color:
Here's the same function, field, and zoom, using a simple line representation of each vector (drawn from tail at evaluated point):
Saturday, November 16, 2019
Free memory game! Memsight 1.0 now available for iPhone, iPad
Our first free iPhone/iPad game is now available on the app store!
Challenge your memory with a fun, addictive game. Free to play with ads, or just $0.99 to remove ads and unlock higher levels!
You can read more about Memsight here, or just go straight to the App Store!
Challenge your memory with a fun, addictive game. Free to play with ads, or just $0.99 to remove ads and unlock higher levels!
You can read more about Memsight here, or just go straight to the App Store!
Friday, November 15, 2019
Fractal Friday! 2019.11.15
This week I'm beginning a new series of postings, to celebrate the implementation of a fractal renderer in our flagship product - Fractal Friday!
Click on each image to see it full size. These are window captures at screen resolution; our final product will also support higher resolutions and larger sizes.
This first collection was produced from early prototype implementations of our renderer - four regular Julia set fractals, and this Mandelbrot set image:
A variety of modes of color mapping, starting values, and iterative depths were used - these options will be interactive features of the product.
Every Friday we'll post more! It's an endless area to explore - both the mathematical worlds of these equations, and the aesthetic possibilities of color mappings and renderings.
Feel free to follow Mathaesthetics on social media (Twitter, Instagram, Facebook), or follow this blog's RSS feed for more. Happy First Fractal Friday!
Click on each image to see it full size. These are window captures at screen resolution; our final product will also support higher resolutions and larger sizes.
This first collection was produced from early prototype implementations of our renderer - four regular Julia set fractals, and this Mandelbrot set image:
A variety of modes of color mapping, starting values, and iterative depths were used - these options will be interactive features of the product.
Every Friday we'll post more! It's an endless area to explore - both the mathematical worlds of these equations, and the aesthetic possibilities of color mappings and renderings.
Feel free to follow Mathaesthetics on social media (Twitter, Instagram, Facebook), or follow this blog's RSS feed for more. Happy First Fractal Friday!
Tuesday, November 12, 2019
Polar graph rendering
More images from our flagship product prototype... polar graph rendering is in! Here are a few results of prototype output. These examples all use the zoom iterator to re-draw the graph multiple times, and I've also now hooked up color iterators used to render the plot lines. This one iterates the color's brightness from dark blue toward white as the renderer re-draws at slightly increasing zoom factor:
The next two, plotting different functions, both use a hue iterator to shift the HSV color angle with each iteration:
Next stop: fractals!
The next two, plotting different functions, both use a hue iterator to shift the HSV color angle with each iteration:
Next stop: fractals!
Thursday, November 7, 2019
Prototype images - fun with iterator objects
Here are some screen captures (also on our Instagram and Facebook feeds) from the flagship work-in-progress.
Today I was working on the idea of an iterator object which is an abstraction of repeated drawing with some incremental parameter change. The prototype has two iterator objects applied - one applies a gradual zoom to the target layer, while the other gradually shifts the origin (including a slight multiplier that increases with each iteration, so the origin is actually moving in a gentle exponential curve).
I like the results with each layer, but the really cool thing is that the iterator objects applied in each case are identical - so there's a clean separation of the concept from the underlying rendering mechanism. The first image is a cartesian function plot (it's an f(x) = x^3 + sin(x^3) function, with some coefficients).
The second image is just a set of few shapes (three circles, two ellipses, two line segments). The iterator objects produce the repeated results in each rendering.
Below are few more images of these two renderings from different zoom levels.
Much more to come!
Today I was working on the idea of an iterator object which is an abstraction of repeated drawing with some incremental parameter change. The prototype has two iterator objects applied - one applies a gradual zoom to the target layer, while the other gradually shifts the origin (including a slight multiplier that increases with each iteration, so the origin is actually moving in a gentle exponential curve).
I like the results with each layer, but the really cool thing is that the iterator objects applied in each case are identical - so there's a clean separation of the concept from the underlying rendering mechanism. The first image is a cartesian function plot (it's an f(x) = x^3 + sin(x^3) function, with some coefficients).
The second image is just a set of few shapes (three circles, two ellipses, two line segments). The iterator objects produce the repeated results in each rendering.
Below are few more images of these two renderings from different zoom levels.
Much more to come!
Sunday, November 3, 2019
This venture
Mathaesthetics is the name of a new venture at the intersection of technology and creativity.
The Mathaesthetics product development vision centers on two unique and original desktop applications, one for visual arts and one for music and audio production. Previews and screenshots will be forthcoming in early 2020. While these major flagship products are in development, some games and utilities for mobile devices are in the works, the first of which will be launched this month.
There is also a more general area of inquiry that is central to the Mathaesthetics mission: the blending of the formal/technical with the expressive/creative. This website and our social media channels will serve as both aggregator and original source for writings, art, research, and news on the synthesis of work and experience across the domains of mathematics and aesthetics.
I will also be sharing some more pragmatic technical experiences in the Mathaesthetics blog, typically focused on development for Mac OS X / iOS / iPadOS and related technologies (Swift, Objective-C, etc.), and sometimes on other technologies and topics of software architecture.
Whatever brought you to this page, I hope you find something of value here, and welcome you to this venture.
Christopher Corbell
Creative Technologist and Founder
Mathaesthetics
Washougal, Washington
The Mathaesthetics product development vision centers on two unique and original desktop applications, one for visual arts and one for music and audio production. Previews and screenshots will be forthcoming in early 2020. While these major flagship products are in development, some games and utilities for mobile devices are in the works, the first of which will be launched this month.
There is also a more general area of inquiry that is central to the Mathaesthetics mission: the blending of the formal/technical with the expressive/creative. This website and our social media channels will serve as both aggregator and original source for writings, art, research, and news on the synthesis of work and experience across the domains of mathematics and aesthetics.
I will also be sharing some more pragmatic technical experiences in the Mathaesthetics blog, typically focused on development for Mac OS X / iOS / iPadOS and related technologies (Swift, Objective-C, etc.), and sometimes on other technologies and topics of software architecture.
Whatever brought you to this page, I hope you find something of value here, and welcome you to this venture.
Christopher Corbell
Creative Technologist and Founder
Mathaesthetics
Washougal, Washington
Subscribe to:
Posts (Atom)