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()
|
||||
pathToDraw.move(to: fromBase.position)
|
||||
// pathToDraw.addLine(to: toBase.position)
|
||||
pathToDraw.addCurve(
|
||||
to: toBase.position,
|
||||
control1: CGPoint(x: xControll1, y: yControll1),
|
||||
@ -51,13 +50,13 @@ class Way: GKEntity {
|
||||
static var wayDelta: CGFloat = 5
|
||||
|
||||
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)
|
||||
return x
|
||||
}
|
||||
|
||||
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)
|
||||
return y
|
||||
}
|
||||
|
@ -183,24 +183,25 @@ class CElement3: CenterElementProtocol {
|
||||
var id: Int = 3
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -260,24 +261,25 @@ class CElement4: CenterElementProtocol {
|
||||
var id: Int = 4
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -337,24 +339,25 @@ class CElement5: CenterElementProtocol {
|
||||
var id: Int = 5
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -414,24 +417,25 @@ class CElement6: CenterElementProtocol {
|
||||
var id: Int = 6
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -766,24 +770,25 @@ class CElement11: CenterElementProtocol {
|
||||
var id: Int = 11
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -843,24 +848,25 @@ class CElement12: CenterElementProtocol {
|
||||
var id: Int = 12
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -920,24 +926,25 @@ class CElement13: CenterElementProtocol {
|
||||
var id: Int = 13
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
@ -997,24 +1004,25 @@ class CElement14: CenterElementProtocol {
|
||||
var id: Int = 14
|
||||
|
||||
required init(frame: CGRect) {
|
||||
let delta = (frame.maxY - frame.minY) * 0.15
|
||||
self.centerBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.midX,
|
||||
y: frame.minY
|
||||
y: frame.minY + delta
|
||||
)
|
||||
)
|
||||
|
||||
self.leftBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.minX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
|
||||
self.rightBase = Base(
|
||||
position: CGPoint(
|
||||
x: frame.maxX,
|
||||
y: frame.maxY
|
||||
y: frame.maxY - delta
|
||||
)
|
||||
)
|
||||
self.bases.append(centerBase)
|
||||
|
Loading…
Reference in New Issue
Block a user