Permalink
Browse files

Initial Commit.

  • Loading branch information...
Ramsundar Shandilya
Ramsundar Shandilya committed Nov 4, 2015
1 parent 31041fc commit 2338b546456578e80789988305733e6928a52be9
@@ -12,6 +12,8 @@
5B61657C1BCE7FAD008EB160 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5B61657A1BCE7FAD008EB160 /* Main.storyboard */; };
5B61657E1BCE7FAD008EB160 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5B61657D1BCE7FAD008EB160 /* Assets.xcassets */; };
5B6165811BCE7FAD008EB160 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5B61657F1BCE7FAD008EB160 /* LaunchScreen.storyboard */; };
5B61658A1BCE801A008EB160 /* BezierView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6165881BCE801A008EB160 /* BezierView.swift */; };
5B61658B1BCE801A008EB160 /* CubicCurveAlgorithm.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B6165891BCE801A008EB160 /* CubicCurveAlgorithm.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -22,6 +24,8 @@
5B61657D1BCE7FAD008EB160 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5B6165801BCE7FAD008EB160 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5B6165821BCE7FAD008EB160 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5B6165881BCE801A008EB160 /* BezierView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BezierView.swift; sourceTree = "<group>"; };
5B6165891BCE801A008EB160 /* CubicCurveAlgorithm.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CubicCurveAlgorithm.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -54,6 +58,8 @@
5B6165751BCE7FAD008EB160 /* Bezier */ = {
isa = PBXGroup;
children = (
5B6165881BCE801A008EB160 /* BezierView.swift */,
5B6165891BCE801A008EB160 /* CubicCurveAlgorithm.swift */,
5B6165761BCE7FAD008EB160 /* AppDelegate.swift */,
5B6165781BCE7FAD008EB160 /* ViewController.swift */,
5B61657A1BCE7FAD008EB160 /* Main.storyboard */,
@@ -135,6 +141,8 @@
buildActionMask = 2147483647;
files = (
5B6165791BCE7FAD008EB160 /* ViewController.swift in Sources */,
5B61658A1BCE801A008EB160 /* BezierView.swift in Sources */,
5B61658B1BCE801A008EB160 /* CubicCurveAlgorithm.swift in Sources */,
5B6165771BCE7FAD008EB160 /* AppDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -247,6 +255,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Bezier/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ymedialabs.Bezier;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -258,6 +267,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Bezier/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ymedialabs.Bezier;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -283,6 +293,7 @@
5B6165871BCE7FAD008EB160 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
@@ -1,33 +1,39 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appIcon-58.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appIcon-87.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appIcon-80.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appIcon-121.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appIcon-120.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "appIcon-180.png",
"scale" : "3x"
}
],
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "iPhone 6.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "iPhone 6@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "iPhone 6@2x-1.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8150" systemVersion="15A204g" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8122"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
@@ -13,15 +15,32 @@
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="grid_bg" translatesAutoresizingMaskIntoConstraints="NO" id="VlZ-vV-MS7">
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<animations/>
</imageView>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="VlZ-vV-MS7" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leadingMargin" constant="-20" id="RSc-ZA-pP8"/>
<constraint firstAttribute="trailingMargin" secondItem="VlZ-vV-MS7" secondAttribute="trailing" constant="-20" id="UDQ-Ud-4Ov"/>
<constraint firstItem="xb3-aO-Qok" firstAttribute="top" secondItem="VlZ-vV-MS7" secondAttribute="bottom" id="fSj-5F-pSY"/>
<constraint firstItem="VlZ-vV-MS7" firstAttribute="top" secondItem="Llm-lL-Icb" secondAttribute="bottom" constant="-20" id="ySa-hY-NMR"/>
</constraints>
</view>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
<point key="canvasLocation" x="52.5" y="374.5"/>
</scene>
</scenes>
<resources>
<image name="grid_bg" width="667" height="375"/>
</resources>
</document>
@@ -1,25 +1,58 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6211" systemVersion="14A298i" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9059" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6204"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9049"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="target" sceneMemberID="viewController">
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Bezier" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="grid_bg" translatesAutoresizingMaskIntoConstraints="NO" id="Qjc-ae-qwX">
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
<animations/>
</imageView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="RY3-hh-ORx" customClass="BezierView" customModule="Bezier" customModuleProvider="target">
<rect key="frame" x="20" y="40" width="627" height="315"/>
<animations/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</view>
</subviews>
<animations/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Qjc-ae-qwX" secondAttribute="trailing" id="2bF-3f-udv"/>
<constraint firstAttribute="leadingMargin" secondItem="RY3-hh-ORx" secondAttribute="leading" id="6cz-cq-MYs"/>
<constraint firstItem="Qjc-ae-qwX" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="BWh-hD-oz2"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="Qjc-ae-qwX" secondAttribute="bottom" id="GUf-lH-Wfi"/>
<constraint firstAttribute="trailingMargin" secondItem="RY3-hh-ORx" secondAttribute="trailing" id="Knp-Ze-8NG"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="RY3-hh-ORx" secondAttribute="bottom" constant="20" id="bf9-bf-HDN"/>
<constraint firstItem="RY3-hh-ORx" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="20" id="n7P-Fc-JBO"/>
<constraint firstItem="Qjc-ae-qwX" firstAttribute="top" secondItem="y3c-jy-aDJ" secondAttribute="bottom" constant="-20" id="qZi-Ya-6nb"/>
</constraints>
</view>
<simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina47"/>
<connections>
<outlet property="firstBezierView" destination="RY3-hh-ORx" id="LFR-NP-2NZ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="299.5" y="374.5"/>
</scene>
</scenes>
<resources>
<image name="grid_bg" width="667" height="375"/>
</resources>
</document>
View
@@ -0,0 +1,103 @@
//
// BezierView.swift
// Bezier
//
// Created by Ramsundar Shandilya on 10/14/15.
// Copyright © 2015 Y Media Labs. All rights reserved.
//
import UIKit
import Foundation
protocol BezierViewDataSource: class {
func bezierViewDataPoints(bezierView: BezierView) -> [CGPoint]
}
class BezierView: UIView {
//MARK: Public members
weak var dataSource: BezierViewDataSource?
var lineColor = UIColor(red: 233.0/255.0, green: 98.0/255.0, blue: 101.0/255.0, alpha: 1.0)
var animates = true
//MARK: Private members
private var dataPoints: [CGPoint]? {
return self.dataSource?.bezierViewDataPoints(self)
}
private let cubicCurveAlgorithm = CubicCurveAlgorithm()
override func layoutSubviews() {
super.layoutSubviews()
self.layer.sublayers?.forEach({ (layer: CALayer) -> () in
layer.removeFromSuperlayer()
})
drawSmoothLines()
drawPoints()
}
private func drawPoints(){
guard let points = dataPoints else {
return
}
for point in points {
let circleLayer = CAShapeLayer()
circleLayer.bounds = CGRect(x: 0, y: 0, width: 10, height: 10)
circleLayer.path = UIBezierPath(ovalInRect: circleLayer.bounds).CGPath
circleLayer.fillColor = UIColor(white: 248.0/255.0, alpha: 0.5).CGColor
circleLayer.position = point
circleLayer.shadowColor = UIColor.blackColor().CGColor
circleLayer.shadowOffset = CGSize(width: 0, height: 2)
circleLayer.shadowOpacity = 0.7
circleLayer.shadowRadius = 3.0
self.layer.addSublayer(circleLayer)
}
}
private func drawSmoothLines() {
guard let points = dataPoints else {
return
}
let controlPoints = cubicCurveAlgorithm.controlPointsFromPoints(points)
let linePath = UIBezierPath()
for var i=0; i<points.count; i++ {
let point = points[i];
if i==0 {
linePath.moveToPoint(point)
} else {
let segment = controlPoints[i-1]
linePath.addCurveToPoint(point, controlPoint1: segment.controlPoint1, controlPoint2: segment.controlPoint2)
}
}
let lineLayer = CAShapeLayer()
lineLayer.path = linePath.CGPath
lineLayer.fillColor = UIColor.clearColor().CGColor
lineLayer.strokeColor = lineColor.CGColor
lineLayer.lineWidth = 4.0
lineLayer.shadowColor = UIColor.blackColor().CGColor
lineLayer.shadowOffset = CGSize(width: 0, height: 8)
lineLayer.shadowOpacity = 0.5
lineLayer.shadowRadius = 6.0
self.layer.addSublayer(lineLayer)
}
}
Oops, something went wrong.

0 comments on commit 2338b54

Please sign in to comment.