From 13521ba3ee4d6fe3c3e170a38c2d122ae8631829 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Fri, 2 Aug 2019 12:01:32 +0300 Subject: [PATCH] changed a texture --- src/assets/ic.svg | 22 +++++++++++++++++++ .../integrated-circuits/helpers/compileIc.ts | 6 ++++- src/modules/saving/helpers/fromState.ts | 8 +++---- src/modules/simulation/helpers/addGate.ts | 16 +++++++++----- 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 src/assets/ic.svg diff --git a/src/assets/ic.svg b/src/assets/ic.svg new file mode 100644 index 0000000..0016a8c --- /dev/null +++ b/src/assets/ic.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/modules/integrated-circuits/helpers/compileIc.ts b/src/modules/integrated-circuits/helpers/compileIc.ts index 3e7fd5c..8566a62 100644 --- a/src/modules/integrated-circuits/helpers/compileIc.ts +++ b/src/modules/integrated-circuits/helpers/compileIc.ts @@ -48,7 +48,11 @@ export const compileIc = (state: SimulationState) => { count: outputCount } }, - category: categories.ic + category: categories.ic, + material: { + type: 'image', + fill: require('../../../assets/ic') + } } templateStore.set(name, result) diff --git a/src/modules/saving/helpers/fromState.ts b/src/modules/saving/helpers/fromState.ts index 454c0c9..a0dcb6e 100644 --- a/src/modules/saving/helpers/fromState.ts +++ b/src/modules/saving/helpers/fromState.ts @@ -13,6 +13,7 @@ import { calculateGateHeight } from '../../simulationRenderer/helpers/calculateG import { getRendererSafely } from '../../logic-gates/helpers/getRendererSafely' import { rendererSubject } from '../../core/subjects/rendererSubject' import { filter, take } from 'rxjs/operators' +import { vector2 } from '../../../common/math/types/vector2' /** * Contains methods for transforming saved state into the respective class instances @@ -46,10 +47,9 @@ export const fromSimulationState = ( gate.transform = fromTransformState(gateState.transform) const fixWrongHeight = () => { - gate.transform.height = calculateGateHeight( - getRendererSafely(), - gate - ) + gate.transform.scale = [...Array(2)].fill( + calculateGateHeight(getRendererSafely(), gate) + ) as vector2 } try { diff --git a/src/modules/simulation/helpers/addGate.ts b/src/modules/simulation/helpers/addGate.ts index 2e0fb81..207d877 100644 --- a/src/modules/simulation/helpers/addGate.ts +++ b/src/modules/simulation/helpers/addGate.ts @@ -1,7 +1,12 @@ import { templateStore } from '../../saving/stores/templateStore' import { SimulationError } from '../../errors/classes/SimulationError' import { Gate } from '../classes/Gate' -import { add, relativeTo, multiply } from '../../vector2/helpers/basic' +import { + add, + relativeTo, + multiply, + multiplyVectors +} from '../../vector2/helpers/basic' import { SimulationRenderer } from '../../simulationRenderer/classes/SimulationRenderer' import { DefaultGateTemplate } from '../constants' import { vector2 } from '../../../common/math/types/vector2' @@ -35,16 +40,17 @@ export const addGate = ( ? (template.shape.scale as vector2) : DefaultGateTemplate.shape.scale - const origin = relativeTo( - multiply(gateScale, 0.5), - relativeTo(renderer.camera.transform.position, Screen.center) + const origin = renderer.camera.toWordPostition( + add(multiply(gateScale, 0.5), Screen.center) ) const scalarOffset = renderer.options.spawning.spawnOffset const offset = multiply([scalarOffset, scalarOffset], renderer.spawnCount) gate.transform.position = add(origin, offset) - gate.transform.height = calculateGateHeight(renderer, gate) + gate.transform.scale = [...Array(2)].fill( + calculateGateHeight(renderer, gate) + ) as vector2 renderer.simulation.push(gate) renderer.spawnCount++