Last active
September 4, 2019 13:24
-
-
Save mdecourse/5223cb3dca5cd45f5b7ea7bd791a4034 to your computer and use it in GitHub Desktop.
Get mouse coordinate in Dartpad
This file contains hidden or 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
| <canvas id="canvas" width="300" height="300"></canvas> | |
| <div id="output"></div> |
This file contains hidden or 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
| import 'dart:html'; | |
| CanvasElement canvas = querySelector('#canvas'); | |
| CanvasRenderingContext2D context = canvas.getContext('2d'); | |
| DivElement output = querySelector("#output"); | |
| void main(){ | |
| document.body.style.backgroundColor = "black"; | |
| canvas.onMouseMove.listen((e) { | |
| output.text = "x:" + (e.client.x).toString() + ", y:" +(e.client.y).toString(); | |
| }); | |
| } |
This file contains hidden or 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
| html, body{ | |
| color: white; | |
| font-size: 25px; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment