Created
October 4, 2020 19:18
-
-
Save jameswpierce/17e836d0bc2de2ac55d556bcb755f1d7 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/mabotom
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> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width"> | |
| <title>JS Bin</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.1.3/pixi.min.js"></script> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| "use strict"; | |
| var app = new PIXI.Application({ antialias: false }); | |
| document.body.appendChild(app.view); | |
| var graphics = new PIXI.Graphics(); | |
| var drawTriangle = function drawTriangle(x, y, scale) { | |
| var height = Math.sqrt(Math.pow(100, 2) - Math.pow(50, 2)); | |
| graphics.moveTo(x, y); | |
| graphics.lineTo(x + 50 * scale, y + height * scale); | |
| graphics.lineTo(x - 50 * scale, y + height * scale); | |
| graphics.lineTo(x, y); | |
| return height; | |
| }; | |
| graphics.drawTriangle = drawTriangle; | |
| graphics.beginFill(0x000000); | |
| graphics.lineStyle(2, 0xffffff, 1); | |
| var nextY = graphics.drawTriangle(100, 100, 1); | |
| graphics.drawTriangle(100, 100 + nextY, -0.5); | |
| graphics.closePath(); | |
| graphics.endFill(); | |
| app.stage.addChild(graphics); | |
| </script> | |
| <script id="jsbin-source-javascript" type="text/javascript">const app = new PIXI.Application({antialias: false}); | |
| document.body.appendChild(app.view); | |
| const graphics = new PIXI.Graphics(); | |
| const drawTriangle = (x, y, scale) => { | |
| const height = Math.sqrt((100**2) - (50**2)); | |
| graphics.moveTo(x, y); | |
| graphics.lineTo(x + (50 * scale), y + (height * scale)); | |
| graphics.lineTo(x - (50 * scale), y + (height * scale)); | |
| graphics.lineTo(x, y); | |
| return height; | |
| } | |
| graphics.drawTriangle = drawTriangle; | |
| graphics.beginFill(0x000000); | |
| graphics.lineStyle(2, 0xffffff, 1); | |
| const nextY = graphics.drawTriangle(100, 100, 1); | |
| graphics.drawTriangle(100, 100+nextY, -(0.5)); | |
| graphics.closePath(); | |
| graphics.endFill(); | |
| app.stage.addChild(graphics);</script></body> | |
| </html> |
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
| "use strict"; | |
| var app = new PIXI.Application({ antialias: false }); | |
| document.body.appendChild(app.view); | |
| var graphics = new PIXI.Graphics(); | |
| var drawTriangle = function drawTriangle(x, y, scale) { | |
| var height = Math.sqrt(Math.pow(100, 2) - Math.pow(50, 2)); | |
| graphics.moveTo(x, y); | |
| graphics.lineTo(x + 50 * scale, y + height * scale); | |
| graphics.lineTo(x - 50 * scale, y + height * scale); | |
| graphics.lineTo(x, y); | |
| return height; | |
| }; | |
| graphics.drawTriangle = drawTriangle; | |
| graphics.beginFill(0x000000); | |
| graphics.lineStyle(2, 0xffffff, 1); | |
| var nextY = graphics.drawTriangle(100, 100, 1); | |
| graphics.drawTriangle(100, 100 + nextY, -0.5); | |
| graphics.closePath(); | |
| graphics.endFill(); | |
| app.stage.addChild(graphics); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment