-
Notifications
You must be signed in to change notification settings - Fork 14
Text Metrics
Andy Gill edited this page Jun 18, 2014
·
7 revisions
«html5canvastutorials version»
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Graphics.Blank
import qualified Data.Text as Text
import Data.Monoid
main = blankCanvas 3000 $ \ context -> do
send context $ do
(width,height) <- size
let x = width / 2
let y = height / 2 - 10;
let text = "Hello World!"
font "30pt Calibri"
textAlign "center"
fillStyle "blue"
fillText(text, x, y)
TextMetrics w <- measureText text
font "20pt Calibri"
textAlign "center"
fillStyle "#555"
fillText("(" <> Text.pack (show w) <> "px wide)", x, y + 40)