Generally how does this app accompish this ?

Discussion in 'iOS Programming' started by theprizerevealed, Apr 16, 2017.

  1. theprizerevealed macrumors member

    Joined:
    Feb 26, 2016
    #1
    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
     
  2. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    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.
     
  3. theprizerevealed thread starter macrumors member

    Joined:
    Feb 26, 2016
    #3
  4. bjet767 macrumors 6502a

    Joined:
    Oct 2, 2010
    #4
    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)];
    
     

Share This Page