fix: fixed copying 1 gate

This commit is contained in:
Matei Adriel 2020-04-13 16:38:21 +03:00
parent 3c59690f30
commit 1a898dc926
3 changed files with 12 additions and 7 deletions

View file

@ -26,6 +26,7 @@ import { GateInitter } from '../types/GateInitter'
import { handleMouseDown } from '../helpers/handleMouseDown'
import { handleMouseUp } from '../helpers/handleMouseUp'
import { handleMouseMove } from '../helpers/handleMouseMove'
import { Gate } from '../../simulation/classes/Gate'
export class SimulationRenderer {
public mouseDownOutput = new Subject<MouseEventInfo>()
@ -117,7 +118,7 @@ export class SimulationRenderer {
* @throws SimulationError if an id isnt valid
* @throws SimulationError if the id doesnt have a data prop
*/
public getSelected() {
public getSelected(): Gate[] {
return setToArray(this.allSelectedIds()).map(id => {
const gate = this.simulation.gates.get(id)

View file

@ -7,7 +7,7 @@ import { vector2 } from '../../../common/math/types/vector2'
export const add = (...vectors: vector2[]): vector2 => {
const first = vectors[0]
const others = vectors.slice(1)
const othersSum = others.length > 1 ? add(...others) : others[0]
const othersSum = others.length >= 1 ? add(...others) : [0, 0]
return first.map((value, index) => value + othersSum[index]) as vector2
}
@ -69,4 +69,4 @@ export const inverse = (vector: vector2) => vector.map(a => 1 / a) as vector2
*
* @param vectors tHe vectors to find the averege of
*/
export const averege = (...vectors: vector2[]) => multiply(add(...vectors), 1 / vectors.length)
export const averege = (...vectors: vector2[]): vector2 => vectors.length ? multiply(add(...vectors), 1 / vectors.length) : [0, 0]

View file

@ -3,12 +3,16 @@
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "preserve",
"noImplicitAny": true,
"experimentalDecorators": true,
"target": "esnext",
"downlevelIteration": true,
"strictNullChecks": true,
"module": "esnext"
},
"exclude": ["node_modules"],
"include": ["src"]
"exclude": [
"node_modules"
],
"include": [
"src"
]
}