@@ -3,4 +3,32 @@ import { writable } from 'svelte/store';
33export const radial_shape = writable ( 'circle' ) ;
44export const radial_named_position = writable ( 'center' ) ;
55export const radial_position = writable ( { x : null , y : null } ) ;
6- export const radial_size = writable ( 'farthest-corner' ) ;
6+ export const radial_size = writable ( 'farthest-corner' ) ;
7+
8+ // Reflect numeric position into named position when it matches a canonical value
9+ function posToName ( x : number , y : number ) : string | null {
10+ const tol = 0 // expect integers from UI/overlay
11+ const eq = ( a : number , b : number ) => Math . abs ( a - b ) <= tol
12+ if ( eq ( x , 50 ) && eq ( y , 50 ) ) return 'center'
13+ if ( eq ( x , 50 ) && eq ( y , 0 ) ) return 'top'
14+ if ( eq ( x , 100 ) && eq ( y , 50 ) ) return 'right'
15+ if ( eq ( x , 50 ) && eq ( y , 100 ) ) return 'bottom'
16+ if ( eq ( x , 0 ) && eq ( y , 50 ) ) return 'left'
17+ if ( eq ( x , 100 ) && eq ( y , 0 ) ) return 'top right'
18+ if ( eq ( x , 100 ) && eq ( y , 100 ) ) return 'bottom right'
19+ if ( eq ( x , 0 ) && eq ( y , 100 ) ) return 'bottom left'
20+ if ( eq ( x , 0 ) && eq ( y , 0 ) ) return 'top left'
21+ return null
22+ }
23+
24+ let syncing = false
25+ radial_position . subscribe ( v => {
26+ if ( syncing ) return
27+ const x = ( v as any ) ?. x
28+ const y = ( v as any ) ?. y
29+ if ( typeof x !== 'number' || typeof y !== 'number' ) return
30+ const name = posToName ( x , y )
31+ syncing = true
32+ try { radial_named_position . set ( name ?? '--' ) }
33+ finally { syncing = false }
34+ } )
0 commit comments