11import { Project , service } from "@/core/Project" ;
22import { Settings } from "@/core/service/Settings" ;
3+ import { RectangleFadeEffect } from "@/core/service/feedbackService/effectEngine/concrete/RectangleFadeEffect" ;
34import { StageObject } from "@/core/stage/stageObject/abstract/StageObject" ;
45import { Edge } from "@/core/stage/stageObject/association/Edge" ;
56import { ImageNode } from "@/core/stage/stageObject/entity/ImageNode" ;
67import { Section } from "@/core/stage/stageObject/entity/Section" ;
78import { isMac } from "@/utils/platform" ;
8- import { Vector } from "@graphif/data-structures" ;
9+ import { Color , ProgressNumber , Vector } from "@graphif/data-structures" ;
910import { Rectangle } from "@graphif/shapes" ;
1011
1112/**
@@ -102,6 +103,10 @@ export class RectangleSelect {
102103 * 相当于鼠标松开释放
103104 */
104105 endSelecting ( ) {
106+ // 保存当前框选矩形和模式,用于创建淡化特效
107+ const currentRectangle = this . selectingRectangle ;
108+ const currentMode = this . getSelectMode ( ) ;
109+
105110 // 将所有选择到的增加到上次选择的节点中
106111 this . project . controller . lastSelectedEntityUUID . clear ( ) ;
107112 for ( const node of this . project . stageManager . getEntities ( ) ) {
@@ -116,6 +121,28 @@ export class RectangleSelect {
116121 this . project . controller . lastSelectedEdgeUUID . add ( edge . uuid ) ;
117122 }
118123 }
124+
125+ // 添加框选矩形淡化消失特效
126+ if ( currentRectangle ) {
127+ const style = this . project . stageStyleManager . currentStyle ;
128+ // 根据框选模式决定特效样式:
129+ // - 碰撞框选(intersect):只显示填充色,无边框
130+ // - 完全覆盖框选(contain):只显示边框色,无填充
131+ const isIntersectMode = currentMode === "intersect" ;
132+ const fillColor = isIntersectMode ? style . SelectRectangleFill . clone ( ) : Color . Transparent ;
133+ const strokeColor = isIntersectMode ? Color . Transparent : style . SelectRectangleBorder . toNewAlpha ( 1 ) ;
134+ const strokeWidth = isIntersectMode ? 0 : 1 ;
135+
136+ const effect = new RectangleFadeEffect (
137+ new ProgressNumber ( 0 , 20 ) ,
138+ currentRectangle ,
139+ fillColor ,
140+ strokeColor ,
141+ strokeWidth ,
142+ ) ;
143+ this . project . effects . addEffect ( effect ) ;
144+ }
145+
119146 this . selectingRectangle = null ;
120147 }
121148
0 commit comments