Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

theprizerevealed

macrumors regular
Original poster
Feb 26, 2016
183
12
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.
howdone.png
 
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: https://developer.apple.com/library/content/samplecode/Sketch/Introduction/Intro.html

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.
 
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
Code:
- (void)touchesBeganWithEvent:(NSEvent *)event;

and OSX "
Code:
 - (void)mouseDown:(NSEvent *)event;"

One would then draw the line between the points.

Here's an example of drawing text:

Code:
[(NSAttributedString *)attributedString drawInRect:CGRectMake(0, 0, size.width, size.height)];
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.