OSDN Git Service

Damageに問題があるときのログを詳細にした
[kcd/KCD.git] / KCD / Graphics.swift
1 //
2 //  Graphics.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/03/01.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 func polygon(_ point: () -> [NSPoint]) -> NSBezierPath? {
12     let points = point()
13     let count = points.count
14     guard count > 2 else { return nil }
15     let path = NSBezierPath()
16     path.move(to: points[0])
17     points[1..<count].forEach { path.line(to: $0) }
18     path.close()
19     
20     return path
21 }
22 func polyline(_ point: () -> [NSPoint]) -> NSBezierPath? {
23     let points = point()
24     let count = points.count
25     guard count > 1 else { return nil }
26     let path = NSBezierPath()
27     path.move(to: points[0])
28     points[1..<count].forEach { path.line(to: $0) }
29     
30     return path
31 }
32 func multiline(_ lines: () -> [(NSPoint, NSPoint)]) -> NSBezierPath? {
33     let path = NSBezierPath()
34     lines().forEach {
35         path.move(to: $0.0)
36         path.line(to: $0.1)
37     }
38     return path
39 }