<div dir="ltr"><div style="" class="markdown-here-wrapper"><p style="margin:1.2em 0px!important">Shine wraps JavaScript’s drawing functions in a declarative API, hiding the boilerplate canvas code.</p>
<p style="margin:1.2em 0px!important">The API mimics the one provided by gloss (<code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">Picture</code>, <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">animate</code>, <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">play</code>…), but some types are different to better adapt to js code (ex. images, fonts, inputs).</p>
<p style="margin:1.2em 0px!important">Example: </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,255) none repeat scroll 0% 0%">main = runWebGUI $ \ webView -> do
ctx <- fixedSizeCanvas webView 800 600
let concentricCircles = foldMap Circle [1,10..100]
draw ctx concentricCircles -- one-shot drawing
</code></pre><p style="margin:1.2em 0px!important">The only direct dependency is ghcjs-dom, so the resulting jsexe should be relatively lightweight.</p>
<p style="margin:1.2em 0px!important">I also wrote shine-varying, a FRP interface to shine in terms of Vars plus some utility Vars.</p>
<p style="margin:1.2em 0px!important">Example (translation of the resize-yogi Elm example): </p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important;display:block;padding:0.5em;color:rgb(51,51,51);background:rgb(248,248,255) none repeat scroll 0% 0%">resizeImage img (x',y') = Translate (x/2) (y/2) -- Pictures are centered on (0,0), so we need to move it
$ Image (Stretched x y) img -- Scale the picture to the given position
where
x = fromIntegral x' -- mousePosition is Integral
y = fromIntegral y'
main = runWebGUI $ \ webView -> do
ctx <- fixedSizeCanvas webView 1024 768
Just doc <- webViewGetDomDocument webView
narwhal <- makeImage "<a href="https://wiki.haskell.org/wikiupload/8/85/NarleyYeeaaahh.jpg">https://wiki.haskell.org/wikiupload/8/85/NarleyYeeaaahh.jpg</a>"
let resizedNarwhal = resizeImage narwhal <$> mousePosition
playVarying ctx doc 30 resizedNarwhal
</code></pre><p style="margin:1.2em 0px!important">I plan to write/port a few simple games with it soon.</p>
<p style="margin:1.2em 0px!important">Francesco</p>
<div title="MDH:PGRpdj5TaGluZSB3cmFwcyBKYXZhU2NyaXB0J3MgZHJhd2luZyBmdW5jdGlvbnMgaW4gYSBkZWNs
YXJhdGl2ZSBBUEksIGhpZGluZyB0aGUgYm9pbGVycGxhdGUgY2FudmFzIGNvZGUuPGJyPjxicj48
L2Rpdj48ZGl2PlRoZSBBUEkgbWltaWNzIHRoZSBvbmUgcHJvdmlkZWQgYnkgZ2xvc3MgKGBQaWN0
dXJlYCwgYGFuaW1hdGVgLCBgcGxheWAuLi4pLCBidXQgc29tZSB0eXBlcyBhcmUgZGlmZmVyZW50
IHRvIGJldHRlciBhZGFwd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