Created
April 6, 2013 08:40
-
-
Save TahaHachana/5325426 to your computer and use it in GitHub Desktop.
This gist demonstrates how to draw the text "Hello Canvas" on the HTML5 canvas using the WebSharper bindings to this element.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HelloCanvas = | |
open IntelliFactory.WebSharper | |
open IntelliFactory.WebSharper.Html | |
open IntelliFactory.WebSharper.Html5 | |
[<JavaScript>] | |
let main() = | |
let element = HTML5.Tags.Canvas [Text "Fallback content goes here."] | |
let canvas = As<CanvasElement> element.Dom | |
canvas.Height <- 100 | |
canvas.Width <- 400 | |
let context = canvas.GetContext "2d" | |
context.Font <- "40px sans-serif" | |
context.FillText("Hello Canvas", 90., 50.) | |
element | |
type Control() = | |
inherit Web.Control() | |
[<JavaScript>] | |
override __.Body = main() :> _ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment