Skip to content

PriyamDutta/SolarSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solar System

A planetary animated UI with intractable planets in their respective orbits in swift.

alt tag

Configure SolarView

public struct SolarConfiguration {
    let planetsCount: Int
    let orbitColor: UIColor
    let orbitDistance: CGFloat
    let planets: [Planet]? = nil
}

Delegation

public protocol SolarViewDelegate: AnyObject {
    func didBeginTouchPlanet(planet: Planet)
    func didMovingPlanet(planet: Planet)
    func didFinishTouchPlanet(planet: Planet)
}

Configure Planet

struct PlanetConfig {
    let id: String
    let radius: CGFloat
    let arcRadius: CGFloat
    let arcCenter: CGPoint
    let revolutionSpeed: CGFloat
    let orbitPath: UIBezierPath
    let isClockwise: Bool
    let color: UIColor
}

Initilization

func createSolarSystem() {
        let config = SolarConfiguration(planetsCount: 8, orbitColor: .systemBlue, orbitDistance: 25)
        let solarView = SolarView(frame: CGRect(x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.width), configuration: config)
        solarView.center = self.view.center
        solarView.delegate = self
        solarView.backgroundColor = .black
        self.solarView = solarView
        self.view.addSubview(solarView)
    }

Deallocation

self.solarView.destroy()

About

A planetary animated UI with intractable planets in their respective orbits.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages