Git Product home page Git Product logo

heisenberg's Introduction

Heisenberg

Heisenberg

CI Status Version License Platform

Heisenberg is an iOS UI library for creating / using chemical structures with written in Swift. It represent directional structures as using HeisenbergDirectionalStructure and just linear structures as using HeisenbergLinearStructure. You can change bonds between two elements as SingleBond, DoubleBond or TripleBond

HeisenbergDirectionalStructure is based on Graphand HeisenbergLinearStructure is based on SinglyLinkedList . You can create just x-axis linear structure with HeisenbergLinearStructure but with HeisenbergDirectionalStructure you can create / build what a Graph can do it.

HeisenbergLinearStructure

let heisenberg = HeisenbergLinearStructure(with: hidyrogen1, itemSize: 40)
heisenberg.linkTo(with: oxgen, with: .SingleBond) { (structure) in
    // structure callback
}.linkTo(with: hidyrogen2, with: .TripleBond) { (structure) in
       
}.linkTo(with: tAtom, with: .TripleBond) { (structure) in
   
}.linkTo(with: babyAtom, with: .TripleBond) { (structure) in

}
let board = HeisenbergBoard<String>(with: heisenberg, with: .cyan)
let boardView =  board.drawBoard()
view.addSubview(boardView)

Linear Structure

HeisenbergDirectionalStructure

let directional = HeisenbergDirectionalStructure(with: cAtom, itemSize: 50)
directional.linkWith(from: cAtom, to: nAtom, way: .next, bond: .SingleBond, bondColor: .black) { (structure) in

}.linkWith(from: nAtom, to: h1Atom, way: .crossUpForward, bond: .SingleBond, bondColor: .black) { (structure) in

}.linkWith(from: nAtom, to: h3Atom, way: .crossDownForward, bond: .SingleBond, bondColor: .black) { (structure) in

}.linkWith(from: nAtom, to: h2Atom, way: .next, bond: .SingleBond, bondColor: .black) { (structure) in

}.linkWith(from: cAtom, to: loveAtom, way: .downward, bond: .TripleBond, bondColor: .darkGray) { (structure) in

}

let board = HeisenbergBoard<String>(with: directional, with: .lightGray)
let boardView = board.drawBoard()
view.addSubview(boardView)

CH4 Directional

Directional Directional

Directional Directional

Bonding Between Atoms

You can tie two or more atoms with elements bonds. There's a list for bond way.

public enum StructuralWay: String{
    case upward = "up"
    case downward = "down"
    case next = "next"
    case angular = "angular"
    case crossDownForward = "cross_down_forward"
    case crossUpForward = "cross_up_forward"
    case crossDownBackward = "cross_back_down"
    case crossUpBackward = "cross_back_up"
}

HeisenbergBoard

HeisenbergBoard is a class for creating board to handle UI structure of chemical structures. You can pass any HeisenbergLinearStructure or HeisenbergDirectionalStructure and you must select a backgroundColor of the board. Then method drawBoard() returns a UIView for your structure.

let board = HeisenbergBoard<String>(with: directional, with: .lightGray)
let boardView = board.drawBoard()

Example

I've added bunch of test functions to generate a Heisenberg. You can check it out. To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

Heisenberg is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'Heisenberg'

Author

eliakorkmaz, [email protected]

License

Heisenberg is available under the MIT license. See the LICENSE file for more info.

heisenberg's People

Contributors

eliakorkmaz avatar

Stargazers

Acampbell avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.