相关疑难解决方法(0)

用频率绘制正弦波?

我正在画一段正弦波:

let width = rect.width
let height = rect.height

let origin = CGPoint(x: width * (1 - graphWidth) / 2, y: height * 0.50)

let path = UIBezierPath()
path.move(to: origin)

for angle in stride(from: 5.0, through: 360.0, by: 5.0) {
    let x = origin.x + CGFloat(angle/360.0) * width * graphWidth
    let y = origin.y - CGFloat(sin(angle/180.0 * Double.pi)) * height * amplitude
    path.addLine(to: CGPoint(x: x, y: y))
}

Globals.sharedInstance.palleteGlowGreen.setStroke()
path.stroke()
Run Code Online (Sandbox Code Playgroud)

我怎么会:

  1. 绘制相同宽度的多个周期(现在为0-360)
  2. 动态更改数字1(周期数),以便您看到波浪挤压.

uibezierpath swift

2
推荐指数
1
解决办法
1203
查看次数

标签 统计

swift ×1

uibezierpath ×1