sprag-cli 3.136.0 → 3.136.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/mac/SpragBar.swift +253 -246
  2. package/package.json +1 -1
@@ -949,264 +949,271 @@ func oval(_ c: NSPoint, _ rx: CGFloat, _ ry: CGFloat) { NSBezierPath(ovalIn: NSR
949
949
 
950
950
  func runner(_ sp: Sp, frame: Int, idle: Bool) -> NSImage {
951
951
  let size = NSSize(width: 31 * RUNNER_SCALE, height: 21.4 * RUNNER_SCALE)
952
- let img = NSImage(size: size, flipped: false) { _ in
953
- let t = NSAffineTransform(); t.scale(by: RUNNER_SCALE); t.concat()
954
- NSColor.black.setFill(); NSColor.black.setStroke()
955
- if sp.waddle { penguin(frame: frame, idle: idle); return true }
956
- if sp.fly > 0 { flyer(sp, frame: frame, idle: idle); return true }
957
- if sp.kind == 4 { frog(frame: frame, idle: idle); return true }
958
- if sp.kind == 5 || sp.kind == 6 { biped(chick: sp.kind == 6, frame: frame, idle: idle); return true }
959
- if sp.kind == 7 { ghost(frame: frame, idle: idle); return true }
960
- let k = idle ? STAND2 : GAL[frame % GAL.count]
961
- let n = GAL.count, ph = 2 * CGFloat.pi * CGFloat(frame % n) / CGFloat(n)
962
- let flex = CGFloat(k.flex * sp.flexAmp), lift = CGFloat(k.lift * sp.liftAmp) * 1.2
963
- let pitch = CGFloat(k.pitch * sp.pitchAmp) * .pi / 180
964
- let ground: CGFloat = 1.3
965
- let airborne = sp.x.contains("wings") && !idle // runs on air: the hooves never touch the ground
966
- let y0 = ground + sp.legH * LEGK * 0.86 + 0.9 + lift + (idle ? 0.12 * sin(ph) : 0) + (airborne ? 1.2 : 0)
967
- let c = NSPoint(x: 14.6, y: y0)
968
- let half = CGFloat(sp.len) * BODYK / 2 * (1 + 0.17 * flex)
969
- let arch = flex < 0 ? -flex * 1.5 : -flex * 0.3 // gathered: the back humps up; stretched: nearly flat
970
- let H = rot(NSPoint(x: c.x - half, y: y0), c, pitch), S = rot(NSPoint(x: c.x + half, y: y0), c, pitch)
971
- let M = rot(NSPoint(x: c.x, y: y0 + arch * 2), c, pitch)
972
- func leg(_ joint: NSPoint, _ a: (Double, Double), _ len: CGFloat, _ near: Bool) {
973
- let a1 = CGFloat(a.0) * .pi / 180, a2 = CGFloat(a.1) * .pi / 180
974
- let u = len * 0.5, l = len * 0.52
975
- let knee = NSPoint(x: joint.x + sin(a1) * u, y: joint.y - cos(a1) * u)
976
- var foot = NSPoint(x: knee.x + sin(a2) * l, y: knee.y - cos(a2) * l)
977
- foot.y = max(foot.y, airborne ? 1.1 : ground)
978
- let w = CGFloat(sp.legW) * (near ? 1 : 0.86)
979
- taper(joint, knee, 3.6 * w, 2.0 * w); taper(knee, foot, 2.0 * w, 1.35 * w)
980
- oval(NSPoint(x: foot.x + 0.35, y: foot.y + 0.05), 1.0 * w, 0.72 * w)
981
- }
982
- let sh = NSPoint(x: S.x - 0.4, y: S.y - CGFloat(sp.chest) * 0.35), hp = NSPoint(x: H.x + 0.5, y: H.y - CGFloat(sp.hip) * 0.3)
983
- // far legs
984
- leg(sh, k.ff, CGFloat(sp.legF) * LEGK, false); leg(hp, k.hf, CGFloat(sp.legH) * LEGK, false)
985
- // tail, trailing the body by a quarter stride
986
- let lag = sin(ph - .pi / 2), tb = rot(NSPoint(x: c.x - half - 0.6, y: y0 + 0.8), c, pitch)
987
- let tail = NSBezierPath(); tail.lineCapStyle = .round; tail.lineJoinStyle = .round
988
- switch sp.tail {
989
- case .curl:
990
- tail.lineWidth = 3.1
991
- tail.move(to: tb)
992
- tail.curve(to: NSPoint(x: tb.x + 1.0 + flex * 0.4, y: tb.y + 5.2 - flex * 0.6), controlPoint1: NSPoint(x: tb.x - 5.0, y: tb.y + 0.4), controlPoint2: NSPoint(x: tb.x - 5.0 + lag, y: tb.y + 6.2))
993
- tail.stroke()
994
- case .long, .tuft, .thin:
995
- tail.lineWidth = sp.tail == .tuft ? 1.4 : 1.6
996
- let end = NSPoint(x: tb.x - 7.0 + abs(flex) * 0.6, y: tb.y + 1.2 - flex * 2.4 + lag * 1.6)
997
- tail.move(to: tb)
998
- tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y - 1.4 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.2 + lag * 1.4))
999
- tail.stroke()
1000
- if sp.tail == .tuft { oval(end, 1.3, 1.1) }
1001
- case .bushy:
1002
- let end = NSPoint(x: tb.x - 7.2, y: tb.y - 0.4 - flex * 1.6 + lag * 1.2)
1003
- let b = NSBezierPath()
1004
- b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
1005
- b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y + 2.4 + lag * 0.6), controlPoint2: NSPoint(x: end.x + 2.4, y: end.y + 2.2))
1006
- b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.6, y: end.y - 1.8), controlPoint2: NSPoint(x: tb.x - 2.8, y: tb.y - 2.0 + lag * 0.6))
1007
- b.close(); b.fill()
1008
- case .stub:
1009
- oval(NSPoint(x: tb.x + 0.6, y: tb.y + 0.6), 1.5, 1.4)
1010
- case .none: break
1011
- case .curly: // a pig's corkscrew
1012
- let cc = NSPoint(x: tb.x - 1.2, y: tb.y + 1.0 + lag * 0.3), t = NSBezierPath(); t.lineWidth = 0.85; t.lineCapStyle = .round
1013
- t.move(to: NSPoint(x: tb.x + 0.2, y: tb.y + 0.2))
1014
- t.appendArc(withCenter: cc, radius: 0.95, startAngle: -20, endAngle: 300, clockwise: false); t.stroke()
1015
- case .ringed, .hang:
1016
- let end = sp.tail == .hang ? NSPoint(x: tb.x - 5.6, y: tb.y - 3.6 + lag * 0.9 - flex * 0.6) : NSPoint(x: tb.x - 7.0, y: tb.y + 0.4 - flex * 1.4 + lag * 1.2)
1017
- let b = NSBezierPath()
1018
- b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
1019
- b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.6 + lag * 0.5), controlPoint2: NSPoint(x: end.x + 2.0, y: end.y + 2.0))
1020
- b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.4, y: end.y - 1.6), controlPoint2: NSPoint(x: tb.x - 2.6, y: tb.y - 1.8 + lag * 0.5))
1021
- b.close(); b.fill()
1022
- if sp.tail == .ringed { // dark and pale rings: two gaps cut across the tail
1023
- NSGraphicsContext.current?.compositingOperation = .clear
1024
- for t in [0.42, 0.7] as [CGFloat] {
1025
- let m = NSPoint(x: tb.x + (end.x - tb.x) * t, y: tb.y + (end.y - tb.y) * t + 0.3)
1026
- line2(NSPoint(x: m.x + 0.5, y: m.y + 2.2), NSPoint(x: m.x - 0.5, y: m.y - 2.2), 0.6)
1027
- }
1028
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1029
- }
1030
- case .squirrel: // a big plume carried up over the back, its tip curling forward
1031
- let t = NSBezierPath(); t.lineWidth = 3.6; t.lineCapStyle = .round
1032
- let tip = NSPoint(x: tb.x + 0.8 + lag * 0.4, y: tb.y + 8.6 - flex * 0.6)
1033
- t.move(to: tb); t.curve(to: tip, controlPoint1: NSPoint(x: tb.x - 5.2, y: tb.y + 1.4), controlPoint2: NSPoint(x: tb.x - 4.4 + lag * 0.5, y: tb.y + 9.4)); t.stroke()
1034
- oval(tip, 1.8, 1.6)
1035
- case .thinLong, .monkey:
1036
- tail.lineWidth = sp.tail == .monkey ? 1.1 : 0.75
1037
- let end = NSPoint(x: tb.x - 7.4, y: tb.y + (sp.tail == .monkey ? 4.2 : 0.2) - flex * 1.2 + lag * 1.4)
1038
- tail.move(to: tb)
1039
- tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.8, y: tb.y - 1.6 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.4 + lag))
1040
- if sp.tail == .monkey { tail.appendArc(withCenter: NSPoint(x: end.x + 0.9, y: end.y), radius: 0.9, startAngle: 180, endAngle: 450, clockwise: false) }
1041
- tail.stroke()
1042
- case .flow: // a horse's tail: a few strands streaming back
1043
- for (dy, w) in [(0.0, 1.5), (-0.9, 1.1), (0.8, 1.0)] as [(CGFloat, CGFloat)] {
1044
- let t = NSBezierPath(); t.lineWidth = w; t.lineCapStyle = .round
1045
- let end = NSPoint(x: tb.x - 6.4, y: tb.y - 2.2 + dy - flex * 1.2 + lag * 1.4)
1046
- t.move(to: NSPoint(x: tb.x, y: tb.y + 0.6)); t.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.4 + dy), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y + 1.2 - lag)); t.stroke()
1047
- }
1048
- case .wag: // a puppy's short tail, held up and wagging
1049
- line2(NSPoint(x: tb.x + 0.3, y: tb.y + 0.4), NSPoint(x: tb.x - 1.8 + lag * 0.9, y: tb.y + 3.0), 1.4)
1050
- case .short:
1051
- oval(NSPoint(x: tb.x - 0.4, y: tb.y + 1.2), 0.9, 1.3)
1052
- case .rope: // an elephant's thin tail with a tuft
1053
- let e = NSPoint(x: tb.x - 1.6 + lag * 0.5, y: tb.y - 2.8)
1054
- line2(tb, e, 0.7); oval(e, 0.6, 0.8)
1055
- }
1056
- // wings beat once a stride, the downstroke as the body rises; the far wing goes behind the body
1057
- let wingFlap: CGFloat = idle ? -0.15 : sin(ph + 0.6)
1058
- let wingRoot = rot(NSPoint(x: c.x + half - 1.8, y: y0 + CGFloat(sp.chest) * 0.75), c, pitch)
1059
- if sp.x.contains("wings") { featherWing(NSPoint(x: wingRoot.x + 0.6, y: wingRoot.y + 0.3), flap: idle ? -0.15 : sin(ph + 0.25), span: idle ? 5.5 : 7.6, near: false) }
1060
- // torso: hip and chest masses joined along a spine that bends
1061
- let sp2 = NSBezierPath(); sp2.lineWidth = CGFloat(min(sp.chest, sp.hip)) * 2.15; sp2.lineCapStyle = .round
1062
- sp2.move(to: H); sp2.curve(to: S, controlPoint1: M, controlPoint2: M); sp2.stroke()
1063
- let sq = 1 - 0.09 * max(0, -lift) // squashed a little on landing
1064
- oval(NSPoint(x: H.x + 0.3, y: H.y), CGFloat(sp.hip) * (2 - sq), CGFloat(sp.hip) * 0.95 * sq)
1065
- oval(NSPoint(x: S.x - 0.2, y: S.y - 0.25), CGFloat(sp.chest) * (2 - sq), CGFloat(sp.chest) * sq)
1066
- if sp.hump { oval(rot(NSPoint(x: S.x - 1.4, y: S.y + CGFloat(sp.chest) * 0.62), S, pitch), CGFloat(sp.chest) * 0.78, CGFloat(sp.chest) * 0.62) }
1067
- let br = CGFloat(min(sp.chest, sp.hip)) * 1.07
1068
- func along(_ t: CGFloat) -> NSPoint { // a point on the spine, t = 0 at the hip and 1 at the shoulder
1069
- let u = 1 - t; return NSPoint(x: u * u * u * H.x + 3 * u * u * t * M.x + 3 * u * t * t * M.x + t * t * t * S.x, y: u * u * u * H.y + 3 * u * u * t * M.y + 3 * u * t * t * M.y + t * t * t * S.y)
1070
- }
1071
- if sp.x.contains("wool") { // a white fleece with a scalloped outline: the puffs drawn dark, then hollowed out
1072
- leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) // under the fleece
1073
- var puffs: [(NSPoint, CGFloat)] = []
1074
- for i in 0...5 { let p = along(CGFloat(i) / 5); puffs.append((NSPoint(x: p.x, y: p.y + br * 0.8), br * 0.62)); puffs.append((NSPoint(x: p.x, y: p.y - br * 0.55), br * 0.58)) }
1075
- puffs.append((NSPoint(x: H.x - br * 0.8, y: H.y + 0.2), br * 0.62)); puffs.append((NSPoint(x: S.x + br * 0.55, y: S.y + br * 0.35), br * 0.6))
1076
- for (c3, r) in puffs { oval(c3, r, r) }
1077
- oval(along(0.5), br * 1.6, br * 1.1)
952
+ // The drawing is its own function. Swift 6.0 type-checks a multi-statement closure together with the call that
953
+ // takes it, and this body inside NSImage(size:flipped:) gave up with "unable to type-check this expression in
954
+ // reasonable time" (#22). A function body is checked statement by statement.
955
+ let img = NSImage(size: size, flipped: false) { _ in drawRunner(sp, frame: frame, idle: idle); return true }
956
+ img.isTemplate = true
957
+ return img
958
+ }
959
+
960
+ func drawRunner(_ sp: Sp, frame: Int, idle: Bool) {
961
+ let t = NSAffineTransform(); t.scale(by: RUNNER_SCALE); t.concat()
962
+ NSColor.black.setFill(); NSColor.black.setStroke()
963
+ if sp.waddle { penguin(frame: frame, idle: idle); return }
964
+ if sp.fly > 0 { flyer(sp, frame: frame, idle: idle); return }
965
+ if sp.kind == 4 { frog(frame: frame, idle: idle); return }
966
+ if sp.kind == 5 || sp.kind == 6 { biped(chick: sp.kind == 6, frame: frame, idle: idle); return }
967
+ if sp.kind == 7 { ghost(frame: frame, idle: idle); return }
968
+ let k = idle ? STAND2 : GAL[frame % GAL.count]
969
+ let n = GAL.count, ph = 2 * CGFloat.pi * CGFloat(frame % n) / CGFloat(n)
970
+ let flex = CGFloat(k.flex * sp.flexAmp), lift = CGFloat(k.lift * sp.liftAmp) * 1.2
971
+ let pitch = CGFloat(k.pitch * sp.pitchAmp) * .pi / 180
972
+ let ground: CGFloat = 1.3
973
+ let airborne = sp.x.contains("wings") && !idle // runs on air: the hooves never touch the ground
974
+ let standY: CGFloat = ground + CGFloat(sp.legH) * LEGK * 0.86 + 0.9
975
+ let bob: CGFloat = idle ? 0.12 * sin(ph) : 0
976
+ let hover: CGFloat = airborne ? 1.2 : 0
977
+ let y0: CGFloat = standY + lift + bob + hover
978
+ let c = NSPoint(x: 14.6, y: y0)
979
+ let half = CGFloat(sp.len) * BODYK / 2 * (1 + 0.17 * flex)
980
+ let arch = flex < 0 ? -flex * 1.5 : -flex * 0.3 // gathered: the back humps up; stretched: nearly flat
981
+ let H = rot(NSPoint(x: c.x - half, y: y0), c, pitch), S = rot(NSPoint(x: c.x + half, y: y0), c, pitch)
982
+ let M = rot(NSPoint(x: c.x, y: y0 + arch * 2), c, pitch)
983
+ func leg(_ joint: NSPoint, _ a: (Double, Double), _ len: CGFloat, _ near: Bool) {
984
+ let a1 = CGFloat(a.0) * .pi / 180, a2 = CGFloat(a.1) * .pi / 180
985
+ let u = len * 0.5, l = len * 0.52
986
+ let knee = NSPoint(x: joint.x + sin(a1) * u, y: joint.y - cos(a1) * u)
987
+ var foot = NSPoint(x: knee.x + sin(a2) * l, y: knee.y - cos(a2) * l)
988
+ foot.y = max(foot.y, airborne ? 1.1 : ground)
989
+ let w = CGFloat(sp.legW) * (near ? 1 : 0.86)
990
+ taper(joint, knee, 3.6 * w, 2.0 * w); taper(knee, foot, 2.0 * w, 1.35 * w)
991
+ oval(NSPoint(x: foot.x + 0.35, y: foot.y + 0.05), 1.0 * w, 0.72 * w)
992
+ }
993
+ let sh = NSPoint(x: S.x - 0.4, y: S.y - CGFloat(sp.chest) * 0.35), hp = NSPoint(x: H.x + 0.5, y: H.y - CGFloat(sp.hip) * 0.3)
994
+ // far legs
995
+ leg(sh, k.ff, CGFloat(sp.legF) * LEGK, false); leg(hp, k.hf, CGFloat(sp.legH) * LEGK, false)
996
+ // tail, trailing the body by a quarter stride
997
+ let lag = sin(ph - .pi / 2), tb = rot(NSPoint(x: c.x - half - 0.6, y: y0 + 0.8), c, pitch)
998
+ let tail = NSBezierPath(); tail.lineCapStyle = .round; tail.lineJoinStyle = .round
999
+ switch sp.tail {
1000
+ case .curl:
1001
+ tail.lineWidth = 3.1
1002
+ tail.move(to: tb)
1003
+ tail.curve(to: NSPoint(x: tb.x + 1.0 + flex * 0.4, y: tb.y + 5.2 - flex * 0.6), controlPoint1: NSPoint(x: tb.x - 5.0, y: tb.y + 0.4), controlPoint2: NSPoint(x: tb.x - 5.0 + lag, y: tb.y + 6.2))
1004
+ tail.stroke()
1005
+ case .long, .tuft, .thin:
1006
+ tail.lineWidth = sp.tail == .tuft ? 1.4 : 1.6
1007
+ let end = NSPoint(x: tb.x - 7.0 + abs(flex) * 0.6, y: tb.y + 1.2 - flex * 2.4 + lag * 1.6)
1008
+ tail.move(to: tb)
1009
+ tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y - 1.4 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.2 + lag * 1.4))
1010
+ tail.stroke()
1011
+ if sp.tail == .tuft { oval(end, 1.3, 1.1) }
1012
+ case .bushy:
1013
+ let end = NSPoint(x: tb.x - 7.2, y: tb.y - 0.4 - flex * 1.6 + lag * 1.2)
1014
+ let b = NSBezierPath()
1015
+ b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
1016
+ b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.6, y: tb.y + 2.4 + lag * 0.6), controlPoint2: NSPoint(x: end.x + 2.4, y: end.y + 2.2))
1017
+ b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.6, y: end.y - 1.8), controlPoint2: NSPoint(x: tb.x - 2.8, y: tb.y - 2.0 + lag * 0.6))
1018
+ b.close(); b.fill()
1019
+ case .stub:
1020
+ oval(NSPoint(x: tb.x + 0.6, y: tb.y + 0.6), 1.5, 1.4)
1021
+ case .none: break
1022
+ case .curly: // a pig's corkscrew
1023
+ let cc = NSPoint(x: tb.x - 1.2, y: tb.y + 1.0 + lag * 0.3), t = NSBezierPath(); t.lineWidth = 0.85; t.lineCapStyle = .round
1024
+ t.move(to: NSPoint(x: tb.x + 0.2, y: tb.y + 0.2))
1025
+ t.appendArc(withCenter: cc, radius: 0.95, startAngle: -20, endAngle: 300, clockwise: false); t.stroke()
1026
+ case .ringed, .hang:
1027
+ let end = sp.tail == .hang ? NSPoint(x: tb.x - 5.6, y: tb.y - 3.6 + lag * 0.9 - flex * 0.6) : NSPoint(x: tb.x - 7.0, y: tb.y + 0.4 - flex * 1.4 + lag * 1.2)
1028
+ let b = NSBezierPath()
1029
+ b.move(to: NSPoint(x: tb.x + 0.4, y: tb.y + 1.2))
1030
+ b.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.6 + lag * 0.5), controlPoint2: NSPoint(x: end.x + 2.0, y: end.y + 2.0))
1031
+ b.curve(to: NSPoint(x: tb.x + 0.4, y: tb.y - 1.2), controlPoint1: NSPoint(x: end.x + 1.4, y: end.y - 1.6), controlPoint2: NSPoint(x: tb.x - 2.6, y: tb.y - 1.8 + lag * 0.5))
1032
+ b.close(); b.fill()
1033
+ if sp.tail == .ringed { // dark and pale rings: two gaps cut across the tail
1078
1034
  NSGraphicsContext.current?.compositingOperation = .clear
1079
- for (c3, r) in puffs { oval(c3, r - 0.75, r - 0.75) }
1080
- oval(along(0.5), br * 1.6 - 0.75, br * 1.1 - 0.75)
1081
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1082
- }
1083
- if sp.x.contains("spikes") { // a hedgehog's coat: spines over the back, pointing back
1084
- for i in 0..<10 {
1085
- let t = 0.05 + CGFloat(i) / 10, p = along(t), up = br * (0.6 + 0.4 * sin(t * .pi))
1086
- let b0 = NSPoint(x: p.x - 0.8, y: p.y + up * 0.7), b1 = NSPoint(x: p.x + 0.8, y: p.y + up * 0.75)
1087
- let tip = NSPoint(x: p.x - 2.6 - lag * 0.2, y: p.y + up + 2.8)
1088
- let sp3 = NSBezierPath(); sp3.move(to: b0); sp3.line(to: tip); sp3.line(to: b1); sp3.close(); sp3.fill()
1035
+ for t in [0.42, 0.7] as [CGFloat] {
1036
+ let m = NSPoint(x: tb.x + (end.x - tb.x) * t, y: tb.y + (end.y - tb.y) * t + 0.3)
1037
+ line2(NSPoint(x: m.x + 0.5, y: m.y + 2.2), NSPoint(x: m.x - 0.5, y: m.y - 2.2), 0.6)
1089
1038
  }
1090
- for i in 0..<3 { let p = along(0.02); let sp3 = NSBezierPath(); sp3.move(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) - 0.6)); sp3.line(to: NSPoint(x: p.x - br - 1.6, y: p.y + CGFloat(i) * 1.2 - 0.6)); sp3.line(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) + 0.4)); sp3.close(); sp3.fill() }
1091
- }
1092
- if sp.x.contains("stripes") {
1093
- NSGraphicsContext.current?.compositingOperation = .clear
1094
- // a tiger's stripes, cut across the back
1095
- for t in [0.12, 0.32, 0.52, 0.72] as [CGFloat] { let p = along(t); line2(NSPoint(x: p.x - 0.4, y: p.y + br * 1.05), NSPoint(x: p.x + 0.4, y: p.y + br * 0.15), 0.55) }
1096
1039
  NSGraphicsContext.current?.compositingOperation = .sourceOver
1097
1040
  }
1098
- if sp.x.contains("wings") { featherWing(wingRoot, flap: wingFlap, span: idle ? 6.0 : 9.0, near: true) }
1099
- // neck and head, turned three-quarters toward the viewer so both eyes show; the head stays steadier than the body
1100
- let hpitch = pitch * 0.35, hr = CGFloat(sp.head) * HEADK
1101
- let hc = NSPoint(x: S.x + CGFloat(sp.neckX) * 0.62 * cos(pitch) - CGFloat(sp.neckY) * 0.4 * sin(pitch),
1102
- y: S.y + CGFloat(sp.neckY) * 0.62 - lift * 0.3 + CGFloat(sp.neckX) * 0.8 * sin(pitch))
1103
- line2(NSPoint(x: S.x + 0.4, y: S.y + 0.4), hc, hr * 1.3)
1104
- if sp.mane {
1105
- lionMane(hc, hr, sweep: idle ? 0.05 : 0.32 + 0.12 * lag)
1106
- }
1107
- oval(hc, hr * 1.05, hr)
1108
- let sn = CGFloat(sp.snout), sh2 = CGFloat(sp.snoutH)
1109
- if sn > 1.6 { // a dog's or fox's muzzle points forward and down from the turned face
1110
- let mc = rot(NSPoint(x: hc.x + hr * 0.62 + sn * 0.2, y: hc.y - hr * 0.45), hc, hpitch)
1111
- oval(mc, hr * 0.42 + sn * 0.24, sh2 * 0.7 + 0.45)
1112
- if sp.hump { oval(rot(NSPoint(x: mc.x + hr * 0.42 + sn * 0.2, y: mc.y + sh2 * 0.5), mc, 0), 0.85, 0.7) } // a bear's nose at the tip
1113
- }
1114
- let back = (lift > 0.8 ? 0.35 : 0.0) + (idle ? 0 : 0.12)
1115
- func ear(_ base0: CGFloat, _ base1: CGFloat, _ tipX: CGFloat, _ tipY: CGFloat) {
1116
- let a = rot(NSPoint(x: hc.x + base0, y: hc.y + hr * 0.55), hc, hpitch), b = rot(NSPoint(x: hc.x + base1, y: hc.y + hr * 0.7), hc, hpitch)
1117
- let tip = rot(NSPoint(x: hc.x + tipX, y: hc.y + tipY), hc, hpitch + CGFloat(back))
1118
- let e = NSBezierPath(); e.move(to: a); e.line(to: tip); e.line(to: b); e.close(); e.fill()
1041
+ case .squirrel: // a big plume carried up over the back, its tip curling forward
1042
+ let t = NSBezierPath(); t.lineWidth = 3.6; t.lineCapStyle = .round
1043
+ let tip = NSPoint(x: tb.x + 0.8 + lag * 0.4, y: tb.y + 8.6 - flex * 0.6)
1044
+ t.move(to: tb); t.curve(to: tip, controlPoint1: NSPoint(x: tb.x - 5.2, y: tb.y + 1.4), controlPoint2: NSPoint(x: tb.x - 4.4 + lag * 0.5, y: tb.y + 9.4)); t.stroke()
1045
+ oval(tip, 1.8, 1.6)
1046
+ case .thinLong, .monkey:
1047
+ tail.lineWidth = sp.tail == .monkey ? 1.1 : 0.75
1048
+ let end = NSPoint(x: tb.x - 7.4, y: tb.y + (sp.tail == .monkey ? 4.2 : 0.2) - flex * 1.2 + lag * 1.4)
1049
+ tail.move(to: tb)
1050
+ tail.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.8, y: tb.y - 1.6 - lag), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y - 2.4 + lag))
1051
+ if sp.tail == .monkey { tail.appendArc(withCenter: NSPoint(x: end.x + 0.9, y: end.y), radius: 0.9, startAngle: 180, endAngle: 450, clockwise: false) }
1052
+ tail.stroke()
1053
+ case .flow: // a horse's tail: a few strands streaming back
1054
+ for (dy, w) in [(0.0, 1.5), (-0.9, 1.1), (0.8, 1.0)] as [(CGFloat, CGFloat)] {
1055
+ let t = NSBezierPath(); t.lineWidth = w; t.lineCapStyle = .round
1056
+ let end = NSPoint(x: tb.x - 6.4, y: tb.y - 2.2 + dy - flex * 1.2 + lag * 1.4)
1057
+ t.move(to: NSPoint(x: tb.x, y: tb.y + 0.6)); t.curve(to: end, controlPoint1: NSPoint(x: tb.x - 2.4, y: tb.y + 1.4 + dy), controlPoint2: NSPoint(x: end.x + 2.6, y: end.y + 1.2 - lag)); t.stroke()
1119
1058
  }
1120
- switch sp.ear {
1121
- case .pricked: ear(-hr * 0.9, -hr * 0.15, -hr * 0.7, hr * 1.75); ear(hr * 0.05, hr * 0.85, hr * 0.55, hr * 1.75)
1122
- case .cat: ear(-hr * 0.95, -hr * 0.2, -hr * 0.72, hr * 1.55); ear(hr * 0.0, hr * 0.85, hr * 0.5, hr * 1.55)
1123
- case .round:
1124
- for dx in [-hr * 0.6, hr * 0.45] { let p = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.82), hc, hpitch); oval(p, hr * 0.38, hr * 0.38) }
1125
- case .long:
1126
- for (dx, sw) in [(-hr * 0.45, 0.1), (hr * 0.2, 0.3)] as [(CGFloat, CGFloat)] {
1127
- let base = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.6), hc, hpitch)
1128
- let ang = hpitch + CGFloat(back) * 1.6 + 0.3 + sw - lag * 0.15
1129
- let tip = NSPoint(x: base.x - sin(ang) * hr * 1.55, y: base.y + cos(ang) * hr * 1.55)
1130
- taper(base, tip, hr * 0.42, hr * 0.36)
1131
- }
1132
- case .tiny, .none: break
1133
- case .floppy: // a puppy's ears hang and swing
1134
- // the far ear peeks over the crown; the near one hangs by the cheek, set off from the head by a thin gap
1135
- let fb = rot(NSPoint(x: hc.x + hr * 0.55, y: hc.y + hr * 0.75), hc, hpitch)
1136
- taper(fb, NSPoint(x: fb.x + hr * 0.35, y: fb.y - hr * 0.35), hr * 0.5, hr * 0.45)
1137
- let base = rot(NSPoint(x: hc.x - hr * 0.88, y: hc.y + hr * 0.55), hc, hpitch)
1138
- let tip = NSPoint(x: base.x - hr * 0.55 - lag * hr * 0.3, y: base.y - hr * 1.4 + (lift > 0.8 ? hr * 0.55 : 0))
1139
- NSGraphicsContext.current?.compositingOperation = .clear
1140
- taper(base, tip, hr * 0.5 + 1.0, hr * 0.66 + 1.0)
1141
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1142
- taper(base, tip, hr * 0.5, hr * 0.66)
1143
- case .side: // round ears on the sides: big and fluffy on a koala
1144
- let big = sp.x.contains("koalanose")
1145
- for (dx, dy, r) in [(-hr * (big ? 0.95 : 1.0), hr * (big ? 0.55 : 0.15), hr * (big ? 0.62 : 0.36)), (hr * (big ? 0.8 : 0.95), hr * (big ? 0.6 : 0.2), hr * (big ? 0.5 : 0.3))] as [(CGFloat, CGFloat, CGFloat)] {
1146
- let ec = rot(NSPoint(x: hc.x + dx, y: hc.y + dy), hc, hpitch)
1147
- oval(ec, r, r)
1148
- if big { NSGraphicsContext.current?.compositingOperation = .clear; oval(NSPoint(x: ec.x + (dx < 0 ? -r * 0.12 : r * 0.12), y: ec.y + r * 0.05), r * 0.55, r * 0.55); NSGraphicsContext.current?.compositingOperation = .sourceOver }
1149
- }
1150
- case .mouse:
1151
- for (dx, r) in [(-hr * 0.55, hr * 0.62), (hr * 0.45, hr * 0.55)] as [(CGFloat, CGFloat)] { oval(rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 1.0), hc, hpitch), r, r) }
1152
- case .horse: ear(-hr * 0.6, -hr * 0.15, -hr * 0.55, hr * 1.6); ear(hr * 0.0, hr * 0.4, hr * 0.15, hr * 1.55)
1153
- case .sheep:
1154
- for (dx, f) in [(-hr * 0.7, 1.0), (hr * 0.4, 0.8)] as [(CGFloat, CGFloat)] { let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.45), hc, hpitch); taper(b, NSPoint(x: b.x - hr * 0.9 * f, y: b.y - hr * 0.1 + lag * 0.2), hr * 0.42, hr * 0.32) }
1155
- case .pig: ear(-hr * 0.85, -hr * 0.15, hr * 0.1, hr * 1.35); ear(hr * 0.0, hr * 0.7, hr * 0.95, hr * 1.2)
1156
- }
1157
- // head features
1158
- if sp.x.contains("horn") {
1159
- let a = rot(NSPoint(x: hc.x + hr * 0.15, y: hc.y + hr * 0.8), hc, hpitch), b = rot(NSPoint(x: hc.x + hr * 0.65, y: hc.y + hr * 0.85), hc, hpitch), t = rot(NSPoint(x: hc.x + hr * 1.15, y: hc.y + hr * 2.25), hc, hpitch)
1160
- let h = NSBezierPath(); h.move(to: a); h.line(to: t); h.line(to: b); h.close(); h.fill()
1059
+ case .wag: // a puppy's short tail, held up and wagging
1060
+ line2(NSPoint(x: tb.x + 0.3, y: tb.y + 0.4), NSPoint(x: tb.x - 1.8 + lag * 0.9, y: tb.y + 3.0), 1.4)
1061
+ case .short:
1062
+ oval(NSPoint(x: tb.x - 0.4, y: tb.y + 1.2), 0.9, 1.3)
1063
+ case .rope: // an elephant's thin tail with a tuft
1064
+ let e = NSPoint(x: tb.x - 1.6 + lag * 0.5, y: tb.y - 2.8)
1065
+ line2(tb, e, 0.7); oval(e, 0.6, 0.8)
1066
+ }
1067
+ // wings beat once a stride, the downstroke as the body rises; the far wing goes behind the body
1068
+ let wingFlap: CGFloat = idle ? -0.15 : sin(ph + 0.6)
1069
+ let wingRoot = rot(NSPoint(x: c.x + half - 1.8, y: y0 + CGFloat(sp.chest) * 0.75), c, pitch)
1070
+ if sp.x.contains("wings") { featherWing(NSPoint(x: wingRoot.x + 0.6, y: wingRoot.y + 0.3), flap: idle ? -0.15 : sin(ph + 0.25), span: idle ? 5.5 : 7.6, near: false) }
1071
+ // torso: hip and chest masses joined along a spine that bends
1072
+ let sp2 = NSBezierPath(); sp2.lineWidth = CGFloat(min(sp.chest, sp.hip)) * 2.15; sp2.lineCapStyle = .round
1073
+ sp2.move(to: H); sp2.curve(to: S, controlPoint1: M, controlPoint2: M); sp2.stroke()
1074
+ let sq = 1 - 0.09 * max(0, -lift) // squashed a little on landing
1075
+ oval(NSPoint(x: H.x + 0.3, y: H.y), CGFloat(sp.hip) * (2 - sq), CGFloat(sp.hip) * 0.95 * sq)
1076
+ oval(NSPoint(x: S.x - 0.2, y: S.y - 0.25), CGFloat(sp.chest) * (2 - sq), CGFloat(sp.chest) * sq)
1077
+ if sp.hump { oval(rot(NSPoint(x: S.x - 1.4, y: S.y + CGFloat(sp.chest) * 0.62), S, pitch), CGFloat(sp.chest) * 0.78, CGFloat(sp.chest) * 0.62) }
1078
+ let br = CGFloat(min(sp.chest, sp.hip)) * 1.07
1079
+ func along(_ t: CGFloat) -> NSPoint { // a point on the spine, t = 0 at the hip and 1 at the shoulder
1080
+ let u = 1 - t; return NSPoint(x: u * u * u * H.x + 3 * u * u * t * M.x + 3 * u * t * t * M.x + t * t * t * S.x, y: u * u * u * H.y + 3 * u * u * t * M.y + 3 * u * t * t * M.y + t * t * t * S.y)
1081
+ }
1082
+ if sp.x.contains("wool") { // a white fleece with a scalloped outline: the puffs drawn dark, then hollowed out
1083
+ leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) // under the fleece
1084
+ var puffs: [(NSPoint, CGFloat)] = []
1085
+ for i in 0...5 { let p = along(CGFloat(i) / 5); puffs.append((NSPoint(x: p.x, y: p.y + br * 0.8), br * 0.62)); puffs.append((NSPoint(x: p.x, y: p.y - br * 0.55), br * 0.58)) }
1086
+ puffs.append((NSPoint(x: H.x - br * 0.8, y: H.y + 0.2), br * 0.62)); puffs.append((NSPoint(x: S.x + br * 0.55, y: S.y + br * 0.35), br * 0.6))
1087
+ for (c3, r) in puffs { oval(c3, r, r) }
1088
+ oval(along(0.5), br * 1.6, br * 1.1)
1089
+ NSGraphicsContext.current?.compositingOperation = .clear
1090
+ for (c3, r) in puffs { oval(c3, r - 0.75, r - 0.75) }
1091
+ oval(along(0.5), br * 1.6 - 0.75, br * 1.1 - 0.75)
1092
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1093
+ }
1094
+ if sp.x.contains("spikes") { // a hedgehog's coat: spines over the back, pointing back
1095
+ for i in 0..<10 {
1096
+ let t = 0.05 + CGFloat(i) / 10, p = along(t), up = br * (0.6 + 0.4 * sin(t * .pi))
1097
+ let b0 = NSPoint(x: p.x - 0.8, y: p.y + up * 0.7), b1 = NSPoint(x: p.x + 0.8, y: p.y + up * 0.75)
1098
+ let tip = NSPoint(x: p.x - 2.6 - lag * 0.2, y: p.y + up + 2.8)
1099
+ let sp3 = NSBezierPath(); sp3.move(to: b0); sp3.line(to: tip); sp3.line(to: b1); sp3.close(); sp3.fill()
1161
1100
  }
1162
- if sp.x.contains("neckmane") { // a mane down the back of the neck, streaming in the run
1163
- for i in 0..<5 {
1164
- let t = CGFloat(i) / 4, base = NSPoint(x: hc.x - hr * 0.75 + (S.x - 0.6 - hc.x + hr * 0.75) * t, y: hc.y + hr * 0.55 + (S.y + CGFloat(sp.chest) * 0.7 - hc.y - hr * 0.55) * t)
1165
- let tip = NSPoint(x: base.x - 2.2 - lag * 0.5, y: base.y + 0.4 - t * 0.6)
1166
- let m = NSBezierPath(); m.move(to: NSPoint(x: base.x + 0.7, y: base.y + 0.4)); m.line(to: tip); m.line(to: NSPoint(x: base.x + 0.3, y: base.y - 0.9)); m.close(); m.fill()
1167
- }
1101
+ for i in 0..<3 { let p = along(0.02); let sp3 = NSBezierPath(); sp3.move(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) - 0.6)); sp3.line(to: NSPoint(x: p.x - br - 1.6, y: p.y + CGFloat(i) * 1.2 - 0.6)); sp3.line(to: NSPoint(x: p.x - 0.4, y: p.y + CGFloat(i) + 0.4)); sp3.close(); sp3.fill() }
1102
+ }
1103
+ if sp.x.contains("stripes") {
1104
+ NSGraphicsContext.current?.compositingOperation = .clear
1105
+ // a tiger's stripes, cut across the back
1106
+ for t in [0.12, 0.32, 0.52, 0.72] as [CGFloat] { let p = along(t); line2(NSPoint(x: p.x - 0.4, y: p.y + br * 1.05), NSPoint(x: p.x + 0.4, y: p.y + br * 0.15), 0.55) }
1107
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1108
+ }
1109
+ if sp.x.contains("wings") { featherWing(wingRoot, flap: wingFlap, span: idle ? 6.0 : 9.0, near: true) }
1110
+ // neck and head, turned three-quarters toward the viewer so both eyes show; the head stays steadier than the body
1111
+ let hpitch = pitch * 0.35, hr = CGFloat(sp.head) * HEADK
1112
+ let hc = NSPoint(x: S.x + CGFloat(sp.neckX) * 0.62 * cos(pitch) - CGFloat(sp.neckY) * 0.4 * sin(pitch),
1113
+ y: S.y + CGFloat(sp.neckY) * 0.62 - lift * 0.3 + CGFloat(sp.neckX) * 0.8 * sin(pitch))
1114
+ line2(NSPoint(x: S.x + 0.4, y: S.y + 0.4), hc, hr * 1.3)
1115
+ if sp.mane {
1116
+ lionMane(hc, hr, sweep: idle ? 0.05 : 0.32 + 0.12 * lag)
1117
+ }
1118
+ oval(hc, hr * 1.05, hr)
1119
+ let sn = CGFloat(sp.snout), sh2 = CGFloat(sp.snoutH)
1120
+ if sn > 1.6 { // a dog's or fox's muzzle points forward and down from the turned face
1121
+ let mc = rot(NSPoint(x: hc.x + hr * 0.62 + sn * 0.2, y: hc.y - hr * 0.45), hc, hpitch)
1122
+ oval(mc, hr * 0.42 + sn * 0.24, sh2 * 0.7 + 0.45)
1123
+ if sp.hump { oval(rot(NSPoint(x: mc.x + hr * 0.42 + sn * 0.2, y: mc.y + sh2 * 0.5), mc, 0), 0.85, 0.7) } // a bear's nose at the tip
1124
+ }
1125
+ let back = (lift > 0.8 ? 0.35 : 0.0) + (idle ? 0 : 0.12)
1126
+ func ear(_ base0: CGFloat, _ base1: CGFloat, _ tipX: CGFloat, _ tipY: CGFloat) {
1127
+ let a = rot(NSPoint(x: hc.x + base0, y: hc.y + hr * 0.55), hc, hpitch), b = rot(NSPoint(x: hc.x + base1, y: hc.y + hr * 0.7), hc, hpitch)
1128
+ let tip = rot(NSPoint(x: hc.x + tipX, y: hc.y + tipY), hc, hpitch + CGFloat(back))
1129
+ let e = NSBezierPath(); e.move(to: a); e.line(to: tip); e.line(to: b); e.close(); e.fill()
1130
+ }
1131
+ switch sp.ear {
1132
+ case .pricked: ear(-hr * 0.9, -hr * 0.15, -hr * 0.7, hr * 1.75); ear(hr * 0.05, hr * 0.85, hr * 0.55, hr * 1.75)
1133
+ case .cat: ear(-hr * 0.95, -hr * 0.2, -hr * 0.72, hr * 1.55); ear(hr * 0.0, hr * 0.85, hr * 0.5, hr * 1.55)
1134
+ case .round:
1135
+ for dx in [-hr * 0.6, hr * 0.45] { let p = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.82), hc, hpitch); oval(p, hr * 0.38, hr * 0.38) }
1136
+ case .long:
1137
+ for (dx, sw) in [(-hr * 0.45, 0.1), (hr * 0.2, 0.3)] as [(CGFloat, CGFloat)] {
1138
+ let base = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.6), hc, hpitch)
1139
+ let ang = hpitch + CGFloat(back) * 1.6 + 0.3 + sw - lag * 0.15
1140
+ let tip = NSPoint(x: base.x - sin(ang) * hr * 1.55, y: base.y + cos(ang) * hr * 1.55)
1141
+ taper(base, tip, hr * 0.42, hr * 0.36)
1168
1142
  }
1169
- if sp.x.contains("antlers") {
1170
- for (dx, f) in [(-hr * 0.35, 1.0), (hr * 0.2, 0.85)] as [(CGFloat, CGFloat)] {
1171
- let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.8), hc, hpitch)
1172
- let top = NSPoint(x: b.x - hr * 0.7 * f, y: b.y + hr * 1.7 * f), m1 = NSPoint(x: b.x - hr * 0.25 * f, y: b.y + hr * 0.75 * f), m2 = NSPoint(x: b.x - hr * 0.5 * f, y: b.y + hr * 1.25 * f)
1173
- line2(b, top, 0.75); line2(m1, NSPoint(x: m1.x + hr * 0.55 * f, y: m1.y + hr * 0.45 * f), 0.65); line2(m2, NSPoint(x: m2.x + hr * 0.5 * f, y: m2.y + hr * 0.55 * f), 0.6)
1174
- }
1143
+ case .tiny, .none: break
1144
+ case .floppy: // a puppy's ears hang and swing
1145
+ // the far ear peeks over the crown; the near one hangs by the cheek, set off from the head by a thin gap
1146
+ let fb = rot(NSPoint(x: hc.x + hr * 0.55, y: hc.y + hr * 0.75), hc, hpitch)
1147
+ taper(fb, NSPoint(x: fb.x + hr * 0.35, y: fb.y - hr * 0.35), hr * 0.5, hr * 0.45)
1148
+ let base = rot(NSPoint(x: hc.x - hr * 0.88, y: hc.y + hr * 0.55), hc, hpitch)
1149
+ let tip = NSPoint(x: base.x - hr * 0.55 - lag * hr * 0.3, y: base.y - hr * 1.4 + (lift > 0.8 ? hr * 0.55 : 0))
1150
+ NSGraphicsContext.current?.compositingOperation = .clear
1151
+ taper(base, tip, hr * 0.5 + 1.0, hr * 0.66 + 1.0)
1152
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1153
+ taper(base, tip, hr * 0.5, hr * 0.66)
1154
+ case .side: // round ears on the sides: big and fluffy on a koala
1155
+ let big = sp.x.contains("koalanose")
1156
+ for (dx, dy, r) in [(-hr * (big ? 0.95 : 1.0), hr * (big ? 0.55 : 0.15), hr * (big ? 0.62 : 0.36)), (hr * (big ? 0.8 : 0.95), hr * (big ? 0.6 : 0.2), hr * (big ? 0.5 : 0.3))] as [(CGFloat, CGFloat, CGFloat)] {
1157
+ let ec = rot(NSPoint(x: hc.x + dx, y: hc.y + dy), hc, hpitch)
1158
+ oval(ec, r, r)
1159
+ if big { NSGraphicsContext.current?.compositingOperation = .clear; oval(NSPoint(x: ec.x + (dx < 0 ? -r * 0.12 : r * 0.12), y: ec.y + r * 0.05), r * 0.55, r * 0.55); NSGraphicsContext.current?.compositingOperation = .sourceOver }
1175
1160
  }
1176
- if sp.x.contains("trunk") { // an elephant: a big ear set apart from the head, and a swinging trunk
1177
- let ec = rot(NSPoint(x: hc.x - hr * 0.95, y: hc.y - hr * 0.05), hc, hpitch)
1178
- NSGraphicsContext.current?.compositingOperation = .clear
1179
- NSBezierPath(ovalIn: NSRect(x: ec.x - hr * 0.78, y: ec.y - hr * 0.98, width: hr * 1.56, height: hr * 1.96)).fill()
1180
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1181
- oval(ec, hr * 0.68 + lag * 0.15, hr * 0.88)
1182
- let r0 = rot(NSPoint(x: hc.x + hr * 0.8, y: hc.y - hr * 0.25), hc, hpitch), mid = NSPoint(x: r0.x + hr * 0.55, y: r0.y - hr * 0.8), tip = NSPoint(x: r0.x + hr * 0.6 + lag * hr * 0.35, y: r0.y - hr * 1.7)
1183
- taper(r0, mid, hr * 0.7, hr * 0.5); taper(mid, tip, hr * 0.5, hr * 0.38)
1161
+ case .mouse:
1162
+ for (dx, r) in [(-hr * 0.55, hr * 0.62), (hr * 0.45, hr * 0.55)] as [(CGFloat, CGFloat)] { oval(rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 1.0), hc, hpitch), r, r) }
1163
+ case .horse: ear(-hr * 0.6, -hr * 0.15, -hr * 0.55, hr * 1.6); ear(hr * 0.0, hr * 0.4, hr * 0.15, hr * 1.55)
1164
+ case .sheep:
1165
+ for (dx, f) in [(-hr * 0.7, 1.0), (hr * 0.4, 0.8)] as [(CGFloat, CGFloat)] { let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.45), hc, hpitch); taper(b, NSPoint(x: b.x - hr * 0.9 * f, y: b.y - hr * 0.1 + lag * 0.2), hr * 0.42, hr * 0.32) }
1166
+ case .pig: ear(-hr * 0.85, -hr * 0.15, hr * 0.1, hr * 1.35); ear(hr * 0.0, hr * 0.7, hr * 0.95, hr * 1.2)
1167
+ }
1168
+ // head features
1169
+ if sp.x.contains("horn") {
1170
+ let a = rot(NSPoint(x: hc.x + hr * 0.15, y: hc.y + hr * 0.8), hc, hpitch), b = rot(NSPoint(x: hc.x + hr * 0.65, y: hc.y + hr * 0.85), hc, hpitch), t = rot(NSPoint(x: hc.x + hr * 1.15, y: hc.y + hr * 2.25), hc, hpitch)
1171
+ let h = NSBezierPath(); h.move(to: a); h.line(to: t); h.line(to: b); h.close(); h.fill()
1172
+ }
1173
+ if sp.x.contains("neckmane") { // a mane down the back of the neck, streaming in the run
1174
+ for i in 0..<5 {
1175
+ let t = CGFloat(i) / 4, base = NSPoint(x: hc.x - hr * 0.75 + (S.x - 0.6 - hc.x + hr * 0.75) * t, y: hc.y + hr * 0.55 + (S.y + CGFloat(sp.chest) * 0.7 - hc.y - hr * 0.55) * t)
1176
+ let tip = NSPoint(x: base.x - 2.2 - lag * 0.5, y: base.y + 0.4 - t * 0.6)
1177
+ let m = NSBezierPath(); m.move(to: NSPoint(x: base.x + 0.7, y: base.y + 0.4)); m.line(to: tip); m.line(to: NSPoint(x: base.x + 0.3, y: base.y - 0.9)); m.close(); m.fill()
1184
1178
  }
1185
- if sp.x.contains("pigsnout") {
1186
- let c2 = rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.3), hc, hpitch)
1187
- oval(c2, hr * 0.38, hr * 0.48)
1188
- NSGraphicsContext.current?.compositingOperation = .clear
1189
- for dy in [hr * 0.15, -hr * 0.17] { oval(NSPoint(x: c2.x + hr * 0.12, y: c2.y + dy), hr * 0.09, hr * 0.12) }
1190
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1179
+ }
1180
+ if sp.x.contains("antlers") {
1181
+ for (dx, f) in [(-hr * 0.35, 1.0), (hr * 0.2, 0.85)] as [(CGFloat, CGFloat)] {
1182
+ let b = rot(NSPoint(x: hc.x + dx, y: hc.y + hr * 0.8), hc, hpitch)
1183
+ let top = NSPoint(x: b.x - hr * 0.7 * f, y: b.y + hr * 1.7 * f), m1 = NSPoint(x: b.x - hr * 0.25 * f, y: b.y + hr * 0.75 * f), m2 = NSPoint(x: b.x - hr * 0.5 * f, y: b.y + hr * 1.25 * f)
1184
+ line2(b, top, 0.75); line2(m1, NSPoint(x: m1.x + hr * 0.55 * f, y: m1.y + hr * 0.45 * f), 0.65); line2(m2, NSPoint(x: m2.x + hr * 0.5 * f, y: m2.y + hr * 0.55 * f), 0.6)
1191
1185
  }
1192
- if sp.x.contains("koalanose") { oval(rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.2), hc, hpitch), hr * 0.38, hr * 0.5) }
1193
- if sp.x.contains("panda") { // pale face, dark eye patches
1194
- NSGraphicsContext.current?.compositingOperation = .clear
1195
- oval(hc, hr * 0.84, hr * 0.8)
1196
- NSGraphicsContext.current?.compositingOperation = .sourceOver
1197
- for (x, y, r) in [(0.42, 0.06, 0.36), (-0.2, 0.1, 0.3)] as [(CGFloat, CGFloat, CGFloat)] {
1198
- let p = NSBezierPath(ovalIn: NSRect(x: -r * hr, y: -r * hr * 0.8, width: 2 * r * hr, height: 1.6 * r * hr))
1199
- let tr = NSAffineTransform(); tr.translateX(by: hc.x + hr * x, yBy: hc.y + hr * y); tr.rotate(byRadians: -0.5); p.transform(using: tr as AffineTransform); p.fill()
1200
- }
1201
- oval(NSPoint(x: hc.x + hr * 0.78, y: hc.y - hr * 0.32), hr * 0.17, hr * 0.13)
1186
+ }
1187
+ if sp.x.contains("trunk") { // an elephant: a big ear set apart from the head, and a swinging trunk
1188
+ let ec = rot(NSPoint(x: hc.x - hr * 0.95, y: hc.y - hr * 0.05), hc, hpitch)
1189
+ NSGraphicsContext.current?.compositingOperation = .clear
1190
+ NSBezierPath(ovalIn: NSRect(x: ec.x - hr * 0.78, y: ec.y - hr * 0.98, width: hr * 1.56, height: hr * 1.96)).fill()
1191
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1192
+ oval(ec, hr * 0.68 + lag * 0.15, hr * 0.88)
1193
+ let r0 = rot(NSPoint(x: hc.x + hr * 0.8, y: hc.y - hr * 0.25), hc, hpitch), mid = NSPoint(x: r0.x + hr * 0.55, y: r0.y - hr * 0.8), tip = NSPoint(x: r0.x + hr * 0.6 + lag * hr * 0.35, y: r0.y - hr * 1.7)
1194
+ taper(r0, mid, hr * 0.7, hr * 0.5); taper(mid, tip, hr * 0.5, hr * 0.38)
1195
+ }
1196
+ if sp.x.contains("pigsnout") {
1197
+ let c2 = rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.3), hc, hpitch)
1198
+ oval(c2, hr * 0.38, hr * 0.48)
1199
+ NSGraphicsContext.current?.compositingOperation = .clear
1200
+ for dy in [hr * 0.15, -hr * 0.17] { oval(NSPoint(x: c2.x + hr * 0.12, y: c2.y + dy), hr * 0.09, hr * 0.12) }
1201
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1202
+ }
1203
+ if sp.x.contains("koalanose") { oval(rot(NSPoint(x: hc.x + hr * 1.0, y: hc.y - hr * 0.2), hc, hpitch), hr * 0.38, hr * 0.5) }
1204
+ if sp.x.contains("panda") { // pale face, dark eye patches
1205
+ NSGraphicsContext.current?.compositingOperation = .clear
1206
+ oval(hc, hr * 0.84, hr * 0.8)
1207
+ NSGraphicsContext.current?.compositingOperation = .sourceOver
1208
+ for (x, y, r) in [(0.42, 0.06, 0.36), (-0.2, 0.1, 0.3)] as [(CGFloat, CGFloat, CGFloat)] {
1209
+ let p = NSBezierPath(ovalIn: NSRect(x: -r * hr, y: -r * hr * 0.8, width: 2 * r * hr, height: 1.6 * r * hr))
1210
+ let tr = NSAffineTransform(); tr.translateX(by: hc.x + hr * x, yBy: hc.y + hr * y); tr.rotate(byRadians: -0.5); p.transform(using: tr as AffineTransform); p.fill()
1202
1211
  }
1203
- // near legs
1204
- if !sp.x.contains("wool") { leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) }
1205
- eyes(NSPoint(x: hc.x + hr * CGFloat(sp.eyeDx), y: hc.y), hr, hpitch, CGFloat(sp.eyeK))
1206
- return true
1212
+ oval(NSPoint(x: hc.x + hr * 0.78, y: hc.y - hr * 0.32), hr * 0.17, hr * 0.13)
1207
1213
  }
1208
- img.isTemplate = true
1209
- return img
1214
+ // near legs
1215
+ if !sp.x.contains("wool") { leg(sh, k.fn, CGFloat(sp.legF) * LEGK, true); leg(hp, k.hn, CGFloat(sp.legH) * LEGK, true) }
1216
+ eyes(NSPoint(x: hc.x + hr * CGFloat(sp.eyeDx), y: hc.y), hr, hpitch, CGFloat(sp.eyeK))
1210
1217
  }
1211
1218
 
1212
1219
  /** A penguin does not gallop: it waddles, rocking side to side with the flippers out. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.136.0",
3
+ "version": "3.136.1",
4
4
  "description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
5
5
  "type": "module",
6
6
  "bin": {