fix gap between two crossed curves
This commit is contained in:
parent
ed764afc45
commit
ad9e970ef6
@ -28,7 +28,6 @@ class Way: GKEntity {
|
|||||||
|
|
||||||
let pathToDraw = CGMutablePath()
|
let pathToDraw = CGMutablePath()
|
||||||
pathToDraw.move(to: fromBase.position)
|
pathToDraw.move(to: fromBase.position)
|
||||||
// pathToDraw.addLine(to: toBase.position)
|
|
||||||
pathToDraw.addCurve(
|
pathToDraw.addCurve(
|
||||||
to: toBase.position,
|
to: toBase.position,
|
||||||
control1: CGPoint(x: xControll1, y: yControll1),
|
control1: CGPoint(x: xControll1, y: yControll1),
|
||||||
@ -51,13 +50,13 @@ class Way: GKEntity {
|
|||||||
static var wayDelta: CGFloat = 5
|
static var wayDelta: CGFloat = 5
|
||||||
|
|
||||||
static func computeX(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
static func computeX(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
||||||
let mix:CGFloat = Int.random(in: 0...1) == 1 ? -1/wayDelta : 1/wayDelta
|
let mix:CGFloat = Bool.random() ? -1/wayDelta : 1/wayDelta
|
||||||
let x = x1 + factor * (x2 - x1) + mix * -(y2-y1)
|
let x = x1 + factor * (x2 - x1) + mix * -(y2-y1)
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
static func computeY(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
static func computeY(x1: CGFloat, x2: CGFloat, y1: CGFloat, y2: CGFloat, factor: CGFloat) -> CGFloat {
|
||||||
let mix:CGFloat = Int.random(in: 0...1) == 1 ? -1/wayDelta : 1/wayDelta
|
let mix:CGFloat = Bool.random() ? -1/wayDelta : 1/wayDelta
|
||||||
let y = y1 + factor * (y2 - y1) + mix * (x2-x1)
|
let y = y1 + factor * (y2 - y1) + mix * (x2-x1)
|
||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
|
@ -183,24 +183,25 @@ class CElement3: CenterElementProtocol {
|
|||||||
var id: Int = 3
|
var id: Int = 3
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -260,24 +261,25 @@ class CElement4: CenterElementProtocol {
|
|||||||
var id: Int = 4
|
var id: Int = 4
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -337,24 +339,25 @@ class CElement5: CenterElementProtocol {
|
|||||||
var id: Int = 5
|
var id: Int = 5
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -414,24 +417,25 @@ class CElement6: CenterElementProtocol {
|
|||||||
var id: Int = 6
|
var id: Int = 6
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -766,24 +770,25 @@ class CElement11: CenterElementProtocol {
|
|||||||
var id: Int = 11
|
var id: Int = 11
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -843,24 +848,25 @@ class CElement12: CenterElementProtocol {
|
|||||||
var id: Int = 12
|
var id: Int = 12
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -920,24 +926,25 @@ class CElement13: CenterElementProtocol {
|
|||||||
var id: Int = 13
|
var id: Int = 13
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
@ -997,24 +1004,25 @@ class CElement14: CenterElementProtocol {
|
|||||||
var id: Int = 14
|
var id: Int = 14
|
||||||
|
|
||||||
required init(frame: CGRect) {
|
required init(frame: CGRect) {
|
||||||
|
let delta = (frame.maxY - frame.minY) * 0.15
|
||||||
self.centerBase = Base(
|
self.centerBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.midX,
|
x: frame.midX,
|
||||||
y: frame.minY
|
y: frame.minY + delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.leftBase = Base(
|
self.leftBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.minX,
|
x: frame.minX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.rightBase = Base(
|
self.rightBase = Base(
|
||||||
position: CGPoint(
|
position: CGPoint(
|
||||||
x: frame.maxX,
|
x: frame.maxX,
|
||||||
y: frame.maxY
|
y: frame.maxY - delta
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.bases.append(centerBase)
|
self.bases.append(centerBase)
|
||||||
|
Loading…
Reference in New Issue
Block a user