Skip to content

Commit

Permalink
Merge pull request #31 from templatone/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
adamjosefus committed May 4, 2022
2 parents faba7c6 + 34736f1 commit 9892a2e
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 27 deletions.
7 changes: 7 additions & 0 deletions dist/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/renderables/ImageObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class ImageObject {
else {
Shadow.clear(renderingLayer);
}
ctx.moveTo(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.translate(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.drawImage(this.source, 0, 0, this.width * pxs, this.height * pxs);
renderingLayer.resetMatrix();
ctx.globalAlpha = 1;
Expand Down
2 changes: 1 addition & 1 deletion dist/renderables/VideoObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class VideoObject {
else {
Shadow.clear(renderingLayer);
}
ctx.moveTo(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.translate(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.drawImage(this.source, 0, 0, this.width * pxs, this.height * pxs);
renderingLayer.resetMatrix();
ctx.globalAlpha = 1;
Expand Down
3 changes: 1 addition & 2 deletions dist/renderables/geometries/Geometry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ declare type GetBoundingBoxType = {
(transform: Transform): IBoundingBox;
};
export declare abstract class Geometry implements IGeometry {
#private;
transform: Transform;
private _drawWithoutMatrixManipulation;
private _getBoundingBox;
constructor(draw: DrawWithoutMatrixManipulationType, getBoundingBox: GetBoundingBoxType);
contructMatrix(renderingLayer: IRenderingLayer): void;
destructMatrix(renderingLayer: IRenderingLayer): void;
Expand Down
12 changes: 6 additions & 6 deletions dist/renderables/geometries/Geometry.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Transform } from "../../properties/mod";
export class Geometry {
transform = new Transform();
_drawWithoutMatrixManipulation;
_getBoundingBox;
#drawWithoutMatrixManipulation;
#getBoundingBox;
constructor(draw, getBoundingBox) {
this._drawWithoutMatrixManipulation = draw;
this._getBoundingBox = getBoundingBox;
this.#drawWithoutMatrixManipulation = draw;
this.#getBoundingBox = getBoundingBox;
}
contructMatrix(renderingLayer) {
const t = this.transform;
Expand All @@ -18,14 +18,14 @@ export class Geometry {
const ctx = renderingLayer.getRenderingContext();
const pxs = renderingLayer.pixelScale;
const t = this.transform;
this._drawWithoutMatrixManipulation(ctx, pxs, t);
this.#drawWithoutMatrixManipulation(ctx, pxs, t);
}
draw(renderingLayer) {
this.contructMatrix(renderingLayer);
this.drawWithoutMatrixManipulation(renderingLayer);
this.destructMatrix(renderingLayer);
}
getBoundingBox(renderingLayer) {
return this._getBoundingBox(this.transform);
return this.#getBoundingBox(this.transform);
}
}
6 changes: 3 additions & 3 deletions dist/renderables/geometries/RectangleGeometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ export class RectangleGeometry extends Geometry {
width;
height;
constructor(width, height) {
const d = (ctx, pxs, t) => {
const draw = (ctx, pxs, t) => {
const width = this.width > 0 ? this.width : 0;
const height = this.height > 0 ? this.height : 0;
ctx.beginPath();
ctx.rect(-t.origin.x * pxs, -t.origin.y * pxs, width * pxs, height * pxs);
ctx.closePath();
};
const b = (t) => {
const getBoundingBox = (t) => {
return {
origin: t.origin.clone(),
size: new Vector(this.width, this.height),
};
};
super(d, b);
super(draw, getBoundingBox);
this.width = width;
this.height = height;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@templatone/kreslo",
"version": "4.2.0-beta.2",
"version": "4.2.0-beta.3",
"description": "Objective oriented typescript library for rendering 2d graphics.",
"keywords": [
"canvas",
Expand Down
3 changes: 1 addition & 2 deletions src/renderables/ImageObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class ImageObject implements IObject, IRenderable, IVisible, IClonable<Im
const pxs = renderingLayer.pixelScale;

const t = this.transform;

renderingLayer.setMatrixToTransform(t);

ctx.globalAlpha = Numbers.limit(this.opacity, 0, 1);
Expand All @@ -66,7 +65,7 @@ export class ImageObject implements IObject, IRenderable, IVisible, IClonable<Im
Shadow.clear(renderingLayer);
}

ctx.moveTo(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.translate(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.drawImage(this.source, 0, 0, this.width * pxs, this.height * pxs);

renderingLayer.resetMatrix();
Expand Down
2 changes: 1 addition & 1 deletion src/renderables/VideoObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class VideoObject implements IObject, IRenderable, IVisible, IClonable<Vi
Shadow.clear(renderingLayer);
}

ctx.moveTo(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.translate(-t.origin.x * pxs, -t.origin.y * pxs);
ctx.drawImage(this.source, 0, 0, this.width * pxs, this.height * pxs);

renderingLayer.resetMatrix();
Expand Down
13 changes: 6 additions & 7 deletions src/renderables/geometries/Geometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ export abstract class Geometry implements IGeometry {

transform: Transform = new Transform();

private _drawWithoutMatrixManipulation: DrawWithoutMatrixManipulationType;
private _getBoundingBox: GetBoundingBoxType;
#drawWithoutMatrixManipulation: DrawWithoutMatrixManipulationType;
#getBoundingBox: GetBoundingBoxType;


constructor(draw: DrawWithoutMatrixManipulationType, getBoundingBox: GetBoundingBoxType) {
this._drawWithoutMatrixManipulation = draw;
this._getBoundingBox = getBoundingBox;
this.#drawWithoutMatrixManipulation = draw;
this.#getBoundingBox = getBoundingBox;
}


Expand All @@ -44,8 +44,7 @@ export abstract class Geometry implements IGeometry {
const pxs = renderingLayer.pixelScale;

const t = this.transform;

this._drawWithoutMatrixManipulation(ctx, pxs, t);
this.#drawWithoutMatrixManipulation(ctx, pxs, t);
}


Expand All @@ -57,7 +56,7 @@ export abstract class Geometry implements IGeometry {


getBoundingBox(renderingLayer: IRenderingLayer): IBoundingBox {
return this._getBoundingBox(this.transform);
return this.#getBoundingBox(this.transform);
}

}
6 changes: 3 additions & 3 deletions src/renderables/geometries/RectangleGeometry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class RectangleGeometry extends Geometry implements IClonable<RectangleGe


constructor(width: number, height: number) {
const d = (ctx: CanvasRenderingContext2D, pxs: number, t: Transform) => {
const draw = (ctx: CanvasRenderingContext2D, pxs: number, t: Transform) => {
const width = this.width > 0 ? this.width : 0;
const height = this.height > 0 ? this.height : 0;

Expand All @@ -26,14 +26,14 @@ export class RectangleGeometry extends Geometry implements IClonable<RectangleGe
ctx.closePath();
}

const b = (t: Transform): IBoundingBox => {
const getBoundingBox = (t: Transform): IBoundingBox => {
return {
origin: t.origin.clone(),
size: new Vector(this.width, this.height),
}
}

super(d, b);
super(draw, getBoundingBox);

this.width = width;
this.height = height;
Expand Down

0 comments on commit 9892a2e

Please sign in to comment.