Be my guest. I felt like this community needed SOMETHING! :)
I like to try to emulate pure JS stuff with Purescript where possible.
Be my guest. I felt like this community needed SOMETHING! :)
I like to try to emulate pure JS stuff with Purescript where possible.
module Main where
import Prelude
import Effect (Effect)
import Effect.Aff (launchAff_)
import Effect.Aff.Timer (setInterval)
import Effect.DOM (window)
import Web.HTML (document)
import Web.HTML.Document (getElementById)
import Web.HTML.Element (Element, toElement)
import Web.HTML.HTMLCanvasElement (getContext2D, getCanvasElementById)
import Web.HTML.Canvas.Image (newImage, getWidth, getHeight, setSrc)
import Web.HTML.Canvas.CanvasRenderingContext2D (CanvasRenderingContext2D, drawImage)
import Web.HTML.Types (CanvasElement, Image)
import Web.DOM.Node.Types (Node)
foreign import requestAnimationFrame :: (Effect Unit -> Effect Unit) -> Effect Unit
-- Loads the image and begins the animation
startAnimation :: Effect Unit
startAnimation = do
img <- newImage
setSrc img "example1.jpg"
canvas <- getCanvasElementById "myCanvas"
context <- getContext2D canvas
-- We defer animation start until the image is loaded
imgOnLoad img (beginAnimation context img)
-- Sets the image `onload` handler, safely deferring canvas drawing until the image is ready
imgOnLoad :: Image -> Effect Unit -> Effect Unit
imgOnLoad img action = do
foreignOnload img action
foreign import foreignOnload :: Image -> Effect Unit -> Effect Unit
-- Initializes the animation loop
beginAnimation :: CanvasRenderingContext2D -> Image -> Effect Unit
beginAnimation context img = do
imageWidth <- getWidth img
imageHeight <- getHeight img
let row = imageHeight
requestAnimationFrame (animate context img row imageWidth imageHeight)
-- Animates drawing row by row
animate :: CanvasRenderingContext2D -> Image -> Int -> Int -> Int -> Effect Unit
animate context img row imageWidth imageHeight = do
drawImage context img 0 row imageWidth 1 0 0 imageWidth row
let nextRow = if row > 0 then row - 1 else imageHeight
requestAnimationFrame (animate context img nextRow imageWidth imageHeight)
main :: Effect Unit
main = do
startAnimation
Not at my computer but I generated a rough chatGPT translation that I’m sure doesn’t compile to get me started later if I want to attempt this with the safety of Purescript.
Ps. Yes, I know Purescript generated by chatGPT generally sucks and is filled with hallucinations.
Israel reminds me of the villain in Team America:
They act as if they are above the law.
They’re talking about disease transmission not the actual thing that will end our world: the insane amounts of greenhouse gases these monstrosities put into the air. I guess I shouldn’t be surprised since this was posted in /c/travel where most people are still intent on boiling the oceans for their vacation plans.
Looked it up. Yes
OP seems to think that’s a good thing. Animated films are the studios’ way of getting cheap products using non union labor.
My hero!
No new movies and TV shows are being made. I’m a 43 year old industry veteran, forced to look for a new career.
Anecdotally, I used to make $120k/year for the past 10 years like clockwork. The past two years, though: I made $18,00 and $22,000.
This article says 40% but that’s in LA. In other places, production is down 90%.
Great article but line 1 is wrong. The genocide has been going on for far, FAR longer than a year.
99%/.9%/0.1% Subscribed thanks to all of the shit users on default communities.
I’m subscribed to the communities I moderate and around 700 others. So, it’s rarely an empty feed. If the feed is empty, it means I’m slacking and I need to step away from Lemmy for a day or two.
The film industry is dead and streaming killed it. Pirate movies over a vpn as much as you want.
Movie studios are now just landlords. They’re run by boards of directors, focused on nothing but number go up. They want money for sitting like a dragon on top of a stockpile of content. Fuck them.
Don’t get me started on how difficult CSS is with Purescript! I tend to just admit defeat eventually and throw tailwind into the project.