
Show HN: Primitive for macOS - fogleman
https://primitive.lol/
======
fogleman
About two months ago I shared my "primitive" project and it was well received:
[https://news.ycombinator.com/item?id=12539109](https://news.ycombinator.com/item?id=12539109)

As a result, I decided to follow through and make more of it. So today I am
announcing Primitive for macOS, now available on the Mac App Store.

The core is still implemented in Go. The GUI is written in Objective-C
(haven't bothered to learn Swift yet!) and communicates with the Go process
over stdin/stdout via NSTask and NSPipe. The rendering is done on the front-
end; the backend just sends shape coordinates and such.

I spent a lot of time fleshing out the GUI layout to make it as simple yet
powerful as possible. I hope you find it to be intuitive and I hope that you
are pleased with the resulting images. I look forward to seeing what people do
with the app. :)

Let me know if you have any questions!

~~~
hftf
I wonder if it’s possible to turn this into a video filter.

~~~
ultrafez
I don't see why that wouldn't be possible, it likely wouldn't run in realtime
though.

~~~
amelius
Well, a problem could be that you get a lot of noise if all the frames are
rendered independently.

You need a constraint that guarantees for example that without any changes in
the video, you won't see any changing primitives.

~~~
JoshTriplett
> Well, a problem could be that you get a lot of noise if all the frames are
> rendered independently.

The site shows an example of what a still image looks like if rendered with
the same parameters several times; it provides an interesting animated effect.
I think that might produce an interesting animation style.

But for a more consistent style between frames, it'd help to have a way to
seed the RNG consistently.

~~~
amelius
I think there is more to it than just seeding the RNG consistently.

For example: what if you have a minor change in the area of the screen that
got the first primitive (and hence used the first few RNG numbers)? Then all
the remaining primitives will use different RNG numbers.

I think the problem becomes more difficult: you want to find the primitives
that result in the minimal change wrt the previous frame.

------
blacksmith_tb
You had me at SVG output - I have a Watercolorbot[1] and a better workflow to
convert images to simplified (but still interesting) SVGs will be great.

1: [http://watercolorbot.com/](http://watercolorbot.com/)

~~~
fogleman
Whoa, what a great application of this. :) My buddy tried doing something
similar with his CNC machine.

------
jonknee
This is great! I put together a page of before/after comparisons with some
photos I tested with:

[http://www.jongales.com/timeshift/primitive/](http://www.jongales.com/timeshift/primitive/)

~~~
jplahn
Two comments: 1\. The original photos are beautiful. What equipment are you
using? We're extremely spoiled here in the PNW! 2\. Have you considered
printing any of the Primitive forms out and displaying them?

~~~
jonknee
Too late to edit my comment, but I added a couple more photos if you want to
check them out. A night scene that I thought would be a tough test (hard to do
stars!) and some columnar basalt that turned out great.

~~~
jplahn
That Rainier picture is incredible!

~~~
jonknee
Thanks, it was an early season night (Milky Way is only visible in the Summer
here) and it started cloudy. I stuck it out and got lucky. That really bright
point above the mountain is Mars, pretty neat!

------
cobbzilla
I have let it run for ~40k shapes on a very hi-res photograph of my adorable
children in front of a stream, and it is a beautiful thing to watch the
resolution unfold. I love that I end up with a vector graphic at the end.

I have a crazy question: It generally seems to fill in detail uniformly,
across the entire image. It's like the entire thing is coming slowly into
focus. At some point, I'd prefer the algorithm to care a little less about
filling in detail on the background, and focus more detail on the "items of
interest" in a scene, the high-contrast regions or something. Perhaps even to
have some manual control over it. Would this be possible? I am a total amateur
when it comes to image analysis, btw, just thought it would be cool.

~~~
myhf
That would be a great feature. You could spend 500 shapes on the background
and 500 on the foreground, instead of needing 3000 to get high detail
everywhere.

It would be possible to do that in the app if you could restrict new shapes to
a specified region.

------
mpolichette
Cool, I'm looking forward to giving this a try... I've always been a big fan
of geometric art.

I do wish I could buy it from your site vs the App store... I've just had so
many be experiences w/ having to 'transfer my license' away from App store
purchases.

------
codazoda
This is cool.

I made something similar years ago. The primary motivation was my need to
print small resolution images in poster sizes when camera technology hadn't
gotten to the point they had high enough resolution.

Mine used transparent images as the "shapes" and then it would "stamp" the
shapes onto a larger image. It could use multiple shapes in a single image.

Here's an example.

[http://imgur.com/gallery/nUUo9](http://imgur.com/gallery/nUUo9)

Doesn't look nearly as nice, but maybe someone with more creatively than me
could create shapes that make it much more interesting. Anyone have any
interest in a library that does that?

------
wgx
Here's a JS version from (at least) a few years ago that's good fun to play
with:

[http://alteredqualia.com/visualization/evolve/](http://alteredqualia.com/visualization/evolve/)

~~~
fogleman
Seen that before. Cool from the evolutionary algorithm standpoint, but
Primitive produces nicer looking results in mere seconds. :) But we both were
inspired by the same original Mona Lisa project.

~~~
chii
is that because the mac version is native (vs js), or is the algorithm
different enough to matter?

------
jankovicsandras
Shameless plug: similar artistic effects can be achieved with ImageTracer,
however the algorithm is different. It's a Public Domain tracing and
vectorizing library, outputting SVG.

JavaScript
[https://github.com/jankovicsandras/imagetracerjs](https://github.com/jankovicsandras/imagetracerjs)
or Java
[https://github.com/jankovicsandras/imagetracerjava](https://github.com/jankovicsandras/imagetracerjava)
or "Android" Java
[https://github.com/jankovicsandras/imagetracerandroid](https://github.com/jankovicsandras/imagetracerandroid)

------
stefs
i write an app like this about once a year (usually a java cmdline
implementation).

to my embarrassment, i never got it _completely_ right. the last instalment
even provided statistics that could be used to compare the effectiveness of
different strategies and parameters.

the last recent one featured:

* classic genetic algorithm (population size etc) with different methods for selection and crossover

* dumb hill climbing

* the "additive" method described in OP's app

* switching of methods at certain points (i.e. switch to hill climbing if the genetic algorithm didn't improve things for a certain time)

* bitmap and svg output

* statistics output that can be plotted with a plotting library so you can compare the effectiveness of different strategies

* multithreading incl. tests to find out the sweet spot for the number of concurrent threads

~~~

i don't know why but i never really reached the point where my results were of
a comparable quality to roger alsings mona lisa or even alteredQualia's image
evolver
([http://alteredqualia.com/visualization/evolve/](http://alteredqualia.com/visualization/evolve/)).

well, soon it's time for the next attempt.

one interesting realisation: my desktop computer is about 10x as fast as the
raspberry pi 3 for this kind of CPU intensive work.

------
ridgeguy
FYI - My wife, who does collaging, just got Primitive off MAS, and she loves
it. She's running it on an older iMac. She's impatient, and will probably go
buy a MacPro in the morning. Thanks - I think...

~~~
fogleman
Haha, that's awesome, thanks for sharing the story.

------
lemming
This is really cool - just bought it. I'd like a good way to get photos from
the Photos app into it, either by sharing them or by directly accessing the
photo roll from within Primitive.

Great work!

~~~
fogleman
Good idea, I'll see what that would take to integrate with Photos.

------
tracker1
Man, that would be an awesome screensaver, far better than the picture
slideshows that are typically used...

------
thenomad
Very cool indeed!

I sadly have no Mac to run it on - will you be porting to other OSes (I'm
primarily Windows), or is this the same code as you shared on Github with a
UI?

~~~
mwambua
+1. Running linux here. It would be really cool if I could test this out.
Edit: Found that the core is on github
([https://github.com/fogleman/primitive](https://github.com/fogleman/primitive)).
All you need is go to run it.

------
olliewagner
I'd love to see this be able to handle batch input with automatic saving (then
I'd use it to style frames in a movie)!

~~~
fogleman
That's a good idea, I can consider it for a future release. :)

~~~
gkya
Guess until then imagemagick + command line primitive can do the business
(convert video to a series of images w/ IM, process with primitive, recreate
the video from processed images w/ IM).

------
tptacek
This is neato. Does the app make animated GIFs? If not, you should make it do
that!

~~~
wyldfire
Animated raster images depicting a sequence of overlaid primitive vector
shapes for a single input? Or just iterating the existing algorithm over a
video input?

~~~
nicky0
Both would be cool.

------
karolist
Cool project, best of luck. Off topic question: are you planning to focus more
in MAS, do you think it's still viable to make a living off it solo? (yes,
depends on COL and needs, still interested in your perspective)

~~~
fogleman
Not quitting my day job any time soon. :)

------
paws
Congrats on launching!

If you're able to do a follow up post in e.g. a month I'd enjoy reading!
Especially if you decide to sell directly I'd be curious how that fares vs the
App Store.

Thanks for sharing here, nice to see this.

------
stinkytaco
That's cool, I'm going to have to try it.

I'm a sucker for this kind of thing. Rotoscoping always fascinated me and I'm
still looking for something that converts photos to pencil drawings.

------
Poiesis
I love this and follow the Twitter bot.

One question: That seems like a really permissive license for a $9.99 app (I
realize GitHub's just got the core). Are you worried about someone cloning it?

One request: I don't know if it's possible, but in iOS Tweetbot the bot's
pictures show the unmodified picture first (requiring a swipe to see the bot's
work). It feels to me like it would be better to show the primitive version
first, but I realize this may not be feasible or universally preferred.

~~~
dancek
I think the majority of work here has been put into designing and implementing
the UI. A friend did something like the core a while back, in a couple of
days. I'm sure many others have and many others will.

I'd also think that app store copycats try and pick easy, profitable projects.
Just having the core implemented in Go would probably be a turn-off for many
of them.

I really appreciate keeping the core FLOSS and hope that it won't cause
problems for the author.

------
jwetzel1492
I just purchased! I'm not even sure what my use will be, but your work is both
mathematically interesting and aesthetically beautiful, and I wanted to
support it. :)

------
aikah
Nice, what algorithm is it using?

~~~
fogleman
Explained here: [https://github.com/fogleman/primitive#how-it-works-part-
ii](https://github.com/fogleman/primitive#how-it-works-part-ii)

~~~
aikah
Thanks, nice work.

------
andrecl
This app looks fantastic! I'm impressed by the various photos posted on
Primitive's twitter account:
[https://twitter.com/PrimitivePic](https://twitter.com/PrimitivePic)

On a separate note @fogleman, would be able to talk a little about how you
architected the app? I'm curious about how you've set up Objective-C
communication with Go using NSTask and NSPipe.

------
KennyCason
Oh wow, I'm impressed with the results you were able to obtain! I was able to
get similar results on my "genetic draw", but it looks like I have some
optimizing to do :)
[https://github.com/kennycason/genetic_draw](https://github.com/kennycason/genetic_draw)

~~~
KennyCason
I can't get over how awesome that flower rendering turned out. O_O

------
bugmango
As a designer, this is what I've waited for for a very long time. I've already
created tons of SVG photos and have started animating them in css. Super cool
effect!

Now some of you nerds need to tell me how I can animate the dash-array/dash-
offset animation with 2000 paths without it being so slow! :D

------
mianos
We are totally loving this at home. The kids love walking away as far as
possible and seeing how the details seems to come out. I have a picture here
where the boat on the water is a little triangle yet at a distance you would
swear the boat is very detailed. Money so well spent.

------
cyphar
I didn't realise the core of this was actually free software[1]. Maybe you
should include a link somewhere on the page you linked?

[1]:
[https://github.com/fogleman/primitive](https://github.com/fogleman/primitive)

------
jeffehobbs
Gorgeous! Saw this getting developed on Twitter and can't wait to give it a
spin. Insta-buy.

------
oliv__
I would love for someone to _primitive_ Google Street View.

Then make an open world game out if it.

------
Cyph0n
Oh, it's fogleman! I follow your work on GH dude, always on the lookout for a
new repo from you in my feed haha :)

Looks like a great tool to be honest, and the UI looks beautiful. Wish you the
best, and keep up the awesome work!

------
rlease
This is very cool. I had a nearly identical idea a few months ago (and somehow
missed your post the first time around) based around feature detection in
images, and this is way cooler than what I had envisioned.

------
azag0
I don't know how the algorithm works, but I noticed that already figures with
a very rough level of approximation are still almost unreckognizable from the
original when I defocus my sight.

------
kaizensoze
Very cool.

Just an FYI, the links at the top link to the current page instead of
sections.

~~~
fogleman
They scroll via javascript. I guess there could be hash fallbacks.

~~~
RussianCow
They don't scroll for me at all, they just reload the page. Firefox on Linux.
No errors in the console either.

~~~
fogleman
Yep, definitely doesn't work on Firefox. Thanks for the heads up.

------
richdougherty
A superellipse shape would be cool:
[https://en.wikipedia.org/wiki/Superellipse](https://en.wikipedia.org/wiki/Superellipse)

------
cobbzilla
I love this project, having some fun with it. Very slick, thank you!

------
leonatan
This reminds me, in art style, the output of the video game Another World.
With some tweaking, it should be possible to make very similar results.

------
snowwrestler
This might be a cool tool for people who make art quilts, to help visualize
different ways of assembling geometric shapes to create a picture.

------
jwn
I'm glad your charging for this. I took one look at the output and immediately
decided that it's something I would pay for!

Buying it now...

------
fizzbatter
This is really awesome! You should make a phone app (Android too please :)),
i'd happily pay for this to make wallpapers!

~~~
coldcode
If the algorithm could work well on a mobile device, this would make awesome
camera filters for something like Instagram, likely could make some $ or get
someone to buy it from you.

------
johncalvinyoung
Pretty much an insta-buy. I'm capable with Illustrator and Photoshop, but the
results of the algorithm are lovely.

------
datalus
Awesome work, I was just working on some image manipulation experiments in
Rust. Great for some inspiration :)

------
owly
How large of an image can this output? I'm interested for large murals. Nice
work!

~~~
sleepychu
If you're really asking about output, you're in luck! SVGs are infinitely
scalable without loss of quality.

[https://en.wikipedia.org/wiki/Scalable_Vector_Graphics#/medi...](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics#/media/File:Bitmap_VS_SVG.svg)

------
trymas
I'll be damned, I was starting to work on app with idea like this. Looks nice.

------
ForFreedom
.lol domain extension!

------
amelius
Nice, but the problem with this kind of effect is that when you zoom out
enough, you lose the effect and the original photo remains. (Just try it in
your browser on the demo page, by e.g. pressing ctrl minus).

------
SCAQTony
I just purchased this, thank you for posting it.

------
abakker
bought - going to see if the quadratics can be used to generate laser etching
paths to make wood burnings with a CNC.

------
hackr123
I would love to see this on Linux.

------
daveheq
Yay, now I know how to turn my beautiful photographs into hipster douchebag
minimalist logos and icons... thanks artfarts!

------
eximius
If I had a mac, I'd buy it.

------
fufjfkrmew22
Cool project. But please some attribution!

Here is the original concept, source included (2008):
[https://rogeralsing.com/2008/12/07/genetic-programming-
evolu...](https://rogeralsing.com/2008/12/07/genetic-programming-evolution-of-
mona-lisa/)

~~~
antirez
The algorithm used is actually very very different even if the results are
visually similar.

~~~
fogleman
Indeed!

~~~
RBerenguel
I did a simulated annealing version 5 or 6 years ago (so I could have a neat
Christmas card), and was surprisingly slow (well, I had a slower computer,
too). Congrats on making it fast and nice (and exporting in vectors, which is
something I didn't bother to even try!)

~~~
KennyCason
I found similar results in my simulations as well.

Even my genetic implementations were "slowish" both simple hill climbing
(single parent) and two parent with cross-over/mutation. Though, after seeing
this awesome implementation, I'm going to go do some work on improving mine.

~~~
RBerenguel
Good luck! I don't plan on revisiting mine for the time being (more interested
in some Scala stuff I have parked on the side)

~~~
KennyCason
Thanks. :) I wrote mine in Kotlin ("genetic_draw" on my GH). The best of both
worlds, fun side project + new language.

------
rasz_pl
Another World used that technique as means of compression, but it was done
manually by the creator (and almost made him go crazy, tons of work). I wonder
if this could be used as basis for modern image compressor.

Im blown away by fantastic effect from such a random algorithm, I was
expecting something classic like edge detection and image segmentation, at
least in the first stage of image creation.

------
wonks
Please consider removing "Very wow" from the homepage. That joke is old now
and if anything you'll lose sales.

~~~
fogleman
Well I also went with a .lol domain, so. :)

~~~
jakebasile
I didn't even know there was a .lol TLD. You made my day.

~~~
fogleman
Honestly I didn't either until I was looking for a domain for this. :)

------
macintux
Gotta be that guy. I'm afraid "totally unique" in the app description makes me
an unhappy camper. Quoting the estimable President Bartlet:

> "Unique" means "one of a kind." Something can't be very unique, nor can it
> be extremely historic.

Conversely, love the lol TLD.

~~~
DennisP
Here's a linguistics professor who disagrees:

> if a word denotes the end-point of some scale (as unique surely does), then
> it can be used — and will be used — in describing approximations to that
> end-point, using approximative expressions like almost and nearly. (If there
> are only two occurrences of X in the world, then each of these is nearly
> unique.) Then, of course, you can ask how close to the end-point something
> is by asking how X it is, and you can describe something that has very few
> competitors for being the one and only as very X, and you can describe
> something that has no competitors at all as entirely X.

> Back up. Some of you are objecting that unique does not denote the end-point
> of a scale, and you say that because unique is not used in mathematics that
> way. But it's a mistake to suppose, when we're talking about ordinary
> language, that the mathematical usage of terms takes priority over ordinary
> people's usage of them. Yes, in mathematical usage, unique is used
> "crisply", for 'one and only one' (and that's an important concept to have
> in mathematical contexts), but, frankly, this really doesn't have beans to
> do with how unique is used in ordinary English. Instead, the mathematical
> usage is a specialization, a refinement, of ordinary English in a technical
> context.

source:
[http://languagelog.ldc.upenn.edu/nll/?p=479](http://languagelog.ldc.upenn.edu/nll/?p=479)

bio: [http://web.stanford.edu/~zwicky/](http://web.stanford.edu/~zwicky/)

~~~
macintux
Bah. I'll take a fictional president over an expert any day. 2016 in a
nutshell.

~~~
DennisP
Funny. I'd managed to read "president" as "professor," googled it, and found a
fairly well-known physicist, which made my second quoted paragraph seem
especially relevant.
[https://en.wikipedia.org/wiki/Albert_Allen_Bartlett](https://en.wikipedia.org/wiki/Albert_Allen_Bartlett)

------
bjcubsfan
The Lenna image that is drawn is originally from a nude image in Playboy [1].
It causes me to associate your work with sexism and pornography. I'm sure not
everyone makes this association, but why not use a free stock image or a great
work of art for the demo?

[1] -
[https://en.wikipedia.org/wiki/Lenna#Controversy](https://en.wikipedia.org/wiki/Lenna#Controversy)

~~~
fogleman
Someone else mentioned this and I agreed, so I already replaced it before
seeing this comment. The Lenna image did make a good demo, but so do other
images.

~~~
pinum
The flower example is much less interesting than an image with a human face,
i.e Lenna.

It's a minor matter, but it's a shame you felt the need to remove the image
when it's so useful and relevant.

~~~
OOPMan
Until this thread I didn't even know this whole "issue" existed.

~~~
NTripleOne
It doesn't; as per usual it's just an SJW making a gratuitous leap to
associate an innocent thing with a bad thing.

