merged dev into parser
This commit is contained in:
commit
2558a548b3
|
@ -1,3 +1,6 @@
|
||||||
|
/// <reference path="vector.ts" />
|
||||||
|
/// <reference path="shapes.ts" />
|
||||||
|
|
||||||
function loadScript(filepath: string): string
|
function loadScript(filepath: string): string
|
||||||
{
|
{
|
||||||
let result = null;
|
let result = null;
|
||||||
|
@ -73,8 +76,8 @@ class Geometry extends HTMLElement
|
||||||
|
|
||||||
private redraw()
|
private redraw()
|
||||||
{
|
{
|
||||||
Shape.line(this.context, new Util.Vector2D(), new Util.Vector2D(300, 300));
|
line(this.context, new Vector2D(), new Vector2D(300, 300));
|
||||||
Shape.circle(this.context, new Util.Vector2D(150, 150), 100);
|
circle(this.context, new Vector2D(150, 150), 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
module Util
|
class ShapeStyle
|
||||||
{
|
{
|
||||||
export class ShapeStyle
|
|
||||||
{
|
|
||||||
public strokeWidth: number;
|
public strokeWidth: number;
|
||||||
public strokeColor: string;
|
public strokeColor: string;
|
||||||
public fillColor: string;
|
public fillColor: string;
|
||||||
|
@ -12,5 +10,4 @@ module Util
|
||||||
this.strokeColor = '#000000';
|
this.strokeColor = '#000000';
|
||||||
this.fillColor = '#00000000';
|
this.fillColor = '#00000000';
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
module Shape
|
/// <reference path="vector.ts" />
|
||||||
|
/// <reference path="shapeStyle.ts" />
|
||||||
|
|
||||||
|
function line(ctx: CanvasRenderingContext2D, from: Vector2D , to: Vector2D, style: ShapeStyle = new ShapeStyle())
|
||||||
{
|
{
|
||||||
export function line(ctx: CanvasRenderingContext2D, from: Util.Vector2D , to: Util.Vector2D, style: Util.ShapeStyle = new Util.ShapeStyle())
|
|
||||||
{
|
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.moveTo(from.x, from.y);
|
ctx.moveTo(from.x, from.y);
|
||||||
ctx.lineTo(to.x, to.y);
|
ctx.lineTo(to.x, to.y);
|
||||||
|
@ -9,10 +10,10 @@ module Shape
|
||||||
ctx.lineWidth = style.strokeWidth;
|
ctx.lineWidth = style.strokeWidth;
|
||||||
ctx.strokeStyle = style.strokeColor;
|
ctx.strokeStyle = style.strokeColor;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function circle(ctx: CanvasRenderingContext2D, center: Util.Vector2D, radius: number, style: Util.ShapeStyle = new Util.ShapeStyle())
|
function circle(ctx: CanvasRenderingContext2D, center: Vector2D, radius: number, style: ShapeStyle = new ShapeStyle())
|
||||||
{
|
{
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI, false);
|
ctx.arc(center.x, center.y, radius, 0, 2 * Math.PI, false);
|
||||||
|
|
||||||
|
@ -22,5 +23,4 @@ module Shape
|
||||||
ctx.lineWidth = style.strokeWidth;
|
ctx.lineWidth = style.strokeWidth;
|
||||||
ctx.strokeStyle = style.strokeColor;
|
ctx.strokeStyle = style.strokeColor;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
module Util
|
class Vector2D
|
||||||
{
|
{
|
||||||
export class Vector2D
|
|
||||||
{
|
|
||||||
public x: number;
|
public x: number;
|
||||||
public y: number;
|
public y: number;
|
||||||
|
|
||||||
|
@ -10,5 +8,4 @@ module Util
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"outFile": "./out/geometry.js",
|
"outFile": "./out/geometry.js",
|
||||||
"outDir": "./out",
|
|
||||||
"sourceRoot": "./src",
|
"sourceRoot": "./src",
|
||||||
"rootDir": "./src",
|
"rootDir": "./src",
|
||||||
"sourceMap": true
|
"sourceMap": true
|
||||||
|
|
Loading…
Reference in a new issue