Skip to content

Commit 4ae2df6

Browse files
authored
Merge pull request #13 from cruisediary/feature-comet-color
Customize comet color
2 parents 02cb8ce + 6370fce commit 4ae2df6

File tree

7 files changed

+47
-26
lines changed

7 files changed

+47
-26
lines changed

Comets.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'Comets'
11-
s.version = '0.3.0'
11+
s.version = '0.3.1'
1212
s.summary = '☄️Comets: Animating Particles in Swift'
1313

1414
# This description is used to generate tags and improve search results.

Comets/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.3.0</string>
18+
<string>0.3.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
</dict>

Comets/Sources/Comet.swift

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
public struct Comet {
2-
public var startPoint: CGPoint
3-
public var endPoint: CGPoint
4-
public var lineColor: UIColor
2+
let startPoint: CGPoint
3+
let endPoint: CGPoint
4+
let lineColor: UIColor
5+
let cometColor: UIColor
56

6-
public init(startPoint: CGPoint, endPoint: CGPoint, lineColor: UIColor) {
7+
public init(
8+
startPoint: CGPoint,
9+
endPoint: CGPoint,
10+
lineColor: UIColor = UIColor.white.withAlphaComponent(0.2),
11+
cometColor: UIColor = UIColor.white
12+
) {
713
self.startPoint = startPoint
814
self.endPoint = endPoint
915
self.lineColor = lineColor
16+
self.cometColor = cometColor
1017
}
1118

1219
public var linePath: UIBezierPath {
@@ -45,9 +52,9 @@ public struct Comet {
4552
return emitter
4653
}
4754

48-
public var contents: Any? {
55+
private var contents: Any? {
4956
let cometLayer = CAGradientLayer()
50-
cometLayer.colors = [UIColor.white.withAlphaComponent(0.0).cgColor, UIColor.white.cgColor]
57+
cometLayer.colors = [cometColor.withAlphaComponent(0.0).cgColor, cometColor.cgColor]
5158
cometLayer.cornerRadius = 0.25
5259
cometLayer.frame = CGRect(x: 0, y: 0, width: 80, height: 0.5)
5360
cometLayer.locations = [0.0, 1.0]

CometsTests/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>BNDL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.3.0</string>
18+
<string>0.3.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>1</string>
2121
</dict>

Example/Example/ViewController.swift

+14-7
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,32 @@ class ViewController: UIViewController {
3737
let height = view.bounds.height
3838
let comets = [Comet(startPoint: CGPoint(x: 100, y: 0),
3939
endPoint: CGPoint(x: 0, y: 100),
40-
lineColor: UIColor.white.withAlphaComponent(0.2)),
40+
lineColor: UIColor.red.withAlphaComponent(0.2),
41+
cometColor: UIColor.red),
4142
Comet(startPoint: CGPoint(x: 0.4 * width, y: 0),
4243
endPoint: CGPoint(x: width, y: 0.8 * width),
43-
lineColor: UIColor.white.withAlphaComponent(0.2)),
44+
lineColor: UIColor.red.withAlphaComponent(0.2),
45+
cometColor: UIColor.red),
4446
Comet(startPoint: CGPoint(x: 0.8 * width, y: 0),
4547
endPoint: CGPoint(x: width, y: 0.2 * width),
46-
lineColor: UIColor.white.withAlphaComponent(0.2)),
48+
lineColor: UIColor.red.withAlphaComponent(0.2),
49+
cometColor: UIColor.red),
4750
Comet(startPoint: CGPoint(x: width, y: 0.2 * height),
4851
endPoint: CGPoint(x: 0, y: 0.25 * height),
49-
lineColor: UIColor.white.withAlphaComponent(0.2)),
52+
lineColor: UIColor.red.withAlphaComponent(0.2),
53+
cometColor: UIColor.red),
5054
Comet(startPoint: CGPoint(x: 0, y: height - 0.8 * width),
5155
endPoint: CGPoint(x: 0.6 * width, y: height),
52-
lineColor: UIColor.white.withAlphaComponent(0.2)),
56+
lineColor: UIColor.red.withAlphaComponent(0.2),
57+
cometColor: UIColor.red),
5358
Comet(startPoint: CGPoint(x: width - 100, y: height),
5459
endPoint: CGPoint(x: width, y: height - 100),
55-
lineColor: UIColor.white.withAlphaComponent(0.2)),
60+
lineColor: UIColor.red.withAlphaComponent(0.2),
61+
cometColor: UIColor.red),
5662
Comet(startPoint: CGPoint(x: 0, y: 0.8 * height),
5763
endPoint: CGPoint(x: width, y: 0.75 * height),
58-
lineColor: UIColor.white.withAlphaComponent(0.2))]
64+
lineColor: UIColor.red.withAlphaComponent(0.2),
65+
cometColor: UIColor.red)]
5966

6067
// draw track and animate
6168
for comet in comets {

Example/Podfile.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
PODS:
2-
- Comets (0.3.0)
2+
- Comets (0.3.1)
33
- Gradients (0.3.0)
44
- SnapKit (5.0.0)
55

@@ -18,7 +18,7 @@ EXTERNAL SOURCES:
1818
:path: "../"
1919

2020
SPEC CHECKSUMS:
21-
Comets: 80ad7341f67f2743b5f8bdcfaf299956b9840d57
21+
Comets: ff75eb4658d612af66073bf9fcf6e8bef274817b
2222
Gradients: d7e1be639692b86577616ee55ea96f54fb5f1de1
2323
SnapKit: fd22d10eb9aff484d79a8724eab922c1ddf89bcf
2424

README.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,32 @@ let width = view.bounds.width
2020
let height = view.bounds.height
2121
let comets = [Comet(startPoint: CGPoint(x: 100, y: 0),
2222
endPoint: CGPoint(x: 0, y: 100),
23-
lineColor: UIColor.white.withAlphaComponent(0.2)),
23+
lineColor: UIColor.white.withAlphaComponent(0.2),
24+
cometColor: UIColor.white),
2425
Comet(startPoint: CGPoint(x: 0.4 * width, y: 0),
2526
endPoint: CGPoint(x: width, y: 0.8 * width),
26-
lineColor: UIColor.white.withAlphaComponent(0.2)),
27+
lineColor: UIColor.white.withAlphaComponent(0.2),
28+
cometColor: UIColor.white),
2729
Comet(startPoint: CGPoint(x: 0.8 * width, y: 0),
2830
endPoint: CGPoint(x: width, y: 0.2 * width),
29-
lineColor: UIColor.white.withAlphaComponent(0.2)),
31+
lineColor: UIColor.white.withAlphaComponent(0.2),
32+
cometColor: UIColor.white),
3033
Comet(startPoint: CGPoint(x: width, y: 0.2 * height),
3134
endPoint: CGPoint(x: 0, y: 0.25 * height),
32-
lineColor: UIColor.white.withAlphaComponent(0.2)),
35+
lineColor: UIColor.white.withAlphaComponent(0.2),
36+
cometColor: UIColor.white),
3337
Comet(startPoint: CGPoint(x: 0, y: height - 0.8 * width),
3438
endPoint: CGPoint(x: 0.6 * width, y: height),
35-
lineColor: UIColor.white.withAlphaComponent(0.2)),
39+
lineColor: UIColor.white.withAlphaComponent(0.2),
40+
cometColor: UIColor.white),
3641
Comet(startPoint: CGPoint(x: width - 100, y: height),
3742
endPoint: CGPoint(x: width, y: height - 100),
38-
lineColor: UIColor.white.withAlphaComponent(0.2)),
43+
lineColor: UIColor.white.withAlphaComponent(0.2),
44+
cometColor: UIColor.white),
3945
Comet(startPoint: CGPoint(x: 0, y: 0.8 * height),
4046
endPoint: CGPoint(x: width, y: 0.75 * height),
41-
lineColor: UIColor.white.withAlphaComponent(0.2))]
47+
lineColor: UIColor.white.withAlphaComponent(0.2),
48+
cometColor: UIColor.white)]
4249

4350
// draw line track and animate
4451
for comet in comets {
@@ -62,7 +69,7 @@ pod "Comets"
6269

6370
### Carthage
6471
```
65-
github "cruisediary/Comets" ~> 0.3.0
72+
github "cruisediary/Comets" ~> 0.3.1
6673
```
6774

6875
## ❤️ Contribution

0 commit comments

Comments
 (0)