Thank you for the reply's i tried both methods without luck, the canvas loads but no image is displayed and the same for the svg method. Could this be my setup that is causing these problems?
--
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/msg/brython/-/m9FayZyNHqYJ.
I tested on both chrome and firefox and didn't get errors on either. The clock demo works for me but it just seems to be these demos using drawImage
--
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/msg/brython/-/3aPUc7tYq64J.
So it appears that i had a number of comments in the code and when i removed those it started working fine,
Thank you all for the help and I'm excited for the future of this project.
--
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/msg/brython/-/eMG2RYQgmuAJ.
That would be great if you could take a look, I'll post the source when I get home but if you want to take a look now just open the page source in the link and the source should link to pie.py
--
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/msg/brython/-/GdhBbyvw-ZIJ.
ship_pos[0] += x ship_pos[1] += y (not going to be changed...yet? :) )
but instead:
ship_pos[0] += ship_vel_x
### where ship_vel_x is a variable to change based on user input and until either the key_up event sets the velocity to zero to stop or the keypress changes to negative ship_x_vel and makes ship go other way...
Here is the link to the source, I just through this together last night, but I hope you can find the issue
--
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/msg/brython/-/p_rOz0tooxkJ.
I ended up using a queue to hold directional key presses so that you can press two keys at once without the ship jolting. Let me know what you think and maybe what needs to be changed :)
--
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/msg/brython/-/WSFQb0oWlwAJ.
Thanks a lot for the help, I wont be working much on it tonight but I'm hoping to put in shields and make the aliens actually able to shoot tomorrow
--
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/msg/brython/-/vAUHc42zRkUJ.
Thats odd. The example code you gave runs and displays the image with the version of Brython contained in the Zip file.
But when I try to run the same HTML and Python code with a Brython version 3.0 , the example does not work.
I get the following in the console:
"RuntimeError: ReferenceError: doc is not defined
Traceback (most recent call last):"
I'm guessing that Brython has changed since your post? (February 2013).
Could someone post a working example of displaying an image on the canvas?
Le mardi 9 décembre 2014 13:14:17 UTC+1, Pierre Quentel a écrit :
Le mardi 9 décembre 2014 13:04:06 UTC+1, João Sebastião de Oliveira Bueno a écrit :On 8 December 2014 at 19:35, Pierre Quentel <pierre....@gmail.com> wrote:
> img = new Image()
>
> The equivalent in Brython is the line
>
> img = javascript.JSConstructor(window.Image)()
Oh, please. no!! If it was this way, writting Brython would be harder
than Javascript, and the whole purpose of the thing is to be simpler
and saner.
The Brython equivalent to create an Image is:
from browser import html
img = html.IMG()
You are right, but dan wanted a working example, and for the moment this version with html.IMG doesn't work : canvas.drawImage(img, 0, 0) raises an Exception. It's on my todo list
--
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/b9333f36-bbfa-49dc-8273-8bc53ee0f790%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello Kiko.
Thank you for your response. But I am not sure this answers my question.
The code does work, as you said (this is also what I said in my original post) , but only when the values are hard coded and not gotten from the image object.
From what I see in the JSFiddle link you gave, that copies my code, you added a couple variables: IW and IH and you "hard coded" the image width and height to those variables. So yeah, in that cas it also works. But what I want is to be able to load an image and then use the img.width and img.height properties of the JS image object.
I am going to try to add a delay before trying to get the values. To allow the browser to load the image before the code is executed. We'll see if this helps.
But this is surprising since, I am loading the image (JS object) in the Brython code and not in the HTML. So the object should exist when I try to access the width and height properties. I'll try the delay anyways... its a quirky hack, but if it works...
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/b4da4bae-ac11-407d-bfaf-cb6dbd91e841%40googlegroups.com.
2014-12-10 12:57 GMT+01:00 dan d. <dandelso...@gmail.com>:Hello Kiko.
Thank you for your response. But I am not sure this answers my question.
The code does work, as you said (this is also what I said in my original post) , but only when the values are hard coded and not gotten from the image object.
From what I see in the JSFiddle link you gave, that copies my code, you added a couple variables: IW and IH and you "hard coded" the image width and height to those variables. So yeah, in that cas it also works. But what I want is to be able to load an image and then use the img.width and img.height properties of the JS image object.
I am going to try to add a delay before trying to get the values. To allow the browser to load the image before the code is executed. We'll see if this helps.
But this is surprising since, I am loading the image (JS object) in the Brython code and not in the HTML. So the object should exist when I try to access the width and height properties. I'll try the delay anyways... its a quirky hack, but if it works...Ok, the following seems it is working as you expect:
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/CAB-sx602UaEfJCVNRPhp-Kaw_uQxKAC-%2BX0sYAS5wfBjcTwnVg%40mail.gmail.com.
Hello Pierre,
I am trying to do something rather simple, rotatating the image using the canvas context rotate() method and using a timer.I got the timer working fine looking at the Brython docs.
In the code below if I hard code the value 150 for (img.width/2) or (img.height/2), the code works. The image is positioned correctly and spins on itself.
If I leave (img.width/2) or (img.height/2) this is evaluated to 0, for some reason, although the image is 300x300 pixels...
Line 18 and 28, the img.width and myImage.width do not contain the correct value for the image.
Since we created the img object using a 300x300 image, shouldn't img.width contain the value 300 ? Or is this a Brython / Javascript interaction particularity?
Yes, thank you Pierre.
Indeed, I am all for short clean syntax, if it works. But if does not, then I would rather have the long syntax that does work :)
Just to give you some context, I am completely new to Brython.
And I would like to port a simple little game I wrote, to Brython. Right now it is written in Python but on top of a web browser framework (HTML5), but which is not open source. It uses Skulpt as the Python translator, and it has additional libraries for handling all the graphics and sound, and user interface. These libraries are not open source.
So the idea is to use Brython instead for this game. If this is possible...
Pierre, can you tell me if it is possible to play sounds (mp3/ogg files) via Brython?
Dan, this seems to be inline with pygame, which is on my todo list to translate to brython. I can try to help by finding how to do these sound effects in html5 (brython) and then try to create the relevant function in pygame. You might want to check the site-packages directory under Lib to see if pygame is there in the repo. I personally have not added a sounds module but some else may have.
Good luck!
Billy
--
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/c328cea0-ad7b-49e4-9fd2-9e8b52114a1d%40googlegroups.com.
Thanks for pointing that out. We definitely need to know, so we can make brython better!
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/29cd9be0-e8a2-4b80-9f16-a70e0ca100d6%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/a1290cfb-cf64-4615-8e09-eece2f6fc5c7%40googlegroups.com.