Skip to content

Instantly share code, notes, and snippets.

@TahaHachana
Last active December 15, 2015 21:59
Show Gist options
  • Save TahaHachana/5329511 to your computer and use it in GitHub Desktop.
Save TahaHachana/5329511 to your computer and use it in GitHub Desktop.
module LinearGradient =
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 <- 300
canvas.Width <- 300
let context = canvas.GetContext "2d"
let grad = context.CreateLinearGradient(0., 150., 300., 150.)
grad.AddColorStop(0., "red")
grad.AddColorStop(0.5, "green")
grad.AddColorStop(1., "blue")
context.FillStyle <- grad
context.FillRect(0., 0., 300., 300.)
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