-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlinkCircleVM.swift
More file actions
33 lines (29 loc) · 913 Bytes
/
Copy pathBlinkCircleVM.swift
File metadata and controls
33 lines (29 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// BlinkCircleVM.swift
// AnimationExamples
//
// Created by Esat Gözcü on 2023/03/14.
//
import SwiftUI
class BlinkCircleVM : ObservableObject {
var startSize = 0.2
var endSize = 2.0
var animTime : Double = 0.05
@Published var currentSize = 0.2
@Published var viewID = 0
@Published var rowCount : Int = 2
func calculateOffsetX(width: CGFloat, i: Int) -> CGFloat{
let onePiece = Double(width/Double(rowCount))
let result = onePiece*Double(i%Int(rowCount))
return CGFloat(result)
}
func calculateOffsetY(size: CGSize, i: Int) -> CGFloat{
let onePiece = Int(size.width/Double(rowCount))
let result = onePiece*Int(i/Int(rowCount))
let startPosition = Int((size.height/2) - (size.width/2))
return CGFloat(result + startPosition)
}
func getItemSize()->Int{
return rowCount*rowCount
}
}