diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5a65bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +js/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..69994b1 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ + + +all: coreLib symbolLib editorLib testsLib + + +coreLib: + (cd components/Core; make all) + +symbolLib: + (cd components/Symbol; make all) + +editorLib: + (cd components/Editor; make all) + +testsLib: + (cd components/Tests; make all) diff --git a/components/Core/Makefile b/components/Core/Makefile new file mode 100644 index 0000000..6283df2 --- /dev/null +++ b/components/Core/Makefile @@ -0,0 +1,15 @@ +OutputName=coreLib +SourceFiles=src/Core.ts src/Fragment.ts src/Paper.ts +BaseDir=../.. +OutputDir=$(BaseDir)/js +Out=$(OutputDir)/$(OutputName).js + +all: $(Out) + +$(Out): lib.ts $(SourceFiles) + tsc --declaration --sourceMap --out $@ lib.ts + sed -i "/\/\/\/\ * +/// +/// diff --git a/components/Core/src/Core.ts b/components/Core/src/Core.ts new file mode 100644 index 0000000..dcc1c8c --- /dev/null +++ b/components/Core/src/Core.ts @@ -0,0 +1,4 @@ + +module Sanara.Core { + export type SanaraContext = CanvasRenderingContext2D; +} diff --git a/components/Core/src/Fragment.ts b/components/Core/src/Fragment.ts new file mode 100644 index 0000000..0173984 --- /dev/null +++ b/components/Core/src/Fragment.ts @@ -0,0 +1,24 @@ +/// + +module Sanara.Core { + export interface Fragment { + paint(paper: Paper) : void; + paintMe(paper : Paper) : void; + } + export class BaseFragment implements Fragment { + children : [Fragment]; + constructor (children : [Fragment] = <[Fragment]>[]) { + this.children = children; + } + paint(paper: Paper) { + paper.context.save(); + this.paintMe(paper); + paper.context.restore(); + } + paintMe(paper : Paper) { + this.children.forEach(function (v) { + v.paint(paper); + }) + } + } +} diff --git a/components/Core/src/Paper.ts b/components/Core/src/Paper.ts new file mode 100644 index 0000000..8b5c0e7 --- /dev/null +++ b/components/Core/src/Paper.ts @@ -0,0 +1,30 @@ +/// + + +module Sanara.Core { + export interface Paper { + domElement : HTMLCanvasElement; + context : SanaraContext; + w : number; + h : number; + root : Fragment; + repaint(time:number) : void; + } + export class BasicPaper implements Paper { + domElement : HTMLCanvasElement; + context : SanaraContext; + w : number; + h : number; + root : Fragment; + constructor (w:number = 100, h:number = 100) { + this.w = w; + this.h = h; + + this.domElement = document.createElement("canvas"); + this.context = this.domElement.getContext("2d"); + } + repaint(time:number = 0) : void { + this.root.paint(this); + } + } +} diff --git a/components/Core/tsconfig.json b/components/Core/tsconfig.json new file mode 100644 index 0000000..060ac0f --- /dev/null +++ b/components/Core/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": false, + "version": "1.5.0-alpha", + "compilerOptions": { + "target": "es5" + }, + "filesGlob": [ + "./**/*.ts", + "!./node_modules/**/*.ts" + ], + "files": [ + "./lib.ts", + "./src/Core.ts", + "./src/Fragment.ts", + "./src/Paper.ts" + ] +} diff --git a/components/Editor/Makefile b/components/Editor/Makefile new file mode 100644 index 0000000..4365150 --- /dev/null +++ b/components/Editor/Makefile @@ -0,0 +1,15 @@ +OutputName=editorLib +SourceFiles=src/Editor.ts +BaseDir=../.. +OutputDir=$(BaseDir)/js +Out=$(OutputDir)/$(OutputName).js + +all: $(Out) + +$(Out): lib.ts $(SourceFiles) + tsc --removeComments --declaration --sourceMap --out $@ lib.ts + sed -i "/\/\/\/\ * diff --git a/components/Editor/src/Editor.ts b/components/Editor/src/Editor.ts new file mode 100644 index 0000000..d172665 --- /dev/null +++ b/components/Editor/src/Editor.ts @@ -0,0 +1 @@ +/// diff --git a/components/Editor/tsconfig.json b/components/Editor/tsconfig.json new file mode 100644 index 0000000..aa41d07 --- /dev/null +++ b/components/Editor/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compileOnSave": false, + "version": "1.5.0-alpha", + "compilerOptions": { + "target": "es5" + }, + "filesGlob": [ + "./**/*.ts", + "!./node_modules/**/*.ts" + ], + "files": [ + "./declareFiles/coreLib.d.ts", + "./lib.ts", + "./src/Editor.ts" + ] +} diff --git a/components/Symbol/Makefile b/components/Symbol/Makefile new file mode 100644 index 0000000..e6ac299 --- /dev/null +++ b/components/Symbol/Makefile @@ -0,0 +1,16 @@ +OutputName=symbolLib +SourceFiles=src/Rect.ts + +BaseDir=../.. +OutputDir=$(BaseDir)/js +Out=$(OutputDir)/$(OutputName).js + +all: $(Out) + +$(Out): lib.ts $(SourceFiles) + tsc --removeComments --declaration --sourceMap --out $@ lib.ts + sed -i "/\/\/\/\ * diff --git a/components/Symbol/src/Rect.ts b/components/Symbol/src/Rect.ts new file mode 100644 index 0000000..c6ca43c --- /dev/null +++ b/components/Symbol/src/Rect.ts @@ -0,0 +1,16 @@ +/// + +module Sanara.Symbol { + export class Rect extends Sanara.Core.BaseFragment { + w : number; + h : number; + constructor(w: number=100, h: number=100){ + super(); + this.w = w; + this.h = h; + } + paintMe (paper : Sanara.Core.Paper) { + paper.context.fillRect(0,0,this.w,this.h); + } + } +} diff --git a/components/Symbol/tsconfig.json b/components/Symbol/tsconfig.json new file mode 100644 index 0000000..19cc356 --- /dev/null +++ b/components/Symbol/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compileOnSave": false, + "version": "1.5.0-alpha", + "compilerOptions": { + "target": "es5" + }, + "filesGlob": [ + "./**/*.ts", + "!./node_modules/**/*.ts" + ], + "files": [ + "./declareFiles/coreLib.d.ts", + "./lib.ts", + "./src/Rect.ts" + ] +} diff --git a/components/Tests/Makefile b/components/Tests/Makefile new file mode 100644 index 0000000..a7d77cb --- /dev/null +++ b/components/Tests/Makefile @@ -0,0 +1,15 @@ +OutputName=testsLib +SourceFiles=src/simplePaper.ts + +BaseDir=../.. +OutputDir=$(BaseDir)/js +Out=$(OutputDir)/$(OutputName).js + +all: $(Out) + +$(Out): lib.ts $(SourceFiles) + tsc --declaration --sourceMap --out $@ lib.ts + cp -f $(OutputDir)/$(OutputName).d.ts ../declareFiles/ + +clean: + rm $(OUT) diff --git a/components/Tests/declareFiles/coreLib.d.ts b/components/Tests/declareFiles/coreLib.d.ts new file mode 120000 index 0000000..585d509 --- /dev/null +++ b/components/Tests/declareFiles/coreLib.d.ts @@ -0,0 +1 @@ +../../declareFiles/coreLib.d.ts \ No newline at end of file diff --git a/components/Tests/declareFiles/symbolLib.d.ts b/components/Tests/declareFiles/symbolLib.d.ts new file mode 120000 index 0000000..aabfd05 --- /dev/null +++ b/components/Tests/declareFiles/symbolLib.d.ts @@ -0,0 +1 @@ +../../declareFiles/symbolLib.d.ts \ No newline at end of file diff --git a/components/Tests/lib.ts b/components/Tests/lib.ts new file mode 100644 index 0000000..37b972b --- /dev/null +++ b/components/Tests/lib.ts @@ -0,0 +1 @@ +/// diff --git a/components/Tests/src/simplePaper.ts b/components/Tests/src/simplePaper.ts new file mode 100644 index 0000000..2230242 --- /dev/null +++ b/components/Tests/src/simplePaper.ts @@ -0,0 +1,10 @@ +/// +/// + +module Sanara.Tests { + export var simplePaper = (function () { + var paper = new Sanara.Core.BasicPaper(1000,1000); + paper.root = new Sanara.Symbol.Rect(122,500); + return paper; + })(); +} diff --git a/components/Tests/tsconfig.json b/components/Tests/tsconfig.json new file mode 100644 index 0000000..fa4853d --- /dev/null +++ b/components/Tests/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compileOnSave": false, + "version": "1.5.0-alpha", + "compilerOptions": { + "target": "es5" + }, + "filesGlob": [ + "./**/*.ts", + "!./node_modules/**/*.ts" + ], + "files": [ + "./declareFiles/coreLib.d.ts", + "./declareFiles/symbolLib.d.ts", + "./lib.ts", + "./src/simplePaper.ts" + ] +} diff --git a/components/declareFiles/coreLib.d.ts b/components/declareFiles/coreLib.d.ts new file mode 100644 index 0000000..384e4a3 --- /dev/null +++ b/components/declareFiles/coreLib.d.ts @@ -0,0 +1,34 @@ +declare module Sanara.Core { + type SanaraContext = CanvasRenderingContext2D; +} +declare module Sanara.Core { + interface Paper { + domElement: HTMLCanvasElement; + context: SanaraContext; + w: number; + h: number; + root: Fragment; + repaint(time: number): void; + } + class BasicPaper implements Paper { + domElement: HTMLCanvasElement; + context: SanaraContext; + w: number; + h: number; + root: Fragment; + constructor(w?: number, h?: number); + repaint(time?: number): void; + } +} +declare module Sanara.Core { + interface Fragment { + paint(paper: Paper): void; + paintMe(paper: Paper): void; + } + class BaseFragment implements Fragment { + children: [Fragment]; + constructor(children?: [Fragment]); + paint(paper: Paper): void; + paintMe(paper: Paper): void; + } +} diff --git a/components/declareFiles/editorLib.d.ts b/components/declareFiles/editorLib.d.ts new file mode 100644 index 0000000..e69de29 diff --git a/components/declareFiles/symbolLib.d.ts b/components/declareFiles/symbolLib.d.ts new file mode 100644 index 0000000..ed37089 --- /dev/null +++ b/components/declareFiles/symbolLib.d.ts @@ -0,0 +1,8 @@ +declare module Sanara.Symbol { + class Rect extends Sanara.Core.BaseFragment { + w: number; + h: number; + constructor(w?: number, h?: number); + paintMe(paper: Sanara.Core.Paper): void; + } +} diff --git a/components/declareFiles/testsLib.d.ts b/components/declareFiles/testsLib.d.ts new file mode 100644 index 0000000..0af007e --- /dev/null +++ b/components/declareFiles/testsLib.d.ts @@ -0,0 +1,5 @@ +/// +/// +declare module Sanara.Tests { + var simplePaper: Core.BasicPaper; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..998d4b0 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + + + + + + + +