@@ -32,7 +32,7 @@ export class SelectionManager {
3232 }
3333
3434 private resetCursor ( ) {
35- this . canvas . style . cursor = "auto " ;
35+ this . canvas . style . cursor = "" ;
3636 }
3737
3838 private onUpdateCallback : ( ) => void = ( ) => { } ;
@@ -110,18 +110,21 @@ export class SelectionManager {
110110 case "diamond" :
111111 bounds . width = shape . width ;
112112 bounds . height = shape . height ;
113- // bounds.x = shape.x - shape.width / 2 - 10;
114- // bounds.y = shape.y - shape.height / 2 - 10;
115- bounds . x = shape . x ;
116- bounds . y = shape . y ;
113+ bounds . x = shape . x - shape . width / 2 ;
114+ bounds . y = shape . y - shape . height / 2 ;
117115 break ;
118116
119117 case "line" :
120118 // case "arrow":
121- bounds . width = Math . abs ( shape . x - shape . toX ) + 20 ;
122- bounds . height = Math . abs ( shape . y - shape . toY ) + 20 ;
123- bounds . x = Math . min ( shape . x , shape . toX ) - 10 ;
124- bounds . y = Math . min ( shape . y , shape . toY ) - 10 ;
119+ const minX = Math . min ( shape . x , shape . toX ) ;
120+ const minY = Math . min ( shape . y , shape . toY ) ;
121+ const maxX = Math . max ( shape . x , shape . toX ) ;
122+ const maxY = Math . max ( shape . y , shape . toY ) ;
123+
124+ bounds . x = minX - shape . strokeWidth ;
125+ bounds . y = minY - shape . strokeWidth ;
126+ bounds . width = maxX - minX + shape . strokeWidth * 2 ;
127+ bounds . height = maxY - minY + shape . strokeWidth * 2 ;
125128 break ;
126129
127130 // case "text":
@@ -201,7 +204,7 @@ export class SelectionManager {
201204 this . ctx . roundRect (
202205 handle . x - handleSize / 2 ,
203206 handle . y - handleSize / 2 ,
204- handleSize ,
207+ handleSize ,
205208 handleSize ,
206209 3
207210 ) ;
@@ -259,6 +262,11 @@ export class SelectionManager {
259262 x : x - this . selectedShape . x ,
260263 y : y - this . selectedShape . y ,
261264 } ;
265+ } else if ( this . selectedShape . type === "diamond" ) {
266+ this . dragOffset = {
267+ x : x - this . selectedShape . x ,
268+ y : y - this . selectedShape . y ,
269+ } ;
262270 } else if ( this . selectedShape . type !== "pen" ) {
263271 this . dragOffset = {
264272 x : x - this . selectedShape . x ,
@@ -389,8 +397,12 @@ export class SelectionManager {
389397 this . selectedShape . radX = newBounds . width / 2 ;
390398 this . selectedShape . radY = newBounds . height / 2 ;
391399 } else if ( this . selectedShape . type === "diamond" ) {
392- this . selectedShape . width =
393- Math . max ( Math . abs ( newBounds . width ) , Math . abs ( newBounds . height ) ) / 2 ;
400+ const centerX = newBounds . x + newBounds . width / 2 ;
401+ const centerY = newBounds . y + newBounds . height / 2 ;
402+ this . selectedShape . x = centerX ;
403+ this . selectedShape . y = centerY ;
404+ this . selectedShape . width = newBounds . width ;
405+ this . selectedShape . height = newBounds . height ;
394406 } else if ( this . selectedShape . type === "line" ) {
395407 // || this.selectedShape.type === "arrow") {
396408 // Update line/arrow endpoints based on the resize handle
0 commit comments