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
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" id="Icons" x="0" y="0" version="1.1" viewBox="0 0 48 48">
<style>
.st4{fill:none;stroke:#45413c;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10}.st38{fill:#ffe500}.st46{fill:#ebcb00}
</style>
<path id="XMLID_16278_" fill="#6dd627" d="M27.4 2c.6.2 1 .8 1 1.4v10h-8.8v-10c0-.6.4-1.2 1-1.4 2.2-.8 4.6-.8 6.8 0z"/>
<path id="XMLID_16277_" fill="#9ceb60" d="M27.4 2c-2.2-.8-4.6-.8-6.9 0-.6.2-1 .8-1 1.4v2.2c0-.6.4-1.2 1-1.4 2.2-.8 4.6-.8 6.9 0 .6.2 1 .8 1 1.4V3.4c0-.6-.4-1.2-1-1.4z"/>
<ellipse id="XMLID_16276_" cx="24" cy="45.1" fill="#45413c" opacity=".15" rx="14.9" ry="1.9"/>
<path id="XMLID_16275_" d="M27.4 2c.6.2 1 .8 1 1.4v10h-8.8v-10c0-.6.4-1.2 1-1.4 2.2-.8 4.6-.8 6.8 0z" class="st4"/>
<path id="XMLID_16274_" fill="#ff8a14" d="M43.9 26.6c0-7.9-3.2-12.6-8.1-15.2-1.2-1.4-3.4-2.7-7.2-3.2-.9-.8-2.3-1.4-4.6-1.4s-3.7.6-4.6 1.4c-3.8.6-6 1.9-7.2 3.3-4.9 2.6-8.1 7.4-8.1 15.1 0 6.5 1.8 11.2 7 13.8.7 1.5 2.8 3.3 8.4 4 .9.6 2.3 1.1 4.6 1.1s3.7-.5 4.6-1.1c5.6-.6 7.6-2.5 8.4-4 5-2.5 6.8-7.2 6.8-13.8z"/>
<path id="XMLID_16273_" fill="#ffaa54" d="M12.2 14.8c1.2-1.4 3.4-2.7 7.2-3.3.9-.8 2.3-1.4 4.6-1.4s3.7.6 4.6 1.4c3.8.6 5.9 1.9 7.2 3.2 4.6 2.4 7.7 6.7 8.1 13.6 0-.6.1-1.1.1-1.7 0-7.9-3.2-12.6-8.1-15.2-1.2-1.4-3.4-2.7-7.2-3.2-.9-.8-2.3-1.4-4.6-1.4s-3.7.6-4.6 1.4c-3.8.6-6 1.9-7.2 3.3-4.9 2.6-8.1 7.4-8.1 15.1 0 .6 0 1.2.1 1.7.3-6.8 3.3-11 7.9-13.5z"/>
<path id="XMLID_16272_" d="M43.9 26.6c0-7.9-3.2-12.6-8.1-15.2-1.2-1.4-3.4-2.7-7.2-3.2-.9-.8-2.3-1.4-4.6-1.4s-3.7.6-4.6 1.4c-3.8.6-6 1.9-7.2 3.3-4.9 2.6-8.1 7.4-8.1 15.1 0 6.5 1.8 11.2 7 13.8.7 1.5 2.8 3.3 8.4 4 .9.6 2.3 1.1 4.6 1.1s3.7-.5 4.6-1.1c5.6-.6 7.6-2.5 8.4-4 5-2.5 6.8-7.2 6.8-13.8z" class="st4"/>
<path d="M26.3 26.6 24.8 25c-.2-.3-.5-.4-.8-.4s-.6.1-.8.4l-1.4 1.7c-.3.4-.4.9-.2 1.3.4.7 1.4.9 1.9.3.1-.1.3-.2.5-.2s.3.1.5.2c.6.6 1.6.4 1.9-.3.2-.5.2-1-.1-1.4z" class="st38"/>
<path id="XMLID_16271_" d="m21.8 28.3 1.3-1.6c.4-.5 1.3-.5 1.7 0l1.3 1.6.3-.3c.2-.4.2-.9-.2-1.3L24.8 25c-.4-.5-1.3-.5-1.7 0l-1.4 1.7c-.3.4-.4.9-.2 1.3.2.1.2.2.3.3z" class="st46"/>
<path d="M26.3 26.6 24.8 25c-.2-.3-.5-.4-.8-.4s-.6.1-.8.4l-1.4 1.7c-.3.4-.4.9-.2 1.3.4.7 1.4.9 1.9.3.1-.1.3-.2.5-.2s.3.1.5.2c.6.6 1.6.4 1.9-.3.2-.5.2-1-.1-1.4z" class="st4"/>
<path id="XMLID_16270_" d="M34.4 17.2c1.7 1.7 2.6 3.7.8 5.5-1.8 1.8-3.7.9-5.5-.8s-2.1-4.2-.8-5.5 3.8-.9 5.5.8z" class="st38"/>
<path id="XMLID_16269_" d="M13.6 17.2c-1.7 1.7-2.6 3.7-.8 5.5 1.8 1.8 3.7.9 5.5-.8s2.1-4.2.8-5.5-3.8-.9-5.5.8z" class="st38"/>
<path id="XMLID_16268_" d="M28.9 18.4c1.3-1.3 3.7-.9 5.5.8.7.7 1.3 1.5 1.6 2.3.6-1.4-.2-2.9-1.6-4.3-1.7-1.7-4.2-2.1-5.5-.8-.7.7-.9 1.9-.6 3 .1-.4.3-.7.6-1z" class="st46"/>
<path id="XMLID_16267_" d="M13.6 19.1c1.7-1.7 4.2-2.1 5.5-.8.3.3.5.7.6 1.1.3-1.2.1-2.3-.6-3-1.3-1.3-3.7-.9-5.5.8-1.3 1.3-2.1 2.8-1.6 4.3.3-.8.9-1.6 1.6-2.4z" class="st46"/>
<path id="XMLID_16266_" d="M34.4 17.2c1.7 1.7 2.6 3.7.8 5.5-1.8 1.8-3.7.9-5.5-.8s-2.1-4.2-.8-5.5 3.8-.9 5.5.8z" class="st4"/>
<path id="XMLID_16265_" d="M13.6 17.2c-1.7 1.7-2.6 3.7-.8 5.5 1.8 1.8 3.7.9 5.5-.8s2.1-4.2.8-5.5-3.8-.9-5.5.8z" class="st4"/>
<path id="XMLID_16264_" d="M28.6 8.2c1.8 1.6 1.5 4.1 1.5 4.1" class="st4"/>
<path id="XMLID_16263_" d="M37.3 16.2s.5-2.5-1.5-4.7" class="st4"/>
<path id="XMLID_16262_" d="M12.2 11.5c-1.9 2.2-1.5 4.7-1.5 4.7" class="st4"/>
<path id="XMLID_16261_" d="M17.9 12.3s-.3-2.5 1.5-4.1" class="st4"/>
<path id="XMLID_16260_" d="M36.9 40.4c.6-1.2.3-2.1.3-2.1" class="st4"/>
<path id="XMLID_16259_" d="M30.1 41.3s.3 1.9-1.5 3.1" class="st4"/>
<path id="XMLID_16258_" d="M19.4 44.4c-1.8-1.3-1.5-3.1-1.5-3.1" class="st4"/>
<path id="XMLID_16257_" d="M10.7 38.3s-.2.9.3 2.1" class="st4"/>
<path id="XMLID_16256_" d="M35.8 31.1c-1 .3-2.3.7-4.1 1-.2 0-.4.2-.4.4l-.3 1.2c-.1.4-.5.7-.9.8l-3.2.4c-.6.1-1.1-.4-1.2-.9l-.2-1.2h-2.6l-.2 1.2c-.1.6-.6 1-1.2.9l-3.2-.4c-.4 0-.8-.4-.9-.8l-.3-1.2c-.1-.2-.2-.4-.4-.4-1.8-.3-3.2-.7-4.1-1-.5-.2-.9.4-.6.8 1.6 2.2 5.5 6.3 12.4 6.3s10.8-4.1 12.4-6.3c-.1-.4-.5-.9-1-.8z" class="st38"/>
<path id="XMLID_16255_" d="M12.2 32.7c1 .3 2.4.7 4.2 1 .2 0 .4.2.4.4l.3 1.2c.1.4.5.7.9.8l3.2.4c.6.1 1.1-.4 1.2-.9l.2-1.2h2.6l.2 1.2c.1.6.6 1 1.2.9l3.2-.4c.4 0 .8-.4.9-.8l.3-1.2c.1-.2.2-.4.4-.4 1.8-.3 3.2-.7 4.1-1h.1c.2-.2.4-.5.6-.7.3-.4-.1-1-.6-.8-1 .3-2.3.7-4.1 1-.2 0-.4.2-.4.4l-.3 1.2c-.1.4-.5.7-.9.8l-3.2.4c-.6.1-1.1-.4-1.2-.9l-.2-1.2h-2.6l-.2 1.2c-.1.6-.6 1-1.2.9l-3.2-.4c-.4 0-.8-.4-.9-.8l-.3-1.2c-.1-.2-.2-.4-.4-.4-1.8-.3-3.2-.7-4.1-1-.5-.2-.9.4-.6.8 0 .2.2.4.4.7z" class="st46"/>
<path id="XMLID_16254_" d="M35.8 31.1c-1 .3-2.3.7-4.1 1-.2 0-.4.2-.4.4l-.3 1.2c-.1.4-.5.7-.9.8l-3.2.4c-.6.1-1.1-.4-1.2-.9l-.2-1.2h-2.6l-.2 1.2c-.1.6-.6 1-1.2.9l-3.2-.4c-.4 0-.8-.4-.9-.8l-.3-1.2c-.1-.2-.2-.4-.4-.4-1.8-.3-3.2-.7-4.1-1-.5-.2-.9.4-.6.8 1.6 2.2 5.5 6.3 12.4 6.3s10.8-4.1 12.4-6.3c-.1-.4-.5-.9-1-.8z" class="st4"/>
</svg>
@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