1 + 1
import SpriteKit
SKShapeNode(circleOfRadius: 10.0)
SKShapeNode(ellipseOf: CGSize(width: 10.0, height: 10.0))
SKShapeNode(ellipseOf: CGSize(width: 20.0, height: 10.0))
SKShapeNode(rectOf: CGSize(width: 10.0, height: 10.0))
SKShapeNode(rectOf: CGSize(width: 10.0, height: 10.0), cornerRadius: 3.0)
CGSize(width: 20.0, height: 10.0)
let line = CGMutablePath()
line.move(to: CGPoint(x: 0.0, y: 0.0))
line.addLine(to: CGPoint(x: 100.0, y: 0.0))
SKShapeNode(path: line)
let triangle = CGMutablePath()
triangle.move(to: CGPoint(x: 0.0, y: 0.0))
triangle.addLine(to: CGPoint(x: 100.0, y: 0.0))
triangle.addLine(to: CGPoint(x: 100.0, y: 100.0))
triangle.closeSubpath()
SKShapeNode(path: triangle)
let rectangle = SKShapeNode(rectOf: CGSize(width: 100.0, height: 50.0))
rectangle.fillColor = .white
rectangle.strokeColor = .red
rectangle.lineWidth = 10.0
rectangle.setScale(0.5)
rectangle.zRotation = 45.0 * CGFloat.pi / 180.0
extension BinaryFloatingPoint {
public static func radians(degrees: Self) -> Self {
degrees * Self.pi / Self(180.0)
}
public static func degrees(radians: Self) -> Self {
radians / Self.pi * Self(180.0)
}
}
rectangle.zRotation = CGFloat.radians(degrees: 45.0)
let arc = CGMutablePath()
arc.addArc(
center: .zero,
radius: 50.0,
startAngle: .radians(degrees: 180.0),
endAngle: .zero,
clockwise: true
)
SKShapeNode(path: arc)
let inner = SKShapeNode(rectOf: CGSize(width: 50.0, height: 50.0))
inner.zRotation = .radians(degrees: 45.0)
let outer = SKShapeNode(rectOf: CGSize(width: 100.0, height: 100.0))
outer.addChild(inner)
0 件のコメント:
コメントを投稿