Skip to content

Instantly share code, notes, and snippets.

@binocularity
Last active October 30, 2022 11:34
Show Gist options
  • Save binocularity/f73d2e94589020c9cd65c122b8d80092 to your computer and use it in GitHub Desktop.
Save binocularity/f73d2e94589020c9cd65c122b8d80092 to your computer and use it in GitHub Desktop.
req = HTTPRequest[
"http://api.thingspeak.com/channels/1417/field/2/last.json"];
f[] := (
colour = Brown;
reqStat = Quiet[ URLRead[ req, TimeConstraint -> 2]];
If[ Not[FailureQ[reqStat]],
( rawData = Import[req];
colour = RGBColor[Lookup[ rawData, "field2"]]; )
];
colour
)
(* jack-o-latern CCby4.0 Vincent Le Moign from
https://commons.wikimedia.org/wiki/File:659-jack-o-lantern.svg *)
jack = ResourceFunction["SVGImport"][
StringJoin[NotebookDirectory[], "jack-o-lantern.svg"]];
backdrop[] := (
LinearGradientImage[{Bottom, Top} -> {Evaluate[f[]], Black}, {50,
50}])
eyes[] := ( Graphics[{Evaluate[f[]], Disk[{15.5, 28}, 2.7], Disk[{32.5, 28}, 2.7]}] )
draw[] := (
Show[ backdrop[], jack, eyes[], ImageSize -> {400, 400}])
CreateDocument[ Dynamic[ draw[], UpdateInterval -> 10] ] ;
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@binocularity
Copy link
Author

NB you need to copy and paste this into Mathematica it is not a .nb notebook.
NB 2 it should work with Wolfram Engine/Mathematica free on the Raspberry PI but I have not tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment