@@ -230,6 +230,11 @@ export class FabricjsEditorComponent implements AfterViewInit {
230230 this . selectItemAfterAdded ( add ) ;
231231 }
232232
233+ changeFigureColor ( color ) {
234+ this . canvas . getActiveObject ( ) . set ( "fill" , color ) ;
235+ this . canvas . renderAll ( ) ;
236+ } ;
237+
233238 /*Canvas*/
234239
235240 cleanSelect ( ) {
@@ -250,7 +255,7 @@ export class FabricjsEditorComponent implements AfterViewInit {
250255
251256 extend ( obj , id ) {
252257 obj . toObject = ( ( toObject ) => {
253- return function ( ) {
258+ return function ( ) {
254259 return fabric . util . object . extend ( toObject . call ( this ) , {
255260 id
256261 } ) ;
@@ -295,21 +300,21 @@ export class FabricjsEditorComponent implements AfterViewInit {
295300
296301 if ( typeof value === 'string' ) {
297302 if ( value . includes ( 'underline' ) ) {
298- object . setSelectionStyles ( { underline : true } ) ;
303+ object . setSelectionStyles ( { underline : true } ) ;
299304 } else {
300- object . setSelectionStyles ( { underline : false } ) ;
305+ object . setSelectionStyles ( { underline : false } ) ;
301306 }
302307
303308 if ( value . includes ( 'overline' ) ) {
304- object . setSelectionStyles ( { overline : true } ) ;
309+ object . setSelectionStyles ( { overline : true } ) ;
305310 } else {
306- object . setSelectionStyles ( { overline : false } ) ;
311+ object . setSelectionStyles ( { overline : false } ) ;
307312 }
308313
309314 if ( value . includes ( 'line-through' ) ) {
310- object . setSelectionStyles ( { linethrough : true } ) ;
315+ object . setSelectionStyles ( { linethrough : true } ) ;
311316 } else {
312- object . setSelectionStyles ( { linethrough : false } ) ;
317+ object . setSelectionStyles ( { linethrough : false } ) ;
313318 }
314319 }
315320
@@ -319,7 +324,7 @@ export class FabricjsEditorComponent implements AfterViewInit {
319324 } else {
320325 if ( typeof value === 'string' ) {
321326 if ( value . includes ( 'underline' ) ) {
322- object . set ( 'underline' , true ) ;
327+ object . set ( 'underline' , true ) ;
323328 } else {
324329 object . set ( 'underline' , false ) ;
325330 }
@@ -502,8 +507,8 @@ export class FabricjsEditorComponent implements AfterViewInit {
502507
503508
504509 removeSelected ( ) {
505- const activeObject :any = this . canvas . getActiveObject ( ) ;
506- const activeGroup :any = this . canvas . getActiveObjects ( ) ;
510+ const activeObject : any = this . canvas . getActiveObject ( ) ;
511+ const activeGroup : any = this . canvas . getActiveObjects ( ) ;
507512
508513 if ( activeObject && ! activeObject . _objects ) {
509514 this . canvas . remove ( activeObject ) ;
@@ -556,20 +561,20 @@ export class FabricjsEditorComponent implements AfterViewInit {
556561
557562 rasterize ( ) {
558563 const image = new Image ( ) ;
559- image . src = this . canvas . toDataURL ( { format : 'png' } ) ;
564+ image . src = this . canvas . toDataURL ( { format : 'png' } ) ;
560565 const w = window . open ( '' ) ;
561566 w . document . write ( image . outerHTML ) ;
562567 this . downLoadImage ( ) ;
563568 }
564569
565- downLoadImage ( ) {
566- const c = this . canvas . toDataURL ( { format : 'png' } ) ;
570+ downLoadImage ( ) {
571+ const c = this . canvas . toDataURL ( { format : 'png' } ) ;
567572 const downloadLink = document . createElement ( 'a' ) ;
568573 document . body . appendChild ( downloadLink ) ;
569574 downloadLink . href = c ;
570575 downloadLink . target = '_self' ;
571- downloadLink . download = Date . now ( ) + '.png' ;
572- downloadLink . click ( ) ;
576+ downloadLink . download = Date . now ( ) + '.png' ;
577+ downloadLink . click ( ) ;
573578 }
574579
575580 rasterizeSVG ( ) {
@@ -579,14 +584,14 @@ export class FabricjsEditorComponent implements AfterViewInit {
579584 return 'data:image/svg+xml;utf8,' + encodeURIComponent ( this . canvas . toSVG ( ) ) ;
580585 }
581586
582- downLoadSVG ( ) {
587+ downLoadSVG ( ) {
583588 const c = 'data:image/svg+xml;utf8,' + encodeURIComponent ( this . canvas . toSVG ( ) ) ;
584589 const downloadLink = document . createElement ( 'a' ) ;
585590 document . body . appendChild ( downloadLink ) ;
586591 downloadLink . href = c ;
587592 downloadLink . target = '_self' ;
588- downloadLink . download = Date . now ( ) + '.svg' ;
589- downloadLink . click ( ) ;
593+ downloadLink . download = Date . now ( ) + '.svg' ;
594+ downloadLink . click ( ) ;
590595 }
591596
592597 saveCanvasToJSON ( ) {
@@ -627,7 +632,7 @@ export class FabricjsEditorComponent implements AfterViewInit {
627632 this . figureEditor = false ;
628633 }
629634
630- drawingMode ( ) {
635+ drawingMode ( ) {
631636 this . canvas . isDrawingMode = ! this . canvas . isDrawingMode ;
632637 }
633638
0 commit comments