// // Copyright 2020 FoxyUtils ehf. All rights reserved. // // This is a commercial product and requires a license to operate. // A trial license can be obtained at https://unidoc.io // // DO NOT EDIT: generated by unitwist Go source code obfuscator. // // Use of this source code is governed by the UniDoc End User License Agreement // terms that can be accessed at https://unidoc.io/eula/ package imagerender ;import (_da "errors";_d "fmt";_dae "github.com/golang/freetype/raster";_bd "github.com/unidoc/unipdf/v3/common";_b "github.com/unidoc/unipdf/v3/internal/transform";_bb "github.com/unidoc/unipdf/v3/render/internal/context";_a "golang.org/x/image/draw";_df "golang.org/x/image/font";_ge "golang.org/x/image/math/f64";_bg "golang.org/x/image/math/fixed";_f "image";_ga "image/color";_ec "image/draw";_g "math";_eg "sort";_ea "strings";);func (_ced *Context )Identity (){_ced ._ead =_b .IdentityMatrix ()};func (_fce *Context )SetLineJoin (lineJoin _bb .LineJoin ){_fce ._fc =lineJoin };func (_bbff *Context )Stroke (){_bbff .StrokePreserve ();_bbff .ClearPath ()};func _ee (_ace ,_geb ,_gg ,_bbde ,_bbc ,_ecc ,_af ,_fbcb ,_gd float64 )(_cb ,_fd float64 ){_eccc :=1-_gd ;_db :=_eccc *_eccc *_eccc ;_cbe :=3*_eccc *_eccc *_gd ;_dfc :=3*_eccc *_gd *_gd ;_fa :=_gd *_gd *_gd ;_cb =_db *_ace +_cbe *_gg +_dfc *_bbc +_fa *_af ;_fd =_db *_geb +_cbe *_bbde +_dfc *_ecc +_fa *_fbcb ;return ;};type repeatOp int ;var (_cf =_cfge (_ga .White );_ba =_cfge (_ga .Black ););func (_gca *Context )SetLineCap (lineCap _bb .LineCap ){_gca ._ece =lineCap };func (_gbb *Context )DrawEllipticalArc (x ,y ,rx ,ry ,angle1 ,angle2 float64 ){const _fga =16;for _beg :=0;_beg < _fga ;_beg ++{_face :=float64 (_beg +0)/_fga ;_bgeb :=float64 (_beg +1)/_fga ;_eebg :=angle1 +(angle2 -angle1 )*_face ;_adaa :=angle1 +(angle2 -angle1 )*_bgeb ;_cbc :=x +rx *_g .Cos (_eebg );_bfb :=y +ry *_g .Sin (_eebg );_cccc :=x +rx *_g .Cos ((_eebg +_adaa )/2);_fgbf :=y +ry *_g .Sin ((_eebg +_adaa )/2);_ddd :=x +rx *_g .Cos (_adaa );_ecf :=y +ry *_g .Sin (_adaa );_agg :=2*_cccc -_cbc /2-_ddd /2;_bbe :=2*_fgbf -_bfb /2-_ecf /2;if _beg ==0{if _gbb ._gffc {_gbb .LineTo (_cbc ,_bfb );}else {_gbb .MoveTo (_cbc ,_bfb );};};_gbb .QuadraticTo (_agg ,_bbe ,_ddd ,_ecf );};};func (_ag *Context )SetFillRule (fillRule _bb .FillRule ){_ag ._ceb =fillRule };func _fca (_fdg _bg .Int26_6 )float64 {const _cgdg ,_gcg =6,1<<6-1;if _fdg >=0{return float64 (_fdg >>_cgdg )+float64 (_fdg &_gcg )/64;};_fdg =-_fdg ;if _fdg >=0{return -(float64 (_fdg >>_cgdg )+float64 (_fdg &_gcg )/64);};return 0;};func (_deag *Context )DrawLine (x1 ,y1 ,x2 ,y2 float64 ){_deag .MoveTo (x1 ,y1 );_deag .LineTo (x2 ,y2 )};func (_dfda *Context )joiner ()_dae .Joiner {switch _dfda ._fc {case _bb .LineJoinBevel :return _dae .BevelJoiner ;case _bb .LineJoinRound :return _dae .RoundJoiner ;};return nil ;};func _cfcd (_gaeg string )(_ggf ,_ecea ,_ecae ,_bgge int ){_gaeg =_ea .TrimPrefix (_gaeg ,"\u0023");_bgge =255;if len (_gaeg )==3{_baf :="\u00251\u0078\u0025\u0031\u0078\u0025\u0031x";_d .Sscanf (_gaeg ,_baf ,&_ggf ,&_ecea ,&_ecae );_ggf |=_ggf <<4;_ecea |=_ecea <<4;_ecae |=_ecae <<4;};if len (_gaeg )==6{_dacg :="\u0025\u0030\u0032x\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078";_d .Sscanf (_gaeg ,_dacg ,&_ggf ,&_ecea ,&_ecae );};if len (_gaeg )==8{_dedb :="\u0025\u00302\u0078\u0025\u00302\u0078\u0025\u0030\u0032\u0078\u0025\u0030\u0032\u0078";_d .Sscanf (_gaeg ,_dedb ,&_ggf ,&_ecea ,&_ecae ,&_bgge );};return ;};func (_cfg *Context )DrawPoint (x ,y ,r float64 ){_cfg .Push ();_cagg ,_adc :=_cfg .Transform (x ,y );_cfg .Identity ();_cfg .DrawCircle (_cagg ,_adc ,r );_cfg .Pop ();};func NewContextForImage (im _f .Image )*Context {return NewContextForRGBA (_eacb (im ))};func _adeg (_caeb ,_gebd ,_afd ,_dcc ,_age ,_fgg float64 )float64 {return _caeb *_dcc +_gebd *_age +_afd *_fgg ;};func (_eeg *Context )ShearAbout (sx ,sy ,x ,y float64 ){_eeg .Translate (x ,y );_eeg .Shear (sx ,sy );_eeg .Translate (-x ,-y );};func (_eea *Context )SetStrokeRGBA (r ,g ,b ,a float64 ){_be :=_ga .NRGBA {uint8 (r *255),uint8 (g *255),uint8 (b *255),uint8 (a *255)};_eea ._de =_cfge (_be );};func (_aafa *radialGradient )AddColorStop (offset float64 ,color _ga .Color ){_aafa ._adbf =append (_aafa ._adbf ,stop {_bdf :offset ,_fba :color });_eg .Sort (_aafa ._adbf );};func (_fcd *Context )DrawArc (x ,y ,r ,angle1 ,angle2 float64 ){_fcd .DrawEllipticalArc (x ,y ,r ,r ,angle1 ,angle2 );};func (_gbd *Context )StrokePreserve (){var _eab _dae .Painter ;if _gbd ._fdf ==nil {if _cca ,_fcf :=_gbd ._de .(*solidPattern );_fcf {_cbea :=_dae .NewRGBAPainter (_gbd ._fbcg );_cbea .SetColor (_cca ._ecga );_eab =_cbea ;};};if _eab ==nil {_eab =_cdca (_gbd ._fbcg ,_gbd ._fdf ,_gbd ._de );};_gbd .stroke (_eab );};func (_bgef *Context )DrawRoundedRectangle (x ,y ,w ,h ,r float64 ){_fbe ,_bbfe ,_fffc ,_ebfd :=x ,x +r ,x +w -r ,x +w ;_cea ,_ecg ,_eaf ,_ada :=y ,y +r ,y +h -r ,y +h ;_bgef .NewSubPath ();_bgef .MoveTo (_bbfe ,_cea );_bgef .LineTo (_fffc ,_cea );_bgef .DrawArc (_fffc ,_ecg ,r ,_cfcf (270),_cfcf (360));_bgef .LineTo (_ebfd ,_eaf );_bgef .DrawArc (_fffc ,_eaf ,r ,_cfcf (0),_cfcf (90));_bgef .LineTo (_bbfe ,_ada );_bgef .DrawArc (_bbfe ,_eaf ,r ,_cfcf (90),_cfcf (180));_bgef .LineTo (_fbe ,_ecg );_bgef .DrawArc (_bbfe ,_ecg ,r ,_cfcf (180),_cfcf (270));_bgef .ClosePath ();};func (_cgd *Context )capper ()_dae .Capper {switch _cgd ._ece {case _bb .LineCapButt :return _dae .ButtCapper ;case _bb .LineCapRound :return _dae .RoundCapper ;case _bb .LineCapSquare :return _dae .SquareCapper ;};return nil ;};func (_ffe *Context )Width ()int {return _ffe ._bgc };func (_bgec *Context )SetMatrix (m _b .Matrix ){_bgec ._ead =m };func (_bde *Context )Image ()_f .Image {return _bde ._fbcg };func (_gbc *Context )DrawImage (im _f .Image ,x ,y int ){_gbc .DrawImageAnchored (im ,x ,y ,0,0)};func (_ffeb *Context )SetColor (c _ga .Color ){_ffeb .setFillAndStrokeColor (c )};func NewContext (width ,height int )*Context {return NewContextForRGBA (_f .NewRGBA (_f .Rect (0,0,width ,height )));};func (_fef *Context )DrawEllipse (x ,y ,rx ,ry float64 ){_fef .NewSubPath ();_fef .DrawEllipticalArc (x ,y ,rx ,ry ,0,2*_g .Pi );_fef .ClosePath ();};func (_bba *Context )ClipPreserve (){_fgc :=_f .NewAlpha (_f .Rect (0,0,_bba ._bgc ,_bba ._ca ));_cbb :=_dae .NewAlphaOverPainter (_fgc );_bba .fill (_cbb );if _bba ._fdf ==nil {_bba ._fdf =_fgc ;}else {_dfee :=_f .NewAlpha (_f .Rect (0,0,_bba ._bgc ,_bba ._ca ));_a .DrawMask (_dfee ,_dfee .Bounds (),_fgc ,_f .Point {},_bba ._fdf ,_f .Point {},_a .Over );_bba ._fdf =_dfee ;};};func _bbce (_fceb _dae .Path )[][]_b .Point {var _aba [][]_b .Point ;var _caga []_b .Point ;var _bced ,_cgb float64 ;for _egfa :=0;_egfa < len (_fceb );{switch _fceb [_egfa ]{case 0:if len (_caga )> 0{_aba =append (_aba ,_caga );_caga =nil ;};_cbba :=_fca (_fceb [_egfa +1]);_ggaa :=_fca (_fceb [_egfa +2]);_caga =append (_caga ,_b .NewPoint (_cbba ,_ggaa ));_bced ,_cgb =_cbba ,_ggaa ;_egfa +=4;case 1:_efgg :=_fca (_fceb [_egfa +1]);_bfd :=_fca (_fceb [_egfa +2]);_caga =append (_caga ,_b .NewPoint (_efgg ,_bfd ));_bced ,_cgb =_efgg ,_bfd ;_egfa +=4;case 2:_dfed :=_fca (_fceb [_egfa +1]);_bea :=_fca (_fceb [_egfa +2]);_cge :=_fca (_fceb [_egfa +3]);_aae :=_fca (_fceb [_egfa +4]);_feff :=_bf (_bced ,_cgb ,_dfed ,_bea ,_cge ,_aae );_caga =append (_caga ,_feff ...);_bced ,_cgb =_cge ,_aae ;_egfa +=6;case 3:_eff :=_fca (_fceb [_egfa +1]);_fbgg :=_fca (_fceb [_egfa +2]);_ebge :=_fca (_fceb [_egfa +3]);_ddfc :=_fca (_fceb [_egfa +4]);_edg :=_fca (_fceb [_egfa +5]);_gdd :=_fca (_fceb [_egfa +6]);_eaagb :=_eeb (_bced ,_cgb ,_eff ,_fbgg ,_ebge ,_ddfc ,_edg ,_gdd );_caga =append (_caga ,_eaagb ...);_bced ,_cgb =_edg ,_gdd ;_egfa +=8;default:_bd .Log .Debug ("\u0057\u0041\u0052\u004e: \u0069\u006e\u0076\u0061\u006c\u0069\u0064\u0020\u0070\u0061\u0074\u0068\u003a\u0020%\u0076",_fceb );return _aba ;};};if len (_caga )> 0{_aba =append (_aba ,_caga );};return _aba ;};func (_egef *Context )TextState ()*_bb .TextState {return _egef ._aa };func (_abba *Context )MeasureString (s string )(_bbdd ,_fag float64 ){_faa :=&_df .Drawer {Face :_abba ._aa .Tf .Face };_dda :=_faa .MeasureString (s );return float64 (_dda >>6),_abba ._aa .Tf .Size ;};func (_ffag *Context )Pop (){_bce :=*_ffag ;_adb :=_ffag ._gce ;_egec :=_adb [len (_adb )-1];*_ffag =*_egec ;_ffag ._aea =_bce ._aea ;_ffag ._dea =_bce ._dea ;_ffag ._acb =_bce ._acb ;_ffag ._gac =_bce ._gac ;_ffag ._gffc =_bce ._gffc ;_ffag ._aa =_bce ._aa ;};func (_dad *Context )Fill (){_dad .FillPreserve ();_dad .ClearPath ()};func (_dfdd *Context )fill (_abb _dae .Painter ){_bdb :=_dfdd ._dea ;if _dfdd ._gffc {_bdb =make (_dae .Path ,len (_dfdd ._dea ));copy (_bdb ,_dfdd ._dea );_bdb .Add1 (_fbag (_dfdd ._acb ));};_dca :=_dfdd ._efa ;_dca .UseNonZeroWinding =_dfdd ._ceb ==_bb .FillRuleWinding ;_dca .Clear ();_dca .AddPath (_bdb );_dca .Rasterize (_abb );};func NewContextForRGBA (im *_f .RGBA )*Context {_ebf :=im .Bounds ().Size ().X ;_dc :=im .Bounds ().Size ().Y ;return &Context {_bgc :_ebf ,_ca :_dc ,_efa :_dae .NewRasterizer (_ebf ,_dc ),_fbcg :im ,_dfd :_ga .Transparent ,_gbf :_cf ,_de :_ba ,_ff :1,_ceb :_bb .FillRuleWinding ,_ead :_b .IdentityMatrix (),_aa :_bb .NewTextState ()};};type linearGradient struct{_eae ,_gffb ,_aab ,_bbdc float64 ;_aef stops ;};func (_daed *Context )Clear (){_ccab :=_f .NewUniform (_daed ._dfd );_a .Draw (_daed ._fbcg ,_daed ._fbcg .Bounds (),_ccab ,_f .Point {},_a .Src );};func (_gcf *Context )LineTo (x ,y float64 ){if !_gcf ._gffc {_gcf .MoveTo (x ,y );}else {x ,y =_gcf .Transform (x ,y );_bec :=_b .NewPoint (x ,y );_bag :=_fbag (_bec );_gcf ._aea .Add1 (_bag );_gcf ._dea .Add1 (_bag );_gcf ._gac =_bec ;};};type stop struct{_bdf float64 ;_fba _ga .Color ;};func (_ade *Context )QuadraticTo (x1 ,y1 ,x2 ,y2 float64 ){if !_ade ._gffc {_ade .MoveTo (x1 ,y1 );};x1 ,y1 =_ade .Transform (x1 ,y1 );x2 ,y2 =_ade .Transform (x2 ,y2 );_cdd :=_b .NewPoint (x1 ,y1 );_cef :=_b .NewPoint (x2 ,y2 );_ecca :=_fbag (_cdd );_aaf :=_fbag (_cef );_ade ._aea .Add2 (_ecca ,_aaf );_ade ._dea .Add2 (_ecca ,_aaf );_ade ._gac =_cef ;};func (_deb *Context )SetLineWidth (lineWidth float64 ){_deb ._ff =lineWidth };func (_bgeff *Context )Shear (x ,y float64 ){_bgeff ._ead .Shear (x ,y )};type patternPainter struct{_eafd *_f .RGBA ;_gfb *_f .Alpha ;_aeaf _bb .Pattern ;};func _fbag (_gcfb _b .Point )_bg .Point26_6 {return _bg .Point26_6 {X :_def (_gcfb .X ),Y :_def (_gcfb .Y )}};func (_ebe *Context )SetHexColor (x string ){_ebd ,_gdba ,_bgga ,_ecd :=_cfcd (x );_ebe .SetRGBA255 (_ebd ,_gdba ,_bgga ,_ecd );};func (_ggc *Context )Push (){_fae :=*_ggc ;_ggc ._gce =append (_ggc ._gce ,&_fae )};func (_gebb *Context )ClearPath (){_gebb ._aea .Clear ();_gebb ._dea .Clear ();_gebb ._gffc =false };type circle struct{_aag ,_ccb ,_gedg float64 };type surfacePattern struct{_agc _f .Image ;_bbef repeatOp ;};func (_bfg *Context )drawString (_bgd *_f .RGBA ,_abd string ,_cfd ,_eed float64 ){_edf :=&_df .Drawer {Dst :_bgd ,Src :_f .NewUniform (_bfg ._dfd ),Face :_bfg ._aa .Tf .Face ,Dot :_fbag (_b .NewPoint (_cfd ,_eed ))};_cfce :=rune (-1);for _ ,_cead :=range _abd {if _cfce >=0{_edf .Dot .X +=_edf .Face .Kern (_cfce ,_cead );};_cga ,_fab ,_acd ,_bcf ,_aac :=_edf .Face .Glyph (_edf .Dot ,_cead );if !_aac {continue ;};_dfa :=_cga .Sub (_cga .Min );_dagb :=_a .BiLinear ;_bfbe :=_bfg ._ead .Clone ();_bfbe .Translate (float64 (_cga .Min .X ),float64 (_cga .Min .Y ));_gbe :=_ge .Aff3 {_bfbe [0],_bfbe [3],_bfbe [6],_bfbe [1],_bfbe [4],_bfbe [7]};_dagb .Transform (_edf .Dst ,_gbe ,_edf .Src ,_dfa ,_a .Over ,&_a .Options {SrcMask :_fab ,SrcMaskP :_acd });_edf .Dot .X +=_bcf ;_cfce =_cead ;};};func (_ffff *Context )Transform (x ,y float64 )(_ede ,_bab float64 ){return _ffff ._ead .Transform (x ,y )};func (_dd *Context )MoveTo (x ,y float64 ){if _dd ._gffc {_dd ._dea .Add1 (_fbag (_dd ._acb ));};x ,y =_dd .Transform (x ,y );_gab :=_b .NewPoint (x ,y );_aeb :=_fbag (_gab );_dd ._aea .Start (_aeb );_dd ._dea .Start (_aeb );_dd ._acb =_gab ;_dd ._gac =_gab ;_dd ._gffc =true ;};func _cfcf (_debb float64 )float64 {return _debb *_g .Pi /180};func (_cag *Context )SetPixel (x ,y int ){_cag ._fbcg .Set (x ,y ,_cag ._dfd )};func (_cddc *Context )DrawRectangle (x ,y ,w ,h float64 ){_cddc .NewSubPath ();_cddc .MoveTo (x ,y );_cddc .LineTo (x +w ,y );_cddc .LineTo (x +w ,y +h );_cddc .LineTo (x ,y +h );_cddc .ClosePath ();};func (_gbcf *Context )DrawImageAnchored (im _f .Image ,x ,y int ,ax ,ay float64 ){_gdea :=im .Bounds ().Size ();x -=int (ax *float64 (_gdea .X ));y -=int (ay *float64 (_gdea .Y ));_eaaa :=_a .BiLinear ;_dffg :=_gbcf ._ead .Clone ();_dffg .Translate (float64 (x ),float64 (y ));_beb :=_ge .Aff3 {_dffg [0],_dffg [3],_dffg [6],_dffg [1],_dffg [4],_dffg [7]};if _gbcf ._fdf ==nil {_eaaa .Transform (_gbcf ._fbcg ,_beb ,im ,im .Bounds (),_a .Over ,nil );}else {_eaaa .Transform (_gbcf ._fbcg ,_beb ,im ,im .Bounds (),_a .Over ,&_a .Options {DstMask :_gbcf ._fdf ,DstMaskP :_f .Point {}});};};type Context struct{_bgc int ;_ca int ;_efa *_dae .Rasterizer ;_fbcg *_f .RGBA ;_fdf *_f .Alpha ;_dfd _ga .Color ;_gbf _bb .Pattern ;_de _bb .Pattern ;_aea _dae .Path ;_dea _dae .Path ;_acb _b .Point ;_gac _b .Point ;_gffc bool ;_egd []float64 ;_egc float64 ;_ff float64 ;_ece _bb .LineCap ;_fc _bb .LineJoin ;_ceb _bb .FillRule ;_ead _b .Matrix ;_aa *_bb .TextState ;_gce []*Context ;};func (_egf *Context )drawRegularPolygon (_bgf int ,_bcb ,_cbcb ,_bace ,_bfba float64 ){_eaa :=2*_g .Pi /float64 (_bgf );_bfba -=_g .Pi /2;if _bgf %2==0{_bfba +=_eaa /2;};_egf .NewSubPath ();for _fcea :=0;_fcea < _bgf ;_fcea ++{_dfeb :=_bfba +_eaa *float64 (_fcea );_egf .LineTo (_bcb +_bace *_g .Cos (_dfeb ),_cbcb +_bace *_g .Sin (_dfeb ));};_egf .ClosePath ();};func _efga (_bfgc [][]_b .Point ,_agbd []float64 ,_bcec float64 )[][]_b .Point {var _caf [][]_b .Point ;if len (_agbd )==0{return _bfgc ;};if len (_agbd )==1{_agbd =append (_agbd ,_agbd [0]);};for _ ,_bgcb :=range _bfgc {if len (_bgcb )< 2{continue ;};_faea :=_bgcb [0];_dgg :=1;_cgg :=0;_eaee :=0.0;if _bcec !=0{var _cfcg float64 ;for _ ,_cff :=range _agbd {_cfcg +=_cff ;};_bcec =_g .Mod (_bcec ,_cfcg );if _bcec < 0{_bcec +=_cfcg ;};for _cfb ,_ecec :=range _agbd {_bcec -=_ecec ;if _bcec < 0{_cgg =_cfb ;_eaee =_ecec +_bcec ;break ;};};};var _eged []_b .Point ;_eged =append (_eged ,_faea );for _dgg < len (_bgcb ){_gaef :=_agbd [_cgg ];_cbcd :=_bgcb [_dgg ];_effc :=_faea .Distance (_cbcd );_gbge :=_gaef -_eaee ;if _effc > _gbge {_bfdf :=_gbge /_effc ;_aagc :=_faea .Interpolate (_cbcd ,_bfdf );_eged =append (_eged ,_aagc );if _cgg %2==0&&len (_eged )> 1{_caf =append (_caf ,_eged );};_eged =nil ;_eged =append (_eged ,_aagc );_eaee =0;_faea =_aagc ;_cgg =(_cgg +1)%len (_agbd );}else {_eged =append (_eged ,_cbcd );_faea =_cbcd ;_eaee +=_effc ;_dgg ++;};};if _cgg %2==0&&len (_eged )> 1{_caf =append (_caf ,_eged );};};return _caf ;};func _eacb (_fde _f .Image )*_f .RGBA {_aefa :=_fde .Bounds ();_aagb :=_f .NewRGBA (_aefa );_ec .Draw (_aagb ,_aefa ,_fde ,_aefa .Min ,_ec .Src );return _aagb ;};func (_cedc *linearGradient )AddColorStop (offset float64 ,color _ga .Color ){_cedc ._aef =append (_cedc ._aef ,stop {_bdf :offset ,_fba :color });_eg .Sort (_cedc ._aef );};func (_cee *Context )SetRGB (r ,g ,b float64 ){_cee .SetRGBA (r ,g ,b ,1)};func (_fdfb *Context )Scale (x ,y float64 ){_fdfb ._ead .Scale (x ,y )};const (_ccee repeatOp =iota ;_adca ;_ccf ;_eafe ;);type radialGradient struct{_fefc ,_ded ,_agb circle ;_cfde ,_cdc float64 ;_becd float64 ;_adbf stops ;};func (_cagd *linearGradient )ColorAt (x ,y int )_ga .Color {if len (_cagd ._aef )==0{return _ga .Transparent ;};_bda ,_fbac :=float64 (x ),float64 (y );_egba ,_bagf ,_ggb ,_acfb :=_cagd ._eae ,_cagd ._gffb ,_cagd ._aab ,_cagd ._bbdc ;_gae ,_ccac :=_ggb -_egba ,_acfb -_bagf ;if _ccac ==0&&_gae !=0{return _gbg ((_bda -_egba )/_gae ,_cagd ._aef );};if _gae ==0&&_ccac !=0{return _gbg ((_fbac -_bagf )/_ccac ,_cagd ._aef );};_gcfd :=_gae *(_bda -_egba )+_ccac *(_fbac -_bagf );if _gcfd < 0{return _cagd ._aef [0]._fba ;};_bbb :=_g .Hypot (_gae ,_ccac );_eaca :=((_bda -_egba )*-_ccac +(_fbac -_bagf )*_gae )/(_bbb *_bbb );_dfde ,_cba :=_egba +_eaca *-_ccac ,_bagf +_eaca *_gae ;_ggad :=_g .Hypot (_bda -_dfde ,_fbac -_cba )/_bbb ;return _gbg (_ggad ,_cagd ._aef );};func (_bcd stops )Less (i ,j int )bool {return _bcd [i ]._bdf < _bcd [j ]._bdf };func (_bc *Context )SetDashOffset (offset float64 ){_bc ._egc =offset };func (_dbc *Context )SetFillStyle (pattern _bb .Pattern ){if _bad ,_gdbc :=pattern .(*solidPattern );_gdbc {_dbc ._dfd =_bad ._ecga ;};_dbc ._gbf =pattern ;};func _ddde (_cbd _f .Image ,_acg repeatOp )_bb .Pattern {return &surfacePattern {_agc :_cbd ,_bbef :_acg }};func _bcbg (_ebdb ,_agbf ,_ecdg ,_ebfdc ,_bdgca ,_acdb float64 )_bb .Gradient {_bded :=circle {_ebdb ,_agbf ,_ecdg };_aca :=circle {_ebfdc ,_bdgca ,_acdb };_gba :=circle {_ebfdc -_ebdb ,_bdgca -_agbf ,_acdb -_ecdg };_eace :=_adeg (_gba ._aag ,_gba ._ccb ,-_gba ._gedg ,_gba ._aag ,_gba ._ccb ,_gba ._gedg );var _dada float64 ;if _eace !=0{_dada =1.0/_eace ;};_dab :=-_bded ._gedg ;_abbg :=&radialGradient {_fefc :_bded ,_ded :_aca ,_agb :_gba ,_cfde :_eace ,_cdc :_dada ,_becd :_dab };return _abbg ;};func (_adf *Context )DrawString (s string ,x ,y float64 ){_adf .DrawStringAnchored (s ,x ,y ,0,0)};func (_eeae *Context )Matrix ()_b .Matrix {return _eeae ._ead };func _edaf (_bgcc ,_caef uint32 ,_bdedd float64 )uint8 {return uint8 (int32 (float64 (_bgcc )*(1.0-_bdedd )+float64 (_caef )*_bdedd )>>8);};type solidPattern struct{_ecga _ga .Color };func _gefa (_bdge ,_fec ,_gbce ,_dddf float64 )_bb .Gradient {_gag :=&linearGradient {_eae :_bdge ,_gffb :_fec ,_aab :_gbce ,_bbdc :_dddf };return _gag ;};func (_eede stops )Len ()int {return len (_eede )};func (_bece *Context )Rotate (angle float64 ){_bece ._ead .Rotate (angle )};func (_ccgd *Context )FillPreserve (){var _fff _dae .Painter ;if _ccgd ._fdf ==nil {if _gef ,_ddc :=_ccgd ._gbf .(*solidPattern );_ddc {_ecdc :=_dae .NewRGBAPainter (_ccgd ._fbcg );_ecdc .SetColor (_gef ._ecga );_fff =_ecdc ;};};if _fff ==nil {_fff =_cdca (_ccgd ._fbcg ,_ccgd ._fdf ,_ccgd ._gbf );};_ccgd .fill (_fff );};func (_cege *patternPainter )Paint (ss []_dae .Span ,done bool ){_aee :=_cege ._eafd .Bounds ();for _ ,_bgad :=range ss {if _bgad .Y < _aee .Min .Y {continue ;};if _bgad .Y >=_aee .Max .Y {return ;};if _bgad .X0 < _aee .Min .X {_bgad .X0 =_aee .Min .X ;};if _bgad .X1 > _aee .Max .X {_bgad .X1 =_aee .Max .X ;};if _bgad .X0 >=_bgad .X1 {continue ;};const _bgebc =1<<16-1;_cgbe :=_bgad .Y -_cege ._eafd .Rect .Min .Y ;_decc :=_bgad .X0 -_cege ._eafd .Rect .Min .X ;_bgeg :=(_bgad .Y -_cege ._eafd .Rect .Min .Y )*_cege ._eafd .Stride +(_bgad .X0 -_cege ._eafd .Rect .Min .X )*4;_bcff :=_bgeg +(_bgad .X1 -_bgad .X0 )*4;for _bfbb ,_ffage :=_bgeg ,_decc ;_bfbb < _bcff ;_bfbb ,_ffage =_bfbb +4,_ffage +1{_gdef :=_bgad .Alpha ;if _cege ._gfb !=nil {_gdef =_gdef *uint32 (_cege ._gfb .AlphaAt (_ffage ,_cgbe ).A )/255;if _gdef ==0{continue ;};};_fbef :=_cege ._aeaf .ColorAt (_ffage ,_cgbe );_aece ,_agf ,_faeb ,_ecgd :=_fbef .RGBA ();_gec :=uint32 (_cege ._eafd .Pix [_bfbb +0]);_eegf :=uint32 (_cege ._eafd .Pix [_bfbb +1]);_cged :=uint32 (_cege ._eafd .Pix [_bfbb +2]);_gaba :=uint32 (_cege ._eafd .Pix [_bfbb +3]);_cec :=(_bgebc -(_ecgd *_gdef /_bgebc ))*0x101;_cege ._eafd .Pix [_bfbb +0]=uint8 ((_gec *_cec +_aece *_gdef )/_bgebc >>8);_cege ._eafd .Pix [_bfbb +1]=uint8 ((_eegf *_cec +_agf *_gdef )/_bgebc >>8);_cege ._eafd .Pix [_bfbb +2]=uint8 ((_cged *_cec +_faeb *_gdef )/_bgebc >>8);_cege ._eafd .Pix [_bfbb +3]=uint8 ((_gaba *_cec +_ecgd *_gdef )/_bgebc >>8);};};};func (_efg *Context )Translate (x ,y float64 ){_efg ._ead .Translate (x ,y )};func _gbg (_gebf float64 ,_eedg stops )_ga .Color {if _gebf <=0.0||len (_eedg )==1{return _eedg [0]._fba ;};_efba :=_eedg [len (_eedg )-1];if _gebf >=_efba ._bdf {return _efba ._fba ;};for _bdc ,_bcea :=range _eedg [1:]{if _gebf < _bcea ._bdf {_gebf =(_gebf -_eedg [_bdc ]._bdf )/(_bcea ._bdf -_eedg [_bdc ]._bdf );return _edb (_eedg [_bdc ]._fba ,_bcea ._fba ,_gebf );};};return _efba ._fba ;};func (_fbgb *Context )ClosePath (){if _fbgb ._gffc {_cae :=_fbag (_fbgb ._acb );_fbgb ._aea .Add1 (_cae );_fbgb ._dea .Add1 (_cae );_fbgb ._gac =_fbgb ._acb ;};};func (_dgf *Context )DrawCircle (x ,y ,r float64 ){_dgf .NewSubPath ();_dgf .DrawEllipticalArc (x ,y ,r ,r ,0,2*_g .Pi );_dgf .ClosePath ();};func (_bdgc *Context )InvertMask (){if _bdgc ._fdf ==nil {_bdgc ._fdf =_f .NewAlpha (_bdgc ._fbcg .Bounds ());}else {for _acbf ,_efb :=range _bdgc ._fdf .Pix {_bdgc ._fdf .Pix [_acbf ]=255-_efb ;};};};func (_ffa *Context )SetFillRGBA (r ,g ,b ,a float64 ){_bac :=_ga .NRGBA {uint8 (r *255),uint8 (g *255),uint8 (b *255),uint8 (a *255)};_ffa ._dfd =_bac ;_ffa ._gbf =_cfge (_bac );};func (_acbb *solidPattern )ColorAt (x ,y int )_ga .Color {return _acbb ._ecga };func (_fgb *Context )SetMask (mask *_f .Alpha )error {if mask .Bounds ().Size ()!=_fgb ._fbcg .Bounds ().Size (){return _da .New ("\u006d\u0061\u0073\u006b\u0020\u0073i\u007a\u0065\u0020\u006d\u0075\u0073\u0074\u0020\u006d\u0061\u0074\u0063\u0068 \u0063\u006f\u006e\u0074\u0065\u0078\u0074 \u0073\u0069\u007a\u0065");};_fgb ._fdf =mask ;return nil ;};func (_bga *Context )SetStrokeStyle (pattern _bb .Pattern ){_bga ._de =pattern };func (_ddf *Context )RotateAbout (angle ,x ,y float64 ){_ddf .Translate (x ,y );_ddf .Rotate (angle );_ddf .Translate (-x ,-y );};func _eeb (_cdb ,_gdb ,_ceg ,_ae ,_dac ,_afg ,_dfe ,_fac float64 )[]_b .Point {_eca :=(_g .Hypot (_ceg -_cdb ,_ae -_gdb )+_g .Hypot (_dac -_ceg ,_afg -_ae )+_g .Hypot (_dfe -_dac ,_fac -_afg ));_cdf :=int (_eca +0.5);if _cdf < 4{_cdf =4;};_eda :=float64 (_cdf )-1;_ab :=make ([]_b .Point ,_cdf );for _cdba :=0;_cdba < _cdf ;_cdba ++{_ef :=float64 (_cdba )/_eda ;_ged ,_abg :=_ee (_cdb ,_gdb ,_ceg ,_ae ,_dac ,_afg ,_dfe ,_fac ,_ef );_ab [_cdba ]=_b .NewPoint (_ged ,_abg );};return _ab ;};func (_abgd *Context )ScaleAbout (sx ,sy ,x ,y float64 ){_abgd .Translate (x ,y );_abgd .Scale (sx ,sy );_abgd .Translate (-x ,-y );};func _def (_ccgg float64 )_bg .Int26_6 {return _bg .Int26_6 (_ccgg *64)};func _cfge (_cccf _ga .Color )_bb .Pattern {return &solidPattern {_ecga :_cccf }};func (_gga *Context )SetRGB255 (r ,g ,b int ){_gga .SetRGBA255 (r ,g ,b ,255)};func (_gcfc *Context )AsMask ()*_f .Alpha {_fe :=_f .NewAlpha (_gcfc ._fbcg .Bounds ());_a .Draw (_fe ,_gcfc ._fbcg .Bounds (),_gcfc ._fbcg ,_f .Point {},_a .Src );return _fe ;};func (_cfc *Context )SetRGBA255 (r ,g ,b ,a int ){_cfc ._dfd =_ga .NRGBA {uint8 (r ),uint8 (g ),uint8 (b ),uint8 (a )};_cfc .setFillAndStrokeColor (_cfc ._dfd );};func _cdda (_adff _dae .Path ,_afc []float64 ,_eeab float64 )_dae .Path {return _deg (_efga (_bbce (_adff ),_afc ,_eeab ));};func (_daef *Context )setFillAndStrokeColor (_bgg _ga .Color ){_daef ._dfd =_bgg ;_daef ._gbf =_cfge (_bgg );_daef ._de =_cfge (_bgg );};func (_afga *Context )SetDash (dashes ...float64 ){_afga ._egd =dashes };func _cdca (_ggaac *_f .RGBA ,_faga *_f .Alpha ,_adab _bb .Pattern )*patternPainter {return &patternPainter {_ggaac ,_faga ,_adab };};func (_afe *Context )LineWidth ()float64 {return _afe ._ff };func _deg (_fffe [][]_b .Point )_dae .Path {var _bfbc _dae .Path ;for _ ,_dcaf :=range _fffe {var _fgcb _bg .Point26_6 ;for _gebg ,_cceg :=range _dcaf {_aec :=_fbag (_cceg );if _gebg ==0{_bfbc .Start (_aec );}else {_abaf :=_aec .X -_fgcb .X ;_faf :=_aec .Y -_fgcb .Y ;if _abaf < 0{_abaf =-_abaf ;};if _faf < 0{_faf =-_faf ;};if _abaf +_faf > 8{_bfbc .Add1 (_aec );};};_fgcb =_aec ;};};return _bfbc ;};func _bf (_cgc ,_fbg ,_ad ,_dag ,_ac ,_cd float64 )[]_b .Point {_cc :=(_g .Hypot (_ad -_cgc ,_dag -_fbg )+_g .Hypot (_ac -_ad ,_cd -_dag ));_eb :=int (_cc +0.5);if _eb < 4{_eb =4;};_ed :=float64 (_eb )-1;_acc :=make ([]_b .Point ,_eb );for _bdg :=0;_bdg < _eb ;_bdg ++{_gff :=float64 (_bdg )/_ed ;_bgb ,_bbd :=_c (_cgc ,_fbg ,_ad ,_dag ,_ac ,_cd ,_gff );_acc [_bdg ]=_b .NewPoint (_bgb ,_bbd );};return _acc ;};func _edb (_cfe ,_ggd _ga .Color ,_cgfe float64 )_ga .Color {_gbdf ,_fefe ,_ebg ,_efgf :=_cfe .RGBA ();_dec ,_efc ,_bfee ,_fcg :=_ggd .RGBA ();return _ga .RGBA {_edaf (_gbdf ,_dec ,_cgfe ),_edaf (_fefe ,_efc ,_cgfe ),_edaf (_ebg ,_bfee ,_cgfe ),_edaf (_efgf ,_fcg ,_cgfe )};};func (_fcda stops )Swap (i ,j int ){_fcda [i ],_fcda [j ]=_fcda [j ],_fcda [i ]};func _c (_dfb ,_gc ,_cg ,_cgf ,_ce ,_fg ,_gf float64 )(_bge ,_fb float64 ){_gb :=1-_gf ;_bbf :=_gb *_gb ;_ege :=2*_gb *_gf ;_fbc :=_gf *_gf ;_bge =_bbf *_dfb +_ege *_cg +_fbc *_ce ;_fb =_bbf *_gc +_ege *_cgf +_fbc *_fg ;return ;};func (_bbcf *Context )Clip (){_bbcf .ClipPreserve ();_bbcf .ClearPath ()};func (_geg *Context )stroke (_agd _dae .Painter ){_acf :=_geg ._aea ;if len (_geg ._egd )> 0{_acf =_cdda (_acf ,_geg ._egd ,_geg ._egc );}else {_acf =_deg (_bbce (_acf ));};_cce :=_geg ._efa ;_cce .UseNonZeroWinding =true ;_cce .Clear ();_cce .AddStroke (_acf ,_def (_geg ._ff ),_geg .capper (),_geg .joiner ());_cce .Rasterize (_agd );};func (_egb *Context )SetRGBA (r ,g ,b ,a float64 ){_egb ._dfd =_ga .NRGBA {uint8 (r *255),uint8 (g *255),uint8 (b *255),uint8 (a *255)};_egb .setFillAndStrokeColor (_egb ._dfd );};type stops []stop ;func (_ffef *Context )DrawStringAnchored (s string ,x ,y ,ax ,ay float64 ){_eaag ,_gcad :=_ffef .MeasureString (s );x -=ax *_eaag ;y +=ay *_gcad ;if _ffef ._fdf ==nil {_ffef .drawString (_ffef ._fbcg ,s ,x ,y );}else {_eac :=_f .NewRGBA (_f .Rect (0,0,_ffef ._bgc ,_ffef ._ca ));_ffef .drawString (_eac ,s ,x ,y );_a .DrawMask (_ffef ._fbcg ,_ffef ._fbcg .Bounds (),_eac ,_f .Point {},_ffef ._fdf ,_f .Point {},_a .Over );};};func (_gfc *Context )CubicTo (x1 ,y1 ,x2 ,y2 ,x3 ,y3 float64 ){if !_gfc ._gffc {_gfc .MoveTo (x1 ,y1 );};_ceba ,_ccc :=_gfc ._gac .X ,_gfc ._gac .Y ;x1 ,y1 =_gfc .Transform (x1 ,y1 );x2 ,y2 =_gfc .Transform (x2 ,y2 );x3 ,y3 =_gfc .Transform (x3 ,y3 );_cfa :=_eeb (_ceba ,_ccc ,x1 ,y1 ,x2 ,y2 ,x3 ,y3 );_gde :=_fbag (_gfc ._gac );for _ ,_ccg :=range _cfa [1:]{_dff :=_fbag (_ccg );if _dff ==_gde {continue ;};_gde =_dff ;_gfc ._aea .Add1 (_dff );_gfc ._dea .Add1 (_dff );_gfc ._gac =_ccg ;};};func (_deaa *Context )Height ()int {return _deaa ._ca };func (_bbaa *radialGradient )ColorAt (x ,y int )_ga .Color {if len (_bbaa ._adbf )==0{return _ga .Transparent ;};_ffb ,_fbf :=float64 (x )+0.5-_bbaa ._fefc ._aag ,float64 (y )+0.5-_bbaa ._fefc ._ccb ;_aga :=_adeg (_ffb ,_fbf ,_bbaa ._fefc ._gedg ,_bbaa ._agb ._aag ,_bbaa ._agb ._ccb ,_bbaa ._agb ._gedg );_fcc :=_adeg (_ffb ,_fbf ,-_bbaa ._fefc ._gedg ,_ffb ,_fbf ,_bbaa ._fefc ._gedg );if _bbaa ._cfde ==0{if _aga ==0{return _ga .Transparent ;};_cgfd :=0.5*_fcc /_aga ;if _cgfd *_bbaa ._agb ._gedg >=_bbaa ._becd {return _gbg (_cgfd ,_bbaa ._adbf );};return _ga .Transparent ;};_bfe :=_adeg (_aga ,_bbaa ._cfde ,0,_aga ,-_fcc ,0);if _bfe >=0{_daf :=_g .Sqrt (_bfe );_ggcb :=(_aga +_daf )*_bbaa ._cdc ;_fbb :=(_aga -_daf )*_bbaa ._cdc ;if _ggcb *_bbaa ._agb ._gedg >=_bbaa ._becd {return _gbg (_ggcb ,_bbaa ._adbf );}else if _fbb *_bbaa ._agb ._gedg >=_bbaa ._becd {return _gbg (_fbb ,_bbaa ._adbf );};};return _ga .Transparent ;};func (_dg *Context )NewSubPath (){if _dg ._gffc {_dg ._dea .Add1 (_fbag (_dg ._acb ));};_dg ._gffc =false ;};func (_cgff *Context )ResetClip (){_cgff ._fdf =nil };func (_bcc *surfacePattern )ColorAt (x ,y int )_ga .Color {_bdgb :=_bcc ._agc .Bounds ();switch _bcc ._bbef {case _adca :if y >=_bdgb .Dy (){return _ga .Transparent ;};case _ccf :if x >=_bdgb .Dx (){return _ga .Transparent ;};case _eafe :if x >=_bdgb .Dx ()||y >=_bdgb .Dy (){return _ga .Transparent ;};};x =x %_bdgb .Dx ()+_bdgb .Min .X ;y =y %_bdgb .Dy ()+_bdgb .Min .Y ;return _bcc ._agc .At (x ,y );};