@@ -202,45 +202,35 @@ export class Cannoner extends ExternalInteractorBase<CannonContainer> {
202202 * Rendered directly on the container canvas context.
203203 */
204204 private _drawVector ( ) : void {
205- const canvas = this . container . canvas . element ;
206-
207- if ( ! canvas ) {
208- return ;
209- }
210-
211- const ctx = canvas . getContext ( "2d" ) ;
212-
213- if ( ! ctx ) {
214- return ;
215- }
216-
217- const opts = this . _cannonOptions ( ) ,
218- { origin, current } = this . _gesture ,
219- pxRatio = this . container . retina . pixelRatio ,
220- dragDist = getDistance ( origin , current ) ,
221- // Clamp to maxDragDistance so visual feedback matches actual force
222- clampedDist = Math . min ( dragDist , opts . maxDragDistance ) ,
223- clampRatio = dragDist > minDistance ? clampedDist / dragDist : minDistance ,
224- clampedX = origin . x + ( current . x - origin . x ) * clampRatio ,
225- clampedY = origin . y + ( current . y - origin . y ) * clampRatio ;
226-
227- ctx . save ( ) ;
228- ctx . strokeStyle = opts . vectorColor ;
229- ctx . lineWidth = double * pxRatio ;
230- ctx . beginPath ( ) ;
231- ctx . moveTo ( origin . x , origin . y ) ;
232- ctx . lineTo ( clampedX , clampedY ) ;
233- ctx . stroke ( ) ;
234-
235- // Power circle at origin — radius reflects clamped force
236- const radius = Math . max ( powerRadiusMin , clampedDist * powerRadiusMaxFactor ) * pxRatio ;
237-
238- ctx . beginPath ( ) ;
239- ctx . arc ( origin . x , origin . y , radius , minAngle , doublePI ) ;
240- ctx . strokeStyle = opts . vectorColor ;
241- ctx . lineWidth = double * pxRatio ;
242- ctx . stroke ( ) ;
243- ctx . restore ( ) ;
205+ this . container . canvas . render . draw ( ctx => {
206+ const opts = this . _cannonOptions ( ) ,
207+ { origin, current } = this . _gesture ,
208+ pxRatio = this . container . retina . pixelRatio ,
209+ dragDist = getDistance ( origin , current ) ,
210+ // Clamp to maxDragDistance so visual feedback matches actual force
211+ clampedDist = Math . min ( dragDist , opts . maxDragDistance ) ,
212+ clampRatio = dragDist > minDistance ? clampedDist / dragDist : minDistance ,
213+ clampedX = origin . x + ( current . x - origin . x ) * clampRatio ,
214+ clampedY = origin . y + ( current . y - origin . y ) * clampRatio ;
215+
216+ ctx . save ( ) ;
217+ ctx . strokeStyle = opts . vectorColor ;
218+ ctx . lineWidth = double * pxRatio ;
219+ ctx . beginPath ( ) ;
220+ ctx . moveTo ( origin . x , origin . y ) ;
221+ ctx . lineTo ( clampedX , clampedY ) ;
222+ ctx . stroke ( ) ;
223+
224+ // Power circle at origin — radius reflects clamped force
225+ const radius = Math . max ( powerRadiusMin , clampedDist * powerRadiusMaxFactor ) * pxRatio ;
226+
227+ ctx . beginPath ( ) ;
228+ ctx . arc ( origin . x , origin . y , radius , minAngle , doublePI ) ;
229+ ctx . strokeStyle = opts . vectorColor ;
230+ ctx . lineWidth = double * pxRatio ;
231+ ctx . stroke ( ) ;
232+ ctx . restore ( ) ;
233+ } ) ;
244234 }
245235
246236 /**
0 commit comments