1- import { c as ctx , canvas } from "./Monopoly/Initialization" ;
21import './globals' ;
3-
2+ let canvas : HTMLCanvasElement ;
3+ let ctx : CanvasRenderingContext2D ;
44/*--------------------------------------Function-1------------------------------------------------------------------*/
55function backToIndex ( ) { /*collapse(1,313)*/
66 var currentURL = location . href ;
@@ -21,6 +21,7 @@ function getRandomColor() {
2121}
2222/*--------------------------------------Function-4------------------------------------------------------------------*/
2323function resizeCanvas ( ) {
24+ const canvas = ( window as any ) . globals . canvas ;
2425 //Get Window Ratio
2526 ( window as any ) . globals . windowRatio = window . innerWidth / ( window . innerHeight - ( window as any ) . globals . toolBarHeight ) ;
2627 //Get Canvas Ratio
@@ -141,6 +142,8 @@ Array.prototype.getControlByName = function (name: string) { //Ver se é mesmo n
141142var functionSaved = false ;
142143var functionSave : ( ) => void ;
143144function AnimationLOOP ( funct : ( ) => void ) {
145+ const canvas = ( window as any ) . globals . canvas ;
146+ const ctx = canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
144147 if ( ! functionSaved ) {
145148 functionSave = funct ;
146149 functionSaved = true ;
@@ -207,6 +210,8 @@ class Rectangle extends Control {
207210 }
208211
209212 public draw ( ) {
213+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
214+
210215 if ( this . visible ) {
211216 ctx . fillStyle = this . color ;
212217 ctx . strokeStyle = this . outlineColor ;
@@ -221,6 +226,8 @@ class Rectangle extends Control {
221226 }
222227
223228 drawParts_outline ( ) {
229+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
230+
224231 switch ( this . outlinePosition . toLowerCase ( ) ) {
225232 case "inner" :
226233 ctx . strokeRect ( this . x + this . outlineWidth / 2 , this . y + this . outlineWidth / 2 , this . width - this . outlineWidth , this . height - this . outlineWidth ) ;
@@ -235,6 +242,8 @@ class Rectangle extends Control {
235242 }
236243
237244 drawParts_patterns ( ) {
245+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
246+
238247 switch ( this . doPattern . toLowerCase ( ) ) {
239248 case "diagonals" :
240249 ctx . beginPath ( ) ;
@@ -291,6 +300,8 @@ class Circle extends Control {
291300 }
292301
293302 draw ( ) {
303+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
304+
294305 if ( this . visible ) {
295306 ctx . beginPath ( ) ;
296307 ctx . fillStyle = this . color ;
@@ -325,6 +336,8 @@ class Label extends Control {
325336 this . yAlign = "middle" ; //Vertical Aligning
326337 }
327338 updateContext ( ) {
339+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
340+
328341 if ( this . visible ) {
329342 ctx . fillStyle = this . color ;
330343 ctx . textAlign = this . xAlign ;
@@ -335,6 +348,8 @@ class Label extends Control {
335348 }
336349 }
337350 draw ( ) {
351+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
352+
338353 if ( this . visible ) {
339354 /*
340355 var something;
@@ -364,6 +379,8 @@ function Button(x: number, y: number, width: number, height: number, text: strin
364379Button . prototype = Object . create ( Rectangle . prototype ) ;
365380Button . prototype . constructor = Button ;
366381Button . prototype . draw = function ( ) {
382+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
383+
367384 if ( this . visible ) {
368385 //RECTANGLE DRAWING;
369386 //Configs:
@@ -406,6 +423,8 @@ Button.prototype.draw = function () {
406423 }
407424}
408425Button . prototype . onhover = function ( ) {
426+ const ctx = ( window as any ) . globals . canvas . getContext ( '2d' ) as CanvasRenderingContext2D ;
427+
409428 if ( this . xAlign == "center" ) { //Para sincronizar o hovering com os align, e para verificar se há hovering.
410429 var hovering1 = mouseX > this . x - ctx . measureText ( this . text ) . width / 2 - this . hoveringHeightIncrement ;
411430 var hovering2 = mouseX < this . x + ctx . measureText ( this . text ) . width / 2 + this . hoveringHeightIncrement ;
0 commit comments