Generally how does this app accompish this ?


macrumors regular
Original poster
Feb 26, 2016
I bought a nice little app for MacOS called MoleculeSketch; It lets you sketch molecular structures. So I'm wondering how might that code work generally? I would have some kind of premade background (an image maybe?) then another image of the letter 'C' which overlaps it? Is that how it might work?

I just want a general idea, I know you guys don't know the code there and I doubt the author would be willing to share.


macrumors 68040
Sep 2, 2008
I can't tell too much from the website but it seems like a specialized 2D drawing app. If you look into the app's documents I don't think you'll find simple raster graphics like a jpg. It will be some kind of data structure that stores the types and positions of all the molecules, bonds, etc. This is vector graphics. It might use a standard version of vector graphics or its own kind.

Apple has a sample drawing app called Sketch that you can download and inspect:

I don't think it's exactly a vector drawing app but probably will show some of the ideas of how 2D drawing is done.

I have a free 3D app from the app store called Molecules that animates 3D molecules; spinning enzymes and things like that. It uses OpenGL, which is completely different from 2D graphics.


macrumors 6502a
Oct 2, 2010
All of the charaters in the alphabet can be "painted" to the view as a graphic rather than text in either iOS or OSX. The lines are part of the normal drawing features of the view.

The line would start in iOS
- (void)touchesBeganWithEvent:(NSEvent *)event;
and OSX "
 - (void)mouseDown:(NSEvent *)event;"
One would then draw the line between the points.

Here's an example of drawing text:

[(NSAttributedString *)attributedString drawInRect:CGRectMake(0, 0, size.width, size.height)];