@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
22import styled from 'styled-components' ;
33import { AnimationState , AnimationTimeline } from '../state/animationSlice' ;
44
5- // 主容器
5+ // 主容器 - 使用蓝色主题
66const VisualizerContainer = styled . div `
77 display: flex;
88 flex-direction: column;
@@ -11,7 +11,7 @@ const VisualizerContainer = styled.div`
1111 align-items: center;
1212 padding: 20px;
1313 overflow: auto;
14- background: radial-gradient(circle at 50% 50%, rgba(237, 231, 246 , 0.3), rgba(179, 157, 219 , 0.1));
14+ background: radial-gradient(circle at 50% 50%, rgba(227, 242, 253 , 0.3), rgba(187, 222, 251 , 0.1));
1515` ;
1616
1717// 算法步骤区域
@@ -32,20 +32,20 @@ const Matrix3DContainer = styled.div<{ active?: boolean }>`
3232 filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
3333
3434 ${ props => props . active && `
35- filter: drop-shadow(0 8px 16px rgba(103, 58, 183 , 0.4));
35+ filter: drop-shadow(0 8px 16px rgba(33, 150, 243 , 0.4));
3636 transform: scale(1.05);
3737 ` }
3838` ;
3939
40- // 矩阵容器
40+ // 矩阵容器 - 使用蓝色
4141const MatrixWrapper = styled . div < { isPowered ?: boolean ; power ?: number } > `
4242 display: inline-grid;
4343 grid-template-columns: repeat(2, 50px);
4444 grid-template-rows: repeat(2, 50px);
4545 gap: 2px;
4646 padding: 10px;
4747 border-radius: 8px;
48- background-color: ${ props => props . isPowered ? '#7E57C2 ' : '#9575CD ' } ;
48+ background-color: ${ props => props . isPowered ? '#1976D2 ' : '#42A5F5 ' } ;
4949 position: relative;
5050 transform-style: preserve-3d;
5151 transform: rotateX(10deg) rotateY(-5deg);
@@ -62,7 +62,7 @@ const MatrixWrapper = styled.div<{ isPowered?: boolean; power?: number }>`
6262 left: 0;
6363 font-size: 16px;
6464 font-weight: bold;
65- color: #512DA8 ;
65+ color: #1565C0 ;
6666 text-shadow: 0 1px 2px rgba(0,0,0,0.2);
6767 }
6868` ;
@@ -74,7 +74,7 @@ const MatrixCell = styled.div<{ highlight?: boolean; calculating?: boolean }>`
7474 align-items: center;
7575 width: 100%;
7676 height: 100%;
77- background-color: ${ props => props . highlight ? '#E1BEE7 ' : 'white' } ;
77+ background-color: ${ props => props . highlight ? '#BBDEFB ' : 'white' } ;
7878 border-radius: 4px;
7979 font-weight: ${ props => props . highlight ? 'bold' : 'normal' } ;
8080 font-size: 16px;
@@ -91,7 +91,7 @@ const MatrixCell = styled.div<{ highlight?: boolean; calculating?: boolean }>`
9191 left: 0;
9292 right: 0;
9393 bottom: 0;
94- background: linear-gradient(90deg, transparent, rgba(103, 58, 183 , 0.2), transparent);
94+ background: linear-gradient(90deg, transparent, rgba(33, 150, 243 , 0.2), transparent);
9595 animation: calculating 1.5s infinite;
9696 }
9797
@@ -120,20 +120,20 @@ const BinaryContainer = styled.div`
120120 width: 100%;
121121` ;
122122
123- // 单个二进制位
123+ // 单个二进制位 - 使用蓝色
124124const BinaryBit = styled . div < { active ?: boolean ; index : number } > `
125125 width: 40px;
126126 height: 40px;
127127 margin: 0 5px;
128128 display: flex;
129129 justify-content: center;
130130 align-items: center;
131- background-color: ${ props => props . active ? '#7E57C2 ' : '#E0E0E0' } ;
131+ background-color: ${ props => props . active ? '#1976D2 ' : '#E0E0E0' } ;
132132 color: ${ props => props . active ? 'white' : '#616161' } ;
133133 border-radius: 50%;
134134 font-weight: bold;
135135 font-size: 16px;
136- box-shadow: ${ props => props . active ? '0 4px 8px rgba(103, 58, 183 , 0.4)' : '0 2px 4px rgba(0,0,0,0.1)' } ;
136+ box-shadow: ${ props => props . active ? '0 4px 8px rgba(33, 150, 243 , 0.4)' : '0 2px 4px rgba(0,0,0,0.1)' } ;
137137 transition: all 0.3s ease;
138138 position: relative;
139139
@@ -147,7 +147,7 @@ const BinaryBit = styled.div<{ active?: boolean; index: number }>`
147147
148148 &:hover {
149149 transform: translateY(-3px);
150- box-shadow: ${ props => props . active ? '0 6px 12px rgba(103, 58, 183 , 0.5)' : '0 4px 8px rgba(0,0,0,0.2)' } ;
150+ box-shadow: ${ props => props . active ? '0 6px 12px rgba(33, 150, 243 , 0.5)' : '0 4px 8px rgba(0,0,0,0.2)' } ;
151151 }
152152` ;
153153
@@ -164,7 +164,7 @@ const MatrixMultiplicationArea = styled.div`
164164const OperatorSign = styled . div `
165165 font-size: 24px;
166166 margin: 0 15px;
167- color: #512DA8 ;
167+ color: #1565C0 ;
168168 font-weight: bold;
169169` ;
170170
@@ -182,7 +182,7 @@ const ResultArrow = styled.div`
182182 left: 0;
183183 width: 100%;
184184 height: 4px;
185- background-color: #512DA8 ;
185+ background-color: #1565C0 ;
186186 transform: translateY(-50%);
187187 }
188188
@@ -193,8 +193,8 @@ const ResultArrow = styled.div`
193193 right: 0;
194194 width: 12px;
195195 height: 12px;
196- border-top: 4px solid #512DA8 ;
197- border-right: 4px solid #512DA8 ;
196+ border-top: 4px solid #1565C0 ;
197+ border-right: 4px solid #1565C0 ;
198198 transform: translateY(-50%) rotate(45deg);
199199 }
200200` ;
@@ -214,7 +214,7 @@ const ExplanationPanel = styled.div`
214214// 步骤标题
215215const StepTitle = styled . h3 `
216216 font-size: 18px;
217- color: #512DA8 ;
217+ color: #1565C0 ;
218218 margin-bottom: 10px;
219219` ;
220220
@@ -250,7 +250,7 @@ const ProgressIndicator = styled.div`
250250const Progress = styled . div < { percent : number } > `
251251 height: 100%;
252252 width: ${ props => props . percent } %;
253- background-color: #7E57C2 ;
253+ background-color: #2196F3 ;
254254 border-radius: 3px;
255255 transition: width 0.3s ease;
256256` ;
@@ -265,9 +265,6 @@ const MatrixFastPower: React.FC<MatrixFastPowerProps> = ({ n, state, currentTime
265265 // 基础矩阵 [[1,1],[1,0]]
266266 const baseMatrix = [ [ 1 , 1 ] , [ 1 , 0 ] ] ;
267267
268- // 当前展示的矩阵幂次
269- const [ powers , setPowers ] = useState < number [ ] > ( [ ] ) ;
270-
271268 // 二进制展示
272269 const [ binaryBits , setBinaryBits ] = useState < number [ ] > ( [ ] ) ;
273270
@@ -290,16 +287,7 @@ const MatrixFastPower: React.FC<MatrixFastPowerProps> = ({ n, state, currentTime
290287 // 将每一位转换为数字
291288 const bits = binaryStr . split ( '' ) . map ( bit => parseInt ( bit , 10 ) ) ;
292289
293- // 计算需要的幂次
294- const requiredPowers = [ ] ;
295- for ( let i = 0 ; i < bits . length ; i ++ ) {
296- if ( bits [ i ] === 1 ) {
297- requiredPowers . push ( bits . length - 1 - i ) ;
298- }
299- }
300-
301290 setBinaryBits ( bits ) ;
302- setPowers ( requiredPowers ) ;
303291 } , [ n ] ) ;
304292
305293 // 根据当前步骤更新显示
@@ -321,7 +309,7 @@ const MatrixFastPower: React.FC<MatrixFastPowerProps> = ({ n, state, currentTime
321309 // 更新结果矩阵
322310 const power = Math . floor ( step / 3 ) ;
323311 if ( power < binaryBits . length && binaryBits [ binaryBits . length - 1 - power ] === 1 ) {
324- setResultMatrix ( matrixMultiply ( resultMatrix , intermediateMatrix ) ) ;
312+ setResultMatrix ( prev => matrixMultiply ( prev , intermediateMatrix ) ) ;
325313 }
326314 }
327315 }
@@ -347,7 +335,7 @@ const MatrixFastPower: React.FC<MatrixFastPowerProps> = ({ n, state, currentTime
347335 } ;
348336
349337 // 辅助函数:矩阵快速幂
350- const matrixPower = ( matrix : number [ ] [ ] , power : number ) => {
338+ const matrixPower = ( matrix : number [ ] [ ] , power : number ) : number [ ] [ ] => {
351339 if ( power === 0 ) {
352340 return [ [ 1 , 0 ] , [ 0 , 1 ] ] ; // 单位矩阵
353341 }
@@ -471,4 +459,4 @@ const MatrixFastPower: React.FC<MatrixFastPowerProps> = ({ n, state, currentTime
471459 ) ;
472460} ;
473461
474- export default MatrixFastPower ;
462+ export default MatrixFastPower ;
0 commit comments