Last active
November 9, 2017 16:51
-
-
Save heolin/8050ee9cf2012df9f0559001242065d5 to your computer and use it in GitHub Desktop.
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <style type="text/css"> | |
| html, | |
| body { | |
| margin: 0; | |
| overflow: hidden; | |
| height: 100%; | |
| } | |
| /* Scale canvas with resize attribute to full size */ | |
| canvas[resize] { | |
| width: 100%; | |
| height: 100%; | |
| } | |
| </style> | |
| <script type="text/javascript" src="js/paper.js"></script> | |
| <script type="text/javascript"> | |
| class Mission { | |
| constructor(position, locked, stars) { | |
| this.position = position; | |
| var path = new Path.Rectangle(position, [100, 100]); | |
| path.fillColor = '#bbbbbb'; | |
| var raster = new Raster('badgeImage'); | |
| raster.position = path.position; | |
| raster.size = new Size(80, 80); | |
| var iconName = "lockImage"; | |
| if (!locked) | |
| iconName = "successImage"; | |
| var icon = new Raster(iconName); | |
| icon.position = path.position.add(new Point(50, -50)); | |
| icon.size = new Size(30, 30); | |
| var starName = "starBlackImage"; | |
| if (stars >= 1) | |
| starName = 'starImage'; | |
| var star1 = new Raster(starName); | |
| star1.position = path.position.add(new Point(-50, 60)); | |
| star1.size = new Size(50, 50); | |
| var starName = "starBlackImage"; | |
| if (stars >= 2) | |
| starName = 'starImage'; | |
| var star2 = new Raster(starName); | |
| star2.position = path.position.add(new Point(0, 50)); | |
| star2.size = new Size(50, 50); | |
| var starName = "starBlackImage"; | |
| if (stars >= 3) | |
| starName = 'starImage'; | |
| var star3 = new Raster(starName); | |
| star3.position = path.position.add(new Point(50, 60)); | |
| star3.size = new Size(50, 50); | |
| var group = new Group(); | |
| group.addChild(raster); | |
| group.addChild(icon); | |
| group.addChild(path); | |
| group.addChild(star1); | |
| group.addChild(star2); | |
| group.addChild(star3); | |
| group.onClick = function(event) { | |
| alert('hehe'); | |
| } | |
| } | |
| } | |
| paper.install(window); | |
| window.onload = function() { | |
| paper.setup('myCanvas'); | |
| var mission = new Mission(new Point(20, 20), true, 2); | |
| var mission = new Mission(new Point(220, 20), false, 3); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <canvas id="myCanvas" resize></canvas> | |
| <img id="badgeImage" style="display:none;" src="http://icons.iconarchive.com/icons/icons8/windows-8/512/City-Police-Badge-icon.png"></img> | |
| <img id="successImage" style="display:none;" src="https://image.flaticon.com/icons/png/128/291/291201.png"></img> | |
| <img id="starImage" style="display:none;" src="https://cdn4.iconfinder.com/data/icons/small-n-flat/24/star-128.png"></img> | |
| <img id="starBlackImage" style="display:none;" src="http://simpleicon.com/wp-content/uploads/star.png"></img> | |
| <img id="lockImage" style="display:none;" src="https://image.flaticon.com/icons/png/512/34/34279.png"></img> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment