have a look to the jsfiddle link I posted in my previous email. I' m
just doing what you did but with the correct 'src' keyword and it
works as expected.
2015-05-10 19:40 GMT+02:00, Paul Curry <
paul.mich...@gmail.com>:
> Even after I included that it would still throw the same exception. However
>
> I found if I used the
> .elt field on the img it wouldn't throw an error and if I alerted the img
> it would alert an "HTLMImageElement".
>
> img = html.IMG(src = "wall.jpg")
> ctx.drawImage(img.elt,0,0)
>
> I think that is more correct. However I still cannot get it to display.
> Perhaps the image is not loading before drawImage is called? Would I need
> to attach an onload event handler?
>
>
> On Sunday, May 10, 2015 at 12:30:01 AM UTC-7, kiko (on pybonacci) wrote:
>>
>>
>>
>> 2015-05-10 4:16 GMT+02:00 Paul Curry <
paul.mich...@gmail.com
>> <javascript:>
>> >:
>>
>>> Hi, I saw that this was asked earlier, but the solution does not seem to
>>>
>>> work anymore as it used JSConstructor(window.Image)() which throws an
>>> exception.
>>>
>>> Here I am trying to draw an image onto the canvass with the html.IMG
>>> tag:
>>>
>>> roleCanvas = html.CANVAS(id = "roleCanvas", width = GAME_WIDTH, height =
>>>
>>> GAME_HEIGHT)
>>> ctx = roleCanvas.getContext("2d");
>>>
>>> img = html.IMG("wall.jpg")
>>>
>>
>> I think you need to use the 'src' keyword here.
>> See a working example here:
http://jsfiddle.net/sef23exg/
>>
>>
>>> ctx.drawImage(img,200,200)
>>>
>>> It throws an exception:
>>> *Uncaught Error: TypeError: Failed to execute 'drawImage' on
>>> 'CanvasRenderingContext2D': The provided value is not of type
>>> '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or
>>> ImageBitmap)'*
>>>
>>> Any help would be greatly appreciated. Thank you.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>>
>>> "brython" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>>
>>> email to
brython+u...@googlegroups.com <javascript:>.
>>> <javascript:>.
>>> <
https://groups.google.com/d/msgid/brython/5f382935-be14-4c8f-9e44-5dec16425374%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
brython+u...@googlegroups.com.
> To post to this group, send email to
bry...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/brython/584421f9-9d6d-4e94-8748-2e7b79ea740a%40googlegroups.com.