Skip to content

Commit 64045f7

Browse files
author
Oleksandr Glagoliev
committed
Improve Demo
1 parent a3e2c0d commit 64045f7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Demo/Demo/VoronoiView.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,21 @@ class VoronoiView: UIView {
6262
size: Size(width: Double(bounds.width) - 100, height: Double(bounds.height) - 100)
6363
)
6464
// ----------------------------------------------------
65-
curTest = (curTest) % testCases.count
66-
let sites = testCases[curTest]
67-
curTest += 1
65+
// curTest = (curTest) % testCases.count
66+
// let sites = testCases[curTest]
67+
// curTest += 1
68+
// diagram = Diagram()
69+
//
70+
// fs.compute(sites: sites, diagram: &diagram, clippingRect: clippingRect)
71+
// setNeedsDisplay()
72+
// ----------------------------------------------------
73+
let sites = randomSites(500, xRange: 50..<Double(bounds.width) - 100, yRange: 50..<Double(bounds.height) - 100)
6874
diagram = Diagram()
6975

7076
fs.compute(sites: sites, diagram: &diagram, clippingRect: clippingRect)
7177
setNeedsDisplay()
7278
// ----------------------------------------------------
79+
7380

7481

7582
// var site = gesture.location(in: self).point
@@ -127,17 +134,17 @@ class VoronoiView: UIView {
127134
context.drawLine(
128135
from: o.cgPoint,
129136
to: d.cgPoint,
130-
color: UIColor.black.withAlphaComponent(1), lineWidth: 2.0
137+
color: UIColor.black.withAlphaComponent(0.1), lineWidth: 2.0
131138
)
132139
context.drawVertex(cell.site)
133140

134141
he = he?.next
135142
finish = he === cell.outerComponent
136143
}
137144
// context.drawPolygonFromCCWPoints(points, color: (cell.site.satellite as! UIColor).withAlphaComponent(0.2))
138-
context.drawPolygonFromCCWPoints(points, color: UIColor.random().withAlphaComponent(0.2))
145+
// context.drawPolygonFromCCWPoints(points, color: UIColor.random().withAlphaComponent(0.2))
139146

140-
let path = UIBezierPath.roundedCornersPath(points.map { $0.cgPoint }, 10)
147+
let path = UIBezierPath.roundedCornersPath(points.map { $0.cgPoint }, 40)
141148
context.addPath(path.cgPath)
142149
context.drawPath(using: .stroke)
143150
}

0 commit comments

Comments
 (0)