Canvas Example

Spring 2019

You are not logged in.

If you are a current student, please Log In for full access to the web site.
Note that this link will take you to an external site (https://oidc.mit.edu) to authenticate, and then you will be redirected back to this page.

Remember you can return any string you want from your Python request_handler function including valid html, which means you can take advantage of any sort of html stuff.

Consider this test page I have up now:

http://608dev.net/sandbox/sc/yuyu/canvas_test/example.py

This is currently a drawing served by the following code:

canvas_example.py

You can do the same thing with literally any html/javascript you'd like. You can also store it in separate files and then read in the files (using your relative home directory path names) and then render those files as strings.

Details on how to work with html graphics are found here and we can always help on piazza and in office hours

https://www.w3schools.com/graphics/canvas_text.asp

Also consider using a DOM-based graphics implementation like SVG (I prefer this over Canvas, but if you're rendering a lot of stuff, canvas is probably better for speed).



This page was last updated on Friday April 12, 2019 at 08:13:25 AM (revision 293362b).
 
Course Site powered by CAT-SOOP 14.0.4.dev5.
CAT-SOOP is free/libre software, available under the terms
of the GNU Affero General Public License, version 3.
(Download Source Code)
CSS/stryling from the Outboxcraft library Beauter, licensed under MIT
Copyright 2017