0

I was recently trying out Brython and I'm having trouble figuring out how to draw a simple rectangle to a canvas.I can only find very complex examples of drawing to a canvas that don't work for me and I was unable to find a clear answer in the docs.

Could someone reading this please show me a bare-bones way of drawing a simple shape to a canvas with Brython and or show me something to get me on the right track?

  • The example posted [here](http://agentultra.com/2014/05/24/python-and-canvas2d-with-brython/) seems simple enough. `ctx.fillRect(x, y, 100.0, 100.0)` is the line that actually draws the rectangle, although you need to set the canvas up correctly first of course. – Octopoid Sep 12 '15 at 19:18

1 Answers1

1

You have some examples based on a library called brython-bryplot in this IPython/jupyter notebook (it uses a magic function called brythonmagic).

You could use directly the brython-bryplot library or you can have a look at the base.py module to check how shapes and text are implemented.

If you find any issues just let me know as I'm the developer of brython-bryplot, brythonmagic,... :-D

kikocorreoso
  • 3,999
  • 1
  • 17
  • 26