The URL can be changed dynamically, but if it doesn't change, you don't have to worry about the program re-generating the img element 30 times a second... that sort of thing gets optimized by the Virtual DOM.
On Mon, Sep 26, 2016 at 8:50 PM, Nick H <[email protected]> wrote: > You can use a src > <http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html-Attributes#src> > attribute, just like in plain ol' HTML. > > img [ src "http://imagesrc.jpg" ] [] > > > > > On Mon, Sep 26, 2016 at 4:47 PM, Redvers Davies <[email protected]> wrote: > >> I'd be happy to use an img element but I'm not sure how to get the image >> data into that img element. >> >> On Monday, September 26, 2016 at 7:18:33 PM UTC-4, Nick H wrote: >>> >>> If all you are doing is loading an image from a URL, why don't you use >>> an img >>> <http://package.elm-lang.org/packages/elm-lang/html/1.1.0/Html#img> >>> element? Canvas sounds like overkill. >>> >>> On Sun, Sep 25, 2016 at 7:16 PM, Redvers Davies <[email protected]> wrote: >>> >>>> >>>> I'm still too early in elm to know the correct question to ask so in >>>> the interests of avoiding the XY problem I'm just going to describe my >>>> end-goal and ask for the best approach to achieve it. >>>> >>>> I have (what I think is) an interesting use-case where I want to model >>>> on a webpage a physical device. The device itself is effectively a >>>> graphical dumb-terminal which just renders to its small screen the image >>>> that it's been sent over the network. >>>> >>>> What I'm hoping to get elm to do is to have, I guess, an image (or >>>> canvas) in my view which, on receiving image data via a websocket would >>>> then cause the view to then render that specific image in the same location >>>> (ie, DOM object). >>>> >>>> I've looked at Canvas and it appears I can do it if I pass a URL via >>>> websocket but that would initiate a separate query for the img data (via >>>> Graphics.Element image). As the hardware is capable of 30fps I don't >>>> really want to trigger 30 requests per second in addition to the websocket >>>> per simulation. Maybe it's possible to use Data URIs but I've not really >>>> been successful with that either. >>>> >>>> I know it's not the most efficient way of 'making a UI', but it's >>>> purpose isn't performance - it's purpose is to model the functionality of >>>> the hardware interface as closely as possible, >>>> >>>> Any pointers in the right direction appreciated. >>>> >>>> Thanks, >>>> >>>> >>>> >>>> Red >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Elm Discuss" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Elm Discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
