refactor: ShapeView owned by physics

This commit is contained in:
cha0s 2019-03-28 02:39:04 -05:00
parent 077b20a56c
commit 0bb3a05f8d
5 changed files with 11 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import {compose} from '@avocado/core';
import {Color, Container, Primitives, ShapeView} from '@avocado/graphics';
import {Color, Container, Primitives} from '@avocado/graphics';
import {Rectangle, Vector} from '@avocado/math';
import {BodyView, shapeFromJSON} from '@avocado/physics';
import {BodyView, shapeFromJSON, ShapeView} from '@avocado/physics';
import {StateProperty, Trait} from '../trait';

View File

@ -9,7 +9,6 @@ export {Image} from './image';
export {Primitives} from './primitives';
export {Renderable} from './renderable';
export {Renderer} from './renderer';
export {ShapeView} from './shape-view';
export {Sprite} from './sprite';
if (PIXI) {

View File

@ -21,13 +21,13 @@ export class BodyView extends Renderable {
this.primitives.drawLine(
[xMiddle, aabb[1]],
[xMiddle, aabb[1] + (aabb[3] - 0.0001)],
Primitives.lineStyle(new Color(255, 255, 0), 1)
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
);
const yMiddle = aabb[1] + (aabb[3] / 2);
this.primitives.drawLine(
[aabb[0], yMiddle],
[aabb[0] + (aabb[2] -0.0001), yMiddle],
Primitives.lineStyle(new Color(255, 255, 0), 1)
Primitives.lineStyle(new Color(255, 255, 0), 0.5)
);
}

View File

@ -9,6 +9,8 @@ export {RectangleShape};
import {ShapeList} from './list';
export {ShapeList};
export {ShapeView} from './shape-view';
export function shapeFromJSON(json) {
let shape;
switch (json.type) {

View File

@ -1,9 +1,7 @@
import {ShapeList, PolygonShape} from '@avocado/physics';
import {Color, Container, Primitives, Renderable} from '@avocado/graphics';
import {Color} from './color';
import {Container} from './container';
import {Primitives} from './primitives';
import {Renderable} from './renderable';
import {ShapeList} from './list';
import {PolygonShape} from './polygon';
export class ShapeView extends Renderable {
@ -45,7 +43,7 @@ export class ShapeView extends Renderable {
primitives.drawLine(
lastVertice,
vertice,
Primitives.lineStyle(new Color(255, 0, 255), 1),
Primitives.lineStyle(new Color(255, 0, 255), 0.5),
);
}
lastVertice = vertice;
@ -53,7 +51,7 @@ export class ShapeView extends Renderable {
primitives.drawLine(
lastVertice,
firstVertice,
Primitives.lineStyle(new Color(255, 0, 255), 1),
Primitives.lineStyle(new Color(255, 0, 255), 0.5),
);
this.container.removeAllChildren();
this.container.addChild(primitives);