omnipython-apps 0.1.4.dev8__py3-none-any.whl

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 (218) hide show
  1. apps/__init__.py +5 -0
  2. apps/about/__init__.py +257 -0
  3. apps/about/app.json +1 -0
  4. apps/about/credits.py +12 -0
  5. apps/about/facts.py +398 -0
  6. apps/about/fonts/OFL.txt +93 -0
  7. apps/about/fonts/latin1_14.bin +0 -0
  8. apps/about/fonts/latin1_16.bin +0 -0
  9. apps/about/fonts/latin1_24.bin +0 -0
  10. apps/about/fonts/latin1_32.bin +0 -0
  11. apps/about/fonts/latin1_40.bin +0 -0
  12. apps/backline/__init__.py +58 -0
  13. apps/backline/app.json +1 -0
  14. apps/backline/app.py +475 -0
  15. apps/backline/art.py +717 -0
  16. apps/backline/ask.py +781 -0
  17. apps/backline/box.py +502 -0
  18. apps/backline/cast.py +137 -0
  19. apps/backline/desk/__init__.py +329 -0
  20. apps/backline/desk/editor.py +331 -0
  21. apps/backline/desk/grid.py +154 -0
  22. apps/backline/desk/look.py +169 -0
  23. apps/backline/desk/pedals.py +102 -0
  24. apps/backline/desk/perform.py +157 -0
  25. apps/backline/desk/prompt.py +210 -0
  26. apps/backline/desk/strip.py +159 -0
  27. apps/backline/desk_main.py +226 -0
  28. apps/backline/engine.py +622 -0
  29. apps/backline/floor.py +509 -0
  30. apps/backline/footswitch.py +119 -0
  31. apps/backline/glyphs.py +82 -0
  32. apps/backline/kits.py +428 -0
  33. apps/backline/midipedal.py +362 -0
  34. apps/backline/page_data.py +413 -0
  35. apps/backline/parts.py +145 -0
  36. apps/backline/pedal.py +107 -0
  37. apps/backline/remote.py +134 -0
  38. apps/backline/songs/ballad_68.json +1 -0
  39. apps/backline/songs/bossa.json +1 -0
  40. apps/backline/songs/country_train.json +1 -0
  41. apps/backline/songs/funk.json +1 -0
  42. apps/backline/songs/metal.json +1 -0
  43. apps/backline/songs/pop.json +1 -0
  44. apps/backline/songs/rock.json +1 -0
  45. apps/backline/songs/shuffle.json +1 -0
  46. apps/battery/__init__.py +101 -0
  47. apps/battery/app.json +1 -0
  48. apps/bit_world/act_deck.py +683 -0
  49. apps/bit_world/act_game.py +762 -0
  50. apps/bit_world/act_pet.py +1032 -0
  51. apps/bit_world/app.json +1 -0
  52. apps/bit_world/bit_output.py +45 -0
  53. apps/bit_world/bit_palette.py +503 -0
  54. apps/bit_world/bit_sound.py +431 -0
  55. apps/bit_world/bit_sprites.py +632 -0
  56. apps/bit_world/bit_world.py +534 -0
  57. apps/btreceiver/__init__.py +690 -0
  58. apps/btreceiver/app.json +1 -0
  59. apps/btreceiver/chime.py +155 -0
  60. apps/btreceiver/demo.py +529 -0
  61. apps/btreceiver/screen.py +633 -0
  62. apps/camera/__init__.py +316 -0
  63. apps/camera/app.json +1 -0
  64. apps/card/__init__.py +113 -0
  65. apps/card/app.json +1 -0
  66. apps/cast/__init__.py +631 -0
  67. apps/cast/app.json +1 -0
  68. apps/cast/receivers.py +193 -0
  69. apps/chess/__init__.py +18 -0
  70. apps/chess/app.json +1 -0
  71. apps/chess/app.py +922 -0
  72. apps/chess/art.py +323 -0
  73. apps/chess/ble.py +411 -0
  74. apps/chess/engine.py +925 -0
  75. apps/chess/game.py +327 -0
  76. apps/chess/net.py +261 -0
  77. apps/clock/__init__.py +38 -0
  78. apps/clock/app.json +1 -0
  79. apps/detect/__init__.py +214 -0
  80. apps/detect/app.json +1 -0
  81. apps/fmsynth/__init__.py +41 -0
  82. apps/fmsynth/algorithms.py +61 -0
  83. apps/fmsynth/app.json +1 -0
  84. apps/fmsynth/app.py +355 -0
  85. apps/fmsynth/editor.py +206 -0
  86. apps/fmsynth/engine.py +257 -0
  87. apps/fmsynth/meters.py +262 -0
  88. apps/fmsynth/midi.py +375 -0
  89. apps/fmsynth/panel_view.py +1071 -0
  90. apps/fmsynth/patches/fmsynth-01.syx +0 -0
  91. apps/fmsynth/settings.py +138 -0
  92. apps/fmsynth/voice.py +398 -0
  93. apps/gamepad/__init__.py +685 -0
  94. apps/gamepad/app.json +1 -0
  95. apps/gamepad/pad.py +94 -0
  96. apps/gamepad/watch.py +352 -0
  97. apps/hidden/__init__.py +72 -0
  98. apps/hidden/app.json +1 -0
  99. apps/home/__init__.py +483 -0
  100. apps/home/app.json +1 -0
  101. apps/home/main.py +36 -0
  102. apps/homeassistant/__init__.py +213 -0
  103. apps/homeassistant/api.py +104 -0
  104. apps/homeassistant/app.json +1 -0
  105. apps/huey/__init__.py +287 -0
  106. apps/huey/acting.py +184 -0
  107. apps/huey/actor.py +194 -0
  108. apps/huey/app.json +1 -0
  109. apps/huey/client.py +125 -0
  110. apps/huey/servers.py +121 -0
  111. apps/huey/settings.example.json +8 -0
  112. apps/huey/settings.py +97 -0
  113. apps/huey/turn.py +504 -0
  114. apps/huey/voice.py +217 -0
  115. apps/info/__init__.py +810 -0
  116. apps/info/app.json +1 -0
  117. apps/lora/__init__.py +62 -0
  118. apps/lora/app.json +1 -0
  119. apps/manifest.py +71 -0
  120. apps/medialink_baby_monitor/__init__.py +222 -0
  121. apps/medialink_baby_monitor/app.json +1 -0
  122. apps/medialink_doorbell/__init__.py +251 -0
  123. apps/medialink_doorbell/app.json +1 -0
  124. apps/medialink_hands_free/__init__.py +217 -0
  125. apps/medialink_hands_free/app.json +1 -0
  126. apps/medialink_surveillance_camera/__init__.py +258 -0
  127. apps/medialink_surveillance_camera/app.json +1 -0
  128. apps/medialink_video_doorbell/__init__.py +289 -0
  129. apps/medialink_video_doorbell/app.json +1 -0
  130. apps/medialink_videophone/__init__.py +273 -0
  131. apps/medialink_videophone/app.json +1 -0
  132. apps/medialink_walkie_talkie/__init__.py +228 -0
  133. apps/medialink_walkie_talkie/app.json +1 -0
  134. apps/midicontroller/__init__.py +774 -0
  135. apps/midicontroller/app.json +1 -0
  136. apps/midicontroller/links.py +421 -0
  137. apps/midicontroller/surface.py +343 -0
  138. apps/midiengine/__init__.py +977 -0
  139. apps/midiengine/app.json +1 -0
  140. apps/midiengine/banks.py +85 -0
  141. apps/midiengine/midiin.py +165 -0
  142. apps/midiengine/player.py +392 -0
  143. apps/midiengine/umidiparser.py +1413 -0
  144. apps/mp3/__init__.py +240 -0
  145. apps/mp3/app.json +1 -0
  146. apps/perch/__init__.py +119 -0
  147. apps/perch/app.json +1 -0
  148. apps/perch/huey.py +481 -0
  149. apps/perch/huey_props.py +386 -0
  150. apps/perch/huey_shift.py +42 -0
  151. apps/perch/huey_views.py +296 -0
  152. apps/perch/scene_bench.py +680 -0
  153. apps/perch/scene_coast.py +479 -0
  154. apps/perch/scene_desk.py +492 -0
  155. apps/perch/stage.py +1274 -0
  156. apps/perch/vec.py +366 -0
  157. apps/repl/__init__.py +325 -0
  158. apps/repl/app.json +1 -0
  159. apps/roku/__init__.py +156 -0
  160. apps/roku/app.json +1 -0
  161. apps/rokucam/__init__.py +362 -0
  162. apps/rokucam/app.json +1 -0
  163. apps/security/__init__.py +261 -0
  164. apps/security/app.json +1 -0
  165. apps/settings/__init__.py +221 -0
  166. apps/settings/app.json +1 -0
  167. apps/shell/__init__.py +33 -0
  168. apps/shell/app.json +1 -0
  169. apps/spotify/__init__.py +669 -0
  170. apps/spotify/app.json +1 -0
  171. apps/spotify/screen.py +82 -0
  172. apps/steps/__init__.py +58 -0
  173. apps/steps/app.json +1 -0
  174. apps/stompbox/__init__.py +31 -0
  175. apps/stompbox/app.json +1 -0
  176. apps/stompbox/app.py +668 -0
  177. apps/stompbox/boards.json +20 -0
  178. apps/stompbox/effects.py +241 -0
  179. apps/stompbox/engine.py +340 -0
  180. apps/stompbox/footswitch.py +331 -0
  181. apps/stompbox/inputs.py +449 -0
  182. apps/stompbox/meter.py +72 -0
  183. apps/stompbox/outputs.py +135 -0
  184. apps/stompbox/pedals.txt +45 -0
  185. apps/stompbox/presets.py +106 -0
  186. apps/stompbox/styles.py +135 -0
  187. apps/stompbox/ui.py +817 -0
  188. apps/stompbox/wavfile.py +73 -0
  189. apps/synthstation/__init__.py +20 -0
  190. apps/synthstation/app.json +1 -0
  191. apps/synthstation/audio.py +397 -0
  192. apps/synthstation/catalog.py +50 -0
  193. apps/synthstation/meters.py +136 -0
  194. apps/synthstation/midi.py +380 -0
  195. apps/synthstation/pads.py +177 -0
  196. apps/synthstation/parts.py +128 -0
  197. apps/synthstation/station.py +1069 -0
  198. apps/system/__init__.py +11 -0
  199. apps/system/app.json +1 -0
  200. apps/touchcal/__init__.py +324 -0
  201. apps/touchcal/app.json +1 -0
  202. apps/touchcal/fit.py +262 -0
  203. apps/wake/__init__.py +268 -0
  204. apps/wake/app.json +1 -0
  205. apps/wake/feed.py +155 -0
  206. apps/watch/__init__.py +355 -0
  207. apps/watch/app.json +1 -0
  208. apps/watch/faces.py +35 -0
  209. apps/watch/wheel.py +157 -0
  210. apps/weather/__init__.py +278 -0
  211. apps/weather/app.json +1 -0
  212. apps/weather/icons.py +172 -0
  213. apps/weather/sizing.py +71 -0
  214. apps/weather/zippad.py +172 -0
  215. omnipython_apps-0.1.4.dev8.dist-info/METADATA +33 -0
  216. omnipython_apps-0.1.4.dev8.dist-info/RECORD +218 -0
  217. omnipython_apps-0.1.4.dev8.dist-info/WHEEL +5 -0
  218. omnipython_apps-0.1.4.dev8.dist-info/top_level.txt +1 -0
@@ -0,0 +1,492 @@
1
+ # SPDX-FileCopyrightText: 2026 Brad Barnett
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ """The desk: a place to write code, with the chameleon keeping you company.
5
+
6
+ `draw` adds the whole scene to a `vec.Doc`, 800 by 480 units, at one of three
7
+ times of day. The window, the lamp and the light on the desk follow the time,
8
+ and the chameleon takes a pose, a place and the colours of where he stands, so
9
+ one drawing gives a wide shot, a close-up and everything between.
10
+ """
11
+
12
+ import math
13
+
14
+ from . import huey_props
15
+ from . import huey_shift
16
+ from . import huey_views
17
+ from . import huey
18
+ from .vec import at, circle, ellipse, line, mix, path, pts, rect, smooth
19
+
20
+ W, H = 800, 480
21
+ DESK_Y = 322 # the back edge of the desk top
22
+ FRONT_Y = 458 # where the top meets the front face
23
+ # where the chameleon perches: the middle of his feet, and how large
24
+ SPOTS = {"books": (160, 391, 0.58), "monitor": (338, 75, 0.4)}
25
+
26
+ NAVY = 0x0B2A4A
27
+ LIME = 0xC4DC4C
28
+ CORAL = 0xF46A45
29
+ WHITE = 0xFFFFFF
30
+
31
+ WALL = 0xA5CBC3
32
+ WOOD = 0xDDA56C
33
+ WOOD_LIGHT = 0xE9BB86
34
+ WOOD_DARK = 0xB97F4B
35
+ WOOD_FRONT = 0x9A6638
36
+ FRAME = 0xF7F1E3
37
+ FRAME_SHADE = 0xD9CDB6
38
+ CASE = 0x2A2F3A
39
+ CASE_LIGHT = 0x444B5A
40
+ SCREEN = 0x0E1B2E
41
+ KEYS = 0xECEAE4
42
+ KEYS_SHADE = 0xBDB9B0
43
+
44
+ TIMES = ("day", "evening", "night")
45
+ # How far the room's colours sink toward the evening and the night.
46
+ _AMBIENT = {"day": (0x000000, 0.0), "evening": (0x9A4B3C, 0.26), "night": (0x071A33, 0.62)}
47
+
48
+ # The view through the window: sky bands from the top, sea bands, sun or moon.
49
+ _VIEW = {
50
+ "day": ((0x6FBDEB, 0x8CCDF0, 0xAEDDF3, 0xD3EEF6), (0x2F9DB5, 0x2488A6, 0x1B7394), 0xFFF6C9),
51
+ "evening": ((0x5C4B8A, 0xB0608F, 0xF08A62, 0xFFC56B), (0xE8846A, 0x8E5A88, 0x4C4479), 0xFFF0B0),
52
+ "night": ((0x081B38, 0x0D274B, 0x14345E, 0x1D4470), (0x163A63, 0x0F2C50, 0x0A2140), 0xF6F2D8),
53
+ }
54
+
55
+ # The code on the monitor: each row an indent and its (length, colour) words.
56
+ _CODE_COLORS = (0xC4DC4C, 0xFF8A66, 0x6EC6FF, 0xD7DEE8, 0xB79CFF, 0x5B6B82)
57
+ _CODE = (
58
+ (0, ((30, 4), (44, 3))),
59
+ (0, ((30, 4), (26, 3), (18, 5))),
60
+ (0, ()),
61
+ (0, ((22, 4), (40, 0), (16, 3))),
62
+ (1, ((34, 3), (10, 5), (30, 2))),
63
+ (1, ((20, 4), (46, 3))),
64
+ (2, ((40, 0), (22, 1), (14, 3))),
65
+ (2, ((28, 3), (10, 5), (36, 1))),
66
+ (1, ((26, 4), (30, 2))),
67
+ (0, ()),
68
+ (0, ((40, 0), (24, 3))),
69
+ )
70
+
71
+
72
+ def _toner(time):
73
+ color, amount = _AMBIENT[time]
74
+
75
+ def tone(c):
76
+ return mix(c, color, amount)
77
+
78
+ return tone
79
+
80
+
81
+ def _room(tone, time):
82
+ # the wall goes on above the picture, for a view that follows something up the monitor
83
+ out = [rect(0, -200, W, DESK_Y + 202, tone(WALL))]
84
+ if time != "night":
85
+ # the window's light, thrown down the wall to the left
86
+ glow = 0xFFF4C8 if time == "day" else 0xFFB37A
87
+ out.append(path(pts(((538, 60), (538, 256), (300, 322), (120, 322)), True), glow, opacity=0.13))
88
+ # a line of shade where the wall meets the desk
89
+ out.append(rect(0, DESK_Y - 8, W, 10, tone(mix(WALL, NAVY, 0.18))))
90
+ out.append(rect(0, DESK_Y, W, FRONT_Y - DESK_Y, tone(WOOD)))
91
+ out.append(rect(0, DESK_Y, W, 5, tone(WOOD_LIGHT)))
92
+ grain = tone(WOOD_DARK)
93
+ for x0, y, length in ((30, 352, 150), (250, 344, 90), (520, 340, 170), (90, 396, 110), (430, 442, 190), (660, 404, 110), (20, 446, 80), (300, 428, 70)):
94
+ out.append(line(x0, y, x0 + length, y, grain, 2, opacity=0.35))
95
+ out.append(rect(0, FRONT_Y, W, H - FRONT_Y, tone(WOOD_FRONT)))
96
+ out.append(rect(0, FRONT_Y, W, 4, tone(WOOD_DARK)))
97
+ return b"".join(out)
98
+
99
+
100
+ def _sunlight(time):
101
+ # the window's two halves, laid across the desk by the sun
102
+ if time == "night":
103
+ return b""
104
+ color = 0xFFF4C8 if time == "day" else 0xFFB37A
105
+ out = [path(pts(((452, DESK_Y), (566, DESK_Y), (470, FRONT_Y), (320, FRONT_Y)), True), color, opacity=0.26)]
106
+ out.append(path(pts(((578, DESK_Y), (690, DESK_Y), (630, FRONT_Y), (486, FRONT_Y)), True), color, opacity=0.26))
107
+ return b"".join(out)
108
+
109
+
110
+ def _window(tone, time):
111
+ x0, y0, w, h = 552, 44, 208, 200
112
+ sky, sea, disc = _VIEW[time]
113
+ out = []
114
+ horizon = y0 + 132
115
+ band = (horizon - y0) / 4
116
+ for i in range(4):
117
+ out.append(rect(x0, y0 + i * band, w, band + 1, sky[i]))
118
+ if time == "night":
119
+ for sx, sy, r in ((572, 62, 1.6), (606, 92, 1.2), (640, 58, 1.8), (700, 60, 1.4), (744, 122, 1.2), (590, 128, 1.3), (696, 150, 1.5), (676, 104, 1.1)):
120
+ out.append(circle(sx, sy, r, 0xEAF2FF))
121
+ # the moon sits inside one band of sky, so the bite out of it is that band's colour
122
+ out.append(circle(712, 93, 14, disc))
123
+ out.append(circle(719, 89, 11, sky[1]))
124
+ # the lighthouse's beam, sweeping out to sea
125
+ out.append(path(pts(((x0 + 34, horizon - 51), (x0 + 150, horizon - 70), (x0 + 150, horizon - 38)), True), 0xFFF3B0, opacity=0.22))
126
+ else:
127
+ sun_y = y0 + 52 if time == "day" else horizon - 8
128
+ sun_x = 700 if time == "day" else 680
129
+ out.append(circle(sun_x, sun_y, 34, disc, opacity=0.28))
130
+ out.append(circle(sun_x, sun_y, 25, disc, opacity=0.4))
131
+ out.append(circle(sun_x, sun_y, 17, disc))
132
+ cloud = WHITE if time == "day" else 0xFFD9B8
133
+ for cx, cy, s in ((606, 84, 1.0), (724, 134, 0.7)):
134
+ out.append(rect(cx - 26 * s, cy, 56 * s, 12 * s, cloud, r=6 * s, opacity=0.92))
135
+ out.append(circle(cx - 8 * s, cy, 12 * s, cloud, opacity=0.92))
136
+ out.append(circle(cx + 10 * s, cy - 3 * s, 15 * s, cloud, opacity=0.92))
137
+ # the sea, and the light lying on it
138
+ step = (y0 + h - horizon) / 3
139
+ for i in range(3):
140
+ out.append(rect(x0, horizon + i * step, w, step + 1, sea[i]))
141
+ if time != "night":
142
+ glint = 0xFFFFFF if time == "day" else 0xFFE3A0
143
+ gx = 700 if time == "day" else 680
144
+ for i, half in enumerate((30, 20, 26, 14)):
145
+ out.append(rect(gx - half, horizon + 5 + i * 11, half * 2, 3, glint, r=1.5, opacity=0.7))
146
+ # a headland and its lighthouse
147
+ land = (0x4F8F6A, 0x3E5E73, 0x0B1E33)[TIMES.index(time)]
148
+ out.append(path("M%d %dL%d %dC%d %d %d %d %d %dZ" % (x0, horizon + 6, x0, horizon - 20, x0 + 34, horizon - 30, x0 + 66, horizon - 2, x0 + 100, horizon + 6), land))
149
+ lx = x0 + 28
150
+ out.append(path(pts(((lx, horizon - 20), (lx + 12, horizon - 20), (lx + 10, horizon - 48), (lx + 2, horizon - 48)), True), 0xF4F1EA if time != "night" else 0x8FA3BD))
151
+ out.append(rect(lx + 1.4, horizon - 38, 9.2, 6, CORAL if time != "night" else 0x8B4A4A))
152
+ out.append(rect(lx, horizon - 54, 12, 6, CASE))
153
+ out.append(rect(lx + 2.5, horizon - 53, 7, 4, 0xFFF3B0))
154
+
155
+ # the frame over the view's edges, its bars, and the sill
156
+ frame, shade = tone(FRAME), tone(FRAME_SHADE)
157
+ out.append(rect(x0 - 7, y0 - 7, w + 14, h + 14, None, stroke=frame, width=14))
158
+ out.append(rect(x0 + w / 2 - 4, y0, 8, h, frame))
159
+ out.append(rect(x0, y0 + 62, w, 7, frame))
160
+ out.append(rect(x0 + w / 2 - 4, y0, 2.5, h, shade))
161
+ out.append(rect(x0, y0 + 67, w, 2, shade))
162
+ out.append(rect(x0 - 26, y0 + h + 12, w + 52, 13, frame, r=3))
163
+ out.append(rect(x0 - 20, y0 + h + 25, w + 40, 5, tone(mix(WALL, NAVY, 0.22))))
164
+ return b"".join(out)
165
+
166
+
167
+ def _picture(tone):
168
+ # a framed print of a shell: one line winding in to the middle
169
+ out = [rect(36, 26, 100, 84, tone(0x8A5A36), r=3)]
170
+ out.append(rect(42, 32, 88, 72, tone(FRAME)))
171
+ out.append(rect(49, 39, 74, 58, tone(0x1C6E8C)))
172
+ cx, cy = 86, 69
173
+ spiral = []
174
+ for i in range(22):
175
+ a = i * 0.62
176
+ r = 23 * (1 - i / 24)
177
+ spiral.append((cx + math.cos(a) * r, cy + math.sin(a) * r * 0.92))
178
+ out.append(path(smooth(spiral), None, tone(0xFFF6E0), 4.2))
179
+ out.append(circle(spiral[0][0], spiral[0][1], 3.6, tone(LIME)))
180
+ return b"".join(out)
181
+
182
+
183
+ def _monitor(tone, time):
184
+ x0, y0, w, h = 226, 74, 300, 204
185
+ mid = x0 + w / 2
186
+ out = []
187
+ # stand
188
+ out.append(ellipse(mid + 6, DESK_Y + 14, 92, 9, 0x000000, opacity=0.14))
189
+ out.append(path(pts(((mid - 16, y0 + h - 6), (mid + 16, y0 + h - 6), (mid + 22, DESK_Y + 8), (mid - 22, DESK_Y + 8)), True), tone(CASE_LIGHT)))
190
+ out.append(path(pts(((mid - 16, y0 + h - 6), (mid - 4, y0 + h - 6), (mid - 6, DESK_Y + 8), (mid - 22, DESK_Y + 8)), True), tone(CASE)))
191
+ out.append(ellipse(mid, DESK_Y + 10, 62, 8, tone(CASE)))
192
+ out.append(ellipse(mid, DESK_Y + 8, 62, 7, tone(CASE_LIGHT)))
193
+ # case and screen
194
+ out.append(rect(x0, y0, w, h, tone(CASE), r=11))
195
+ out.append(rect(x0 + 8, y0 + 2, w - 16, 3, tone(CASE_LIGHT), r=1.5))
196
+ sx, sy, sw, sh = x0 + 10, y0 + 10, w - 20, h - 24
197
+ out.append(rect(sx, sy, sw, sh, SCREEN, r=3))
198
+ # the editor's title strip and its three lights
199
+ out.append(rect(sx, sy, sw, 14, 0x16263D, r=3))
200
+ for i, c in enumerate((0xFF6B5E, 0xFFC24A, LIME)):
201
+ out.append(circle(sx + 10 + i * 10, sy + 7, 2.8, c))
202
+ out.append(rect(sx + 56, sy + 3, 60, 11, SCREEN, r=3))
203
+ out.append(rect(sx + 64, sy + 7, 34, 3, 0x8FA3BD, r=1.5))
204
+ # the file tree down the left
205
+ out.append(rect(sx, sy + 14, 46, sh - 14, 0x122036))
206
+ for i, (ind, length) in enumerate(((0, 26), (6, 24), (6, 30), (6, 18), (0, 22), (6, 28), (6, 20))):
207
+ c = LIME if i == 2 else 0x4E6079
208
+ out.append(rect(sx + 7 + ind, sy + 24 + i * 11, length, 3.4, c, r=1.7))
209
+ # code
210
+ left = sx + 56
211
+ y = sy + 25
212
+ for n, (indent, words) in enumerate(_CODE):
213
+ out.append(rect(left, y, 5, 3, 0x33455F, r=1.5))
214
+ x = left + 13 + indent * 14
215
+ for length, color in words:
216
+ out.append(rect(x, y - 0.5, length, 4.4, _CODE_COLORS[color], r=2.2))
217
+ x += length + 6
218
+ if n == 7:
219
+ out.append(rect(x + 1, y - 3, 3, 9, WHITE))
220
+ y += 11.4
221
+ # the pane at the right: what the code draws
222
+ px, py, pw, ph = sx + sw - 92, sy + 22, 84, sh - 30
223
+ out.append(rect(px, py, pw, ph, 0x16263D, r=5))
224
+ wave = []
225
+ for i in range(13):
226
+ wave.append((px + 8 + i * 5.6, py + 34 + math.sin(i * 0.82) * 15))
227
+ out.append(path(smooth(wave), None, LIME, 2.4))
228
+ out.append(circle(wave[4][0], wave[4][1], 3.4, WHITE))
229
+ for i, height in enumerate((18, 30, 24, 40, 34, 22)):
230
+ out.append(rect(px + 9 + i * 11.6, py + ph - 12 - height, 8, height, (0x6EC6FF, 0xFF8A66)[i == 3], r=2))
231
+ out.append(rect(px + 8, py + ph - 11, pw - 16, 2, 0x4E6079, r=1))
232
+ # the glass catches the window
233
+ out.append(path(pts(((sx + sw - 54, sy), (sx + sw - 22, sy), (sx + sw - 96, sy + sh), (sx + sw - 128, sy + sh)), True), WHITE, opacity=0.035))
234
+ # the maker's light
235
+ out.append(circle(mid, y0 + h - 7, 2.2, LIME))
236
+ if time == "night":
237
+ out.append(ellipse(mid, DESK_Y + 44, 170, 30, 0x6EC6FF, opacity=0.10))
238
+ return b"".join(out)
239
+
240
+
241
+ def _notes(tone):
242
+ out = []
243
+ for x, y, rot, c, dark in ((192, 92, -6, 0xFFE27A, 0xE3BF47), (196, 136, 5, 0xFF9FB2, 0xE07A90)):
244
+ body = rect(-17, 0, 34, 34, tone(c)) + path("M17 34L5 34L17 22Z", tone(dark))
245
+ body += rect(-11, 8, 22, 2.6, tone(dark), r=1.3) + rect(-11, 15, 15, 2.6, tone(dark), r=1.3)
246
+ out.append(at(x, y, body, rot=rot))
247
+ return b"".join(out)
248
+
249
+
250
+ def _keyboard(tone):
251
+ top, bottom = 366, 418
252
+ xl0, xr0, xl1, xr1 = 306, 512, 292, 526
253
+ out = [ellipse(412, bottom + 6, 128, 8, 0x000000, opacity=0.15)]
254
+ out.append(path(pts(((xl1, bottom), (xr1, bottom), (xr1, bottom + 6), (xl1, bottom + 6)), True), tone(0x8E8A82)))
255
+ out.append(path(pts(((xl0, top), (xr0, top), (xr1, bottom), (xl1, bottom)), True), tone(0xCFCBC2)))
256
+ rows = 5
257
+ for r in range(rows):
258
+ t0, t1 = (r + 0.16) / rows, (r + 0.86) / rows
259
+ y0, y1 = top + 3 + (bottom - top - 6) * t0, top + 3 + (bottom - top - 6) * t1
260
+ left = xl0 + (xl1 - xl0) * t0 + 6
261
+ right = xr0 + (xr1 - xr0) * t0 - 6
262
+ if r == rows - 1:
263
+ cells = ((0, 2), (2, 3.6), (3.6, 9.6), (9.6, 11.2), (11.2, 13))
264
+ else:
265
+ cells = [(i, i + 1) for i in range(13)]
266
+ for a, b in cells:
267
+ kx0 = left + (right - left) * a / 13 + 1.2
268
+ kx1 = left + (right - left) * b / 13 - 1.2
269
+ c = KEYS
270
+ if r == 0 and a == 0:
271
+ c = CORAL
272
+ elif r == 2 and a == 12:
273
+ c = LIME
274
+ out.append(rect(kx0, y0 + 1.4, kx1 - kx0, y1 - y0, tone(KEYS_SHADE), r=1.8))
275
+ out.append(rect(kx0, y0, kx1 - kx0, y1 - y0 - 0.6, tone(c), r=1.8))
276
+ return b"".join(out)
277
+
278
+
279
+ def _mug(tone):
280
+ x, y = 606, 386 # the middle of its foot
281
+ out = [ellipse(x - 6, y + 1, 30, 6, 0x000000, opacity=0.16)]
282
+ out.append(circle(x - 21, y - 21, 10, None, tone(0x123A5E), 5.5))
283
+ out.append(path("M%d %dL%d %dQ%d %d %d %dL%d %dQ%d %d %d %dL%d %dZ" % (x - 19, y - 40, x - 19, y - 6, x - 19, y + 2, x - 11, y + 2, x + 11, y + 2, x + 19, y + 2, x + 19, y - 6, x + 19, y - 40), tone(NAVY)))
284
+ out.append(path("M%d %dL%d %dQ%d %d %d %dL%d %dZ" % (x - 19, y - 40, x - 19, y - 6, x - 19, y + 2, x - 11, y + 2, x - 9, y - 40), tone(0x061A30)))
285
+ out.append(rect(x - 19, y - 22, 38, 6, tone(LIME)))
286
+ out.append(ellipse(x, y - 40, 19, 5.5, tone(0x1D4470)))
287
+ out.append(ellipse(x, y - 39.4, 15.5, 3.8, tone(0x5B3524)))
288
+ out.append(rect(x + 10, y - 34, 3.4, 9, tone(0x4A6FA5), r=1.7))
289
+ for dx, lift in ((-5, 0), (6, 8)):
290
+ x1, y1 = x + dx, y - 46 - lift
291
+ d = "M%d %dC%d %d %d %d %d %dC%d %d %d %d %d %d" % (x1, y1, x1 - 8, y1 - 10, x1 + 8, y1 - 18, x1, y1 - 28, x1 - 7, y1 - 36, x1 + 5, y1 - 42, x1 + 1, y1 - 50)
292
+ out.append(path(d, None, WHITE, 3.4, opacity=0.42))
293
+ return b"".join(out)
294
+
295
+
296
+ def _leaf(x, y, length, width, rot, light, dark):
297
+ body = path("M0 0C%.1f %.1f %.1f %.1f 0 %.1fC%.1f %.1f %.1f %.1f 0 0Z" % (width, -length * 0.25, width, -length * 0.8, -length, -width, -length * 0.8, -width, -length * 0.25), light)
298
+ body += path("M0 0C%.1f %.1f %.1f %.1f 0 %.1fZ" % (-width, -length * 0.25, -width, -length * 0.8, -length), dark)
299
+ return at(x, y, body, rot=rot)
300
+
301
+
302
+ def _plant(tone):
303
+ out = []
304
+ # two books, lying flat
305
+ out.append(ellipse(718, 349, 76, 7, 0x000000, opacity=0.15))
306
+ out.append(rect(658, 334, 128, 14, tone(0x2F6F7E), r=2))
307
+ out.append(rect(664, 337, 116, 3, tone(0xF2EAD8)))
308
+ out.append(rect(666, 344, 22, 2, tone(0x7FB6C2)))
309
+ out.append(rect(670, 320, 108, 14, tone(0xE0A83A), r=2))
310
+ out.append(rect(676, 323, 96, 3, tone(0xF2EAD8)))
311
+ out.append(rect(752, 329, 18, 2, tone(0xF7D58A)))
312
+ # stems and leaves, the back ones first
313
+ green, deep, pale = tone(0x4E9A63), tone(0x2F6E4A), tone(0x7CC27F)
314
+ px, py = 726, 268
315
+ for tx, ty in ((690, 214), (756, 196), (722, 176), (776, 236), (676, 250)):
316
+ out.append(path("M%d %dQ%d %d %d %d" % (px, py, (px + tx) // 2, ty + 20, tx, ty), None, deep, 3))
317
+ out.append(_leaf(676, 252, 44, 15, -74, green, deep))
318
+ out.append(_leaf(776, 238, 46, 16, 62, pale, green))
319
+ out.append(_leaf(690, 216, 54, 18, -38, pale, green))
320
+ out.append(_leaf(756, 198, 56, 19, 30, green, deep))
321
+ out.append(_leaf(722, 178, 58, 19, -4, pale, green))
322
+ # pot
323
+ out.append(path(pts(((698, 272), (758, 272), (750, 320), (706, 320)), True), tone(0xF4EFE6)))
324
+ out.append(path(pts(((698, 272), (716, 272), (720, 320), (706, 320)), True), tone(0xD6CDBD)))
325
+ out.append(rect(693, 264, 70, 11, tone(0xFFFBF2), r=3))
326
+ out.append(rect(693, 264, 20, 11, tone(0xE4DCCD), r=3))
327
+ out.append(rect(706, 296, 44, 5, tone(CORAL)))
328
+ return b"".join(out)
329
+
330
+
331
+ def _lamp(tone, on):
332
+ body, dark = tone(LIME), tone(0x93AA2E)
333
+ arm = tone(0x3A4150)
334
+ out = [ellipse(40, 352, 44, 8, 0x000000, opacity=0.15)]
335
+ out.append(ellipse(44, 346, 38, 9, dark))
336
+ out.append(ellipse(44, 343, 38, 8, body))
337
+ out.append(line(44, 340, 24, 250, arm, 6))
338
+ out.append(line(24, 250, 78, 178, arm, 6))
339
+ out.append(circle(24, 250, 7, tone(CASE)))
340
+ # the shade, pointing down and to the right
341
+ head = path("M-12 -8L12 -8L34 32L-34 32Z", body) + path("M-12 -8L-2 -8L-10 32L-34 32Z", dark)
342
+ head += rect(-9, -17, 18, 10, tone(CASE), r=3)
343
+ head += ellipse(0, 32, 34, 6, 0xFFF6D2 if on else dark)
344
+ out.append(at(78, 178, head, rot=-24))
345
+ return b"".join(out)
346
+
347
+
348
+ def _lamp_light(time):
349
+ # the cone through the air, and the pool it leaves on the desk
350
+ cone = path(pts(((62, 196), (120, 222), (330, 440), (0, 452), (0, 330)), True), 0xFFE9A8, opacity=0.10 if time == "evening" else 0.13)
351
+ pool = ellipse(166, 426, 178, 28, 0xFFDFA0, opacity=0.22 if time == "evening" else 0.30)
352
+ return cone + pool
353
+
354
+
355
+ def _board(doc, tone):
356
+ # drawn about its own middle, so it can sit at an angle
357
+ out = [ellipse(2, 16, 62, 9, 0x000000, opacity=0.16)]
358
+ out.append(rect(-54, -18, 108, 34, tone(0x061A30), r=5))
359
+ out.append(rect(-54, -20, 108, 34, tone(NAVY), r=5))
360
+ for x, y in ((-48, -14), (48, -14), (-48, 8), (48, 8)):
361
+ out.append(circle(x, y, 2.6, tone(0xD9B45A)))
362
+ # the processor, its radio can and the traces between them
363
+ out.append(path("M-6 -3L8 -3L14 -9L30 -9M-6 3L10 3L16 9L36 9M-20 -10L-20 -15L-34 -15", None, tone(0x1F5E8F), 1.6))
364
+ out.append(rect(-24, -11, 18, 18, tone(0x15171C), r=2))
365
+ out.append(rect(-20, -7, 10, 10, tone(0x2F343F), r=1))
366
+ out.append(rect(14, -15, 24, 14, tone(0xC9CED6), r=2))
367
+ out.append(rect(17, -12, 18, 3, tone(0xEEF1F5), r=1))
368
+ for i in range(10):
369
+ out.append(rect(-38 + i * 7.6, 8, 4, 4, tone(0xD9B45A), r=1))
370
+ out.append(rect(-62, -9, 14, 14, tone(0xC9CED6), r=2))
371
+ # its light is on
372
+ halo = doc.radial([(0, LIME, 0.75), (1, LIME, 0)])
373
+ out.append(circle(43, -3, 11, halo))
374
+ out.append(circle(43, -3, 3, 0xF4FFB0))
375
+ return b"".join(out)
376
+
377
+
378
+ def _cable(tone):
379
+ points = ((598, 433), (572, 430), (552, 416), (548, 388), (532, 352), (480, 338), (424, 336))
380
+ return path(smooth(points), None, tone(0x1D2430), 4.4)
381
+
382
+
383
+ def _bubble(x, y):
384
+ out = []
385
+ for cx, cy, r in ((x + 62, y + 62, 5), (x + 50, y + 46, 8)):
386
+ out.append(circle(cx + 1.5, cy + 2, r, NAVY, opacity=0.14))
387
+ out.append(circle(cx, cy, r, WHITE))
388
+ out.append(ellipse(x + 2, y + 4, 52, 35, NAVY, opacity=0.14))
389
+ for cx, cy, r in ((x - 24, y + 6, 26), (x + 24, y + 8, 25), (x - 6, y - 12, 26), (x + 22, y - 8, 22), (x, y + 12, 26)):
390
+ out.append(circle(cx, cy, r, WHITE))
391
+ for i, c in enumerate((NAVY, NAVY, CORAL)):
392
+ out.append(circle(x - 20 + i * 20, y + 2, 5.6, c))
393
+ return b"".join(out)
394
+
395
+
396
+ def _stack(tone):
397
+ # two books by the keyboard: somewhere to stand
398
+ out = [ellipse(160, 441, 150, 9, 0x000000, opacity=0.16)]
399
+ out.append(rect(26, 414, 250, 25, tone(0x23466B), r=3))
400
+ out.append(rect(26, 414, 250, 4, tone(0x3A6491), r=2))
401
+ out.append(rect(44, 421, 8, 18, tone(LIME)))
402
+ out.append(rect(58, 421, 3, 18, tone(LIME)))
403
+ out.append(rect(186, 424, 62, 4, tone(0x7FA3C9), r=2))
404
+ out.append(rect(44, 391, 218, 23, tone(0xEFE6D2), r=3))
405
+ out.append(rect(44, 410, 218, 4, tone(0xCDBFA3), r=2))
406
+ out.append(rect(224, 391, 9, 23, tone(CORAL)))
407
+ out.append(rect(70, 399, 74, 4, tone(0xB9AB90), r=2))
408
+ out.append(rect(70, 406, 44, 3, tone(0xB9AB90), r=1.5))
409
+ return b"".join(out)
410
+
411
+
412
+ def _scheme(time, spot):
413
+ # he takes his colours from where he stands
414
+ if time == "night":
415
+ return "night"
416
+ if spot == "monitor":
417
+ return "brand" if time == "day" else huey_shift.between("brand", "sunset", 0.35)
418
+ return "leaf" if time == "day" else "sunset"
419
+
420
+
421
+ def _chameleon(doc, time, spot, pose, colors, look, look_far, blink, mood, wave, nod, prop):
422
+ x, y, scale = SPOTS[spot]
423
+ if colors is None:
424
+ colors = _scheme(time, spot)
425
+ if pose == "front":
426
+ body = huey_views.front(doc, look=look, look_other=look_far, blink=blink, mood=mood, colors=colors, hand=wave, perch=None)
427
+ elif pose == "three_quarter":
428
+ body = huey_views.three_quarter(doc, look=look, look_far=look_far, blink=blink, mood=mood, colors=colors, perch=None)
429
+ elif pose == "sit":
430
+ body = huey.draw_sit(doc, look=look, look_far=look_far, blink=blink, mood=mood, colors=colors, perch=None, wave=wave)
431
+ elif pose == "sleep":
432
+ body = huey.draw_sleep(doc, colors=colors, perch=None)
433
+ elif pose == "hold":
434
+ body = huey_props.hold(doc, prop, look=look, look_far=look_far, blink=blink, mood=mood, colors=colors, perch=None)
435
+ else:
436
+ body = huey.draw(doc, look=look, look_far=look_far, blink=blink, mood=mood, colors=colors, hand=wave, perch=None, nod=nod)
437
+ # his shadow lies on what he stands on
438
+ shadow = ellipse(x - 4, y + 2, 170 * scale, 5, 0x000000, opacity=0.16) if spot == "books" else b""
439
+ return shadow + at(x, y, body, scale=scale)
440
+
441
+
442
+ def draw(doc, who="chameleon", time="day", mood="calm", look=None, look_far=None, wave=0, blink=0, bubble=False, pose="three_quarter", spot="books", colors=None, nod=0, prop=None):
443
+ """Add the desk and its company to *doc*.
444
+
445
+ Args:
446
+ doc: The `vec.Doc` to draw into.
447
+ who (str): "chameleon", or "stage" for the desk without him.
448
+ time (str): "day", "evening" or "night". The lamp is on after day.
449
+ mood (str): "calm", "happy", "curious" or "sleepy".
450
+ look: Where the near eye points, each of x and y from -1 to 1.
451
+ look_far: Where the chameleon's other eye points, or None for the same way.
452
+ wave (float): The chameleon's raised hand, 0 to 1.
453
+ blink (float): 0 with the eyes open, 1 closed.
454
+ bubble (bool): Draw a thought bubble.
455
+ pose (str): The chameleon's: "three_quarter", "side", "front", "sit", "sleep" or "hold".
456
+ spot (str): Where the chameleon perches, a name from `SPOTS`.
457
+ colors (str): A scheme from `huey.COLORS`, or None for the one that suits the time and the spot.
458
+ nod (float): The chameleon's head tilt in the "side" pose, in degrees, positive chin down.
459
+ prop (str): What he holds in the "hold" pose, a name from `huey_props.PROPS`.
460
+ """
461
+ tone = _toner(time)
462
+ lit = time != "day"
463
+ if look is None:
464
+ look = (0.3, 0.1)
465
+ doc.add(_room(tone, time))
466
+ doc.add(_picture(tone))
467
+ doc.add(_window(tone, time))
468
+ doc.add(_sunlight(time))
469
+ doc.add(_lamp(tone, lit))
470
+ doc.add(_plant(tone))
471
+ doc.add(_monitor(tone, time))
472
+ doc.add(_notes(tone))
473
+ if who == "chameleon" and spot == "monitor":
474
+ doc.add(_chameleon(doc, time, spot, pose, colors, look, look_far, blink, mood, wave, nod, prop))
475
+ doc.add(_cable(tone))
476
+ if prop != "mug":
477
+ doc.add(_mug(tone))
478
+ doc.add(_keyboard(tone))
479
+ doc.add(at(664, 436, _board(doc, tone), rot=-7))
480
+ if lit:
481
+ doc.add(_lamp_light(time))
482
+ # the books stand in the lamp's light, so they keep more of their colour
483
+ doc.add(_stack((lambda c: mix(tone(c), c, 0.5)) if lit else tone))
484
+ if who != "chameleon":
485
+ x, y, scale = SPOTS["books"]
486
+ doc.add(ellipse(x - 4, y + 2, 170 * scale, 5, 0x000000, opacity=0.16))
487
+ return
488
+ if spot != "monitor":
489
+ doc.add(_chameleon(doc, time, spot, pose, colors, look, look_far, blink, mood, wave, nod, prop))
490
+ if bubble:
491
+ x, y, scale = SPOTS[spot]
492
+ doc.add(_bubble(x - 76, y - 330 * scale))