Created
April 6, 2013 09:18
-
-
Save TahaHachana/5325516 to your computer and use it in GitHub Desktop.
This WebSharper code draws a black rectangle on the hole canvas surface and then clears a 100px X 100px rectangle starting from the coordinates (50, 50).
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 ClearRect = | |
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 <- 200 | |
canvas.Width <- 200 | |
let context = canvas.GetContext "2d" | |
context.FillRect(0., 0., 200., 200.) | |
context.ClearRect(50., 50., 100., 100.) | |
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