@@ -846,6 +846,47 @@ export class FontMetrics implements IFontMetrics {
846
846
}
847
847
848
848
export class Paint implements IPaint {
849
+ mColor : Color = new Color ( 'black' ) ;
850
+ style : Style = Style . FILL ;
851
+ align : Align = Align . LEFT ;
852
+ mFont : Font ;
853
+ strokeWidth = 0 ;
854
+ strokeMiter = 0 ;
855
+ strokeCap : Cap = Cap . BUT ;
856
+ strokeJoin : Join = Join . BEVEL ;
857
+ antiAlias ;
858
+ dither ;
859
+ alpha = 255 ;
860
+ currentContext : any ;
861
+ shadowLayer ?: {
862
+ radius : number ;
863
+ dx : number ;
864
+ dy : number ;
865
+ color : Color ;
866
+ } ;
867
+ shader ;
868
+ pathEffect : PathEffect ;
869
+ xfermode : IPorterDuffXfermode ;
870
+ mTextAttribs : NSMutableDictionary < any , any > ;
871
+ constructor ( paint ?: Paint ) {
872
+ if ( paint ) {
873
+ this . mColor = paint . mColor ;
874
+ this . style = paint . style ;
875
+ this . align = paint . align ;
876
+ this . mFont = paint . mFont ;
877
+ this . strokeWidth = paint . strokeWidth ;
878
+ this . strokeMiter = paint . strokeMiter ;
879
+ this . strokeCap = paint . strokeCap ;
880
+ this . strokeJoin = paint . strokeJoin ;
881
+ this . antiAlias = paint . antiAlias ;
882
+ this . dither = paint . dither ;
883
+ this . alpha = paint . alpha ;
884
+ this . shadowLayer = paint . shadowLayer ;
885
+ this . shader = paint . shader ;
886
+ this . pathEffect = paint . pathEffect ;
887
+ this . xfermode = paint . xfermode ;
888
+ }
889
+ }
849
890
getTextPath ( text : string , start : number , end : number , x : number , y : number , path : Path ) {
850
891
const bPath = UIBezierPath . fromStringWithFont ( text . slice ( start , end ) , this . getUIFont ( ) ) ;
851
892
const bounds = bPath . bounds ;
@@ -860,30 +901,11 @@ export class Paint implements IPaint {
860
901
861
902
public setTextAlign ( align : Align ) : void {
862
903
this . align = align ;
863
- this . _textAttribs = null ;
904
+ this . mTextAttribs = null ;
864
905
}
865
906
public getTextAlign ( ) : Align {
866
907
return this . align ;
867
908
}
868
- _color : Color = new Color ( 'black' ) ;
869
- style : Style = Style . FILL ;
870
- align : Align = Align . LEFT ;
871
- _font : Font ;
872
- strokeWidth = 0 ;
873
- strokeMiter = 0 ;
874
- strokeCap : Cap = Cap . BUT ;
875
- strokeJoin : Join = Join . BEVEL ;
876
- antiAlias = false ;
877
- dither = false ;
878
- alpha = 255 ;
879
- currentContext : any ;
880
- shadowLayer ?: {
881
- radius : number ;
882
- dx : number ;
883
- dy : number ;
884
- color : Color ;
885
- } ;
886
- shader ;
887
909
888
910
public setShadowLayer ( radius : number , dx : number , dy : number , color : number | Color | string ) : void {
889
911
color = color instanceof Color ? color : new Color ( color as any ) ;
@@ -908,7 +930,7 @@ export class Paint implements IPaint {
908
930
this . strokeMiter = value ;
909
931
}
910
932
public setARGB ( a : number , r : number , g : number , b : number ) : void {
911
- this . _color = new Color ( a , r , g , b ) ;
933
+ this . mColor = new Color ( a , r , g , b ) ;
912
934
}
913
935
public measureText ( text : string , start = 0 , end ?) {
914
936
if ( end === undefined ) {
@@ -977,36 +999,33 @@ export class Paint implements IPaint {
977
999
}
978
1000
this . shader = value ;
979
1001
}
980
- constructor ( ) {
981
- // this.font = Font.default;
982
- }
983
1002
setFont ( font : Font ) {
984
- if ( font === this . _font ) {
1003
+ if ( font === this . mFont ) {
985
1004
return ;
986
1005
}
987
- this . _font = font ;
988
- this . _textAttribs = null ;
1006
+ this . mFont = font ;
1007
+ this . mTextAttribs = null ;
989
1008
}
990
1009
public setTypeface ( font : Font | UIFont ) : Font {
991
1010
if ( this . font === font ) {
992
- return this . _font ;
1011
+ return this . mFont ;
993
1012
}
994
1013
if ( font instanceof Font ) {
995
1014
this . setFont ( font ) ;
996
- return this . _font ;
1015
+ return this . mFont ;
997
1016
} else if ( font ) {
998
- this . _font [ '_uiFont' ] = font ;
1017
+ this . mFont [ '_uiFont' ] = font ;
999
1018
} else {
1000
- this . _font = null ;
1019
+ this . mFont = null ;
1001
1020
}
1002
- this . _textAttribs = null ;
1003
- return this . _font ;
1021
+ this . mTextAttribs = null ;
1022
+ return this . mFont ;
1004
1023
}
1005
1024
getFont ( ) {
1006
- if ( ! this . _font ) {
1007
- this . _font = Font . default ;
1025
+ if ( ! this . mFont ) {
1026
+ this . mFont = Font . default ;
1008
1027
}
1009
- return this . _font ;
1028
+ return this . mFont ;
1010
1029
}
1011
1030
get font ( ) {
1012
1031
return this . getFont ( ) ;
@@ -1016,11 +1035,11 @@ export class Paint implements IPaint {
1016
1035
}
1017
1036
1018
1037
setFontFamily ( familyName : string ) {
1019
- if ( this . _font && this . _font . fontFamily === familyName ) {
1038
+ if ( this . mFont && this . mFont . fontFamily === familyName ) {
1020
1039
return ;
1021
1040
}
1022
- this . _font = this . font . withFontFamily ( familyName ) ;
1023
- this . _textAttribs = null ;
1041
+ this . mFont = this . font . withFontFamily ( familyName ) ;
1042
+ this . mTextAttribs = null ;
1024
1043
}
1025
1044
set fontFamily ( familyName : string ) {
1026
1045
this . setFontFamily ( familyName ) ;
@@ -1033,35 +1052,35 @@ export class Paint implements IPaint {
1033
1052
}
1034
1053
1035
1054
set fontWeight ( weight : FontWeight ) {
1036
- if ( this . _font && this . _font . fontWeight === weight ) {
1055
+ if ( this . mFont && this . mFont . fontWeight === weight ) {
1037
1056
return ;
1038
1057
}
1039
1058
this . setFontWeight ( weight ) ;
1040
1059
}
1041
1060
setFontWeight ( weight : FontWeight ) {
1042
- this . _font = this . font . withFontWeight ( weight ) ;
1043
- this . _textAttribs = null ;
1061
+ this . mFont = this . font . withFontWeight ( weight ) ;
1062
+ this . mTextAttribs = null ;
1044
1063
}
1045
1064
set fontStyle ( style : FontStyle ) {
1046
1065
this . setFontStyle ( style ) ;
1047
1066
}
1048
1067
setFontStyle ( style : FontStyle ) {
1049
- if ( this . _font && this . _font . fontStyle === style ) {
1068
+ if ( this . mFont && this . mFont . fontStyle === style ) {
1050
1069
return ;
1051
1070
}
1052
- this . _font = this . font . withFontStyle ( style ) ;
1053
- this . _textAttribs = null ;
1071
+ this . mFont = this . font . withFontStyle ( style ) ;
1072
+ this . mTextAttribs = null ;
1054
1073
}
1055
1074
1056
1075
getUIFont ( ) : UIFont {
1057
1076
return this . font . getUIFont ( UIFont . systemFontOfSize ( UIFont . labelFontSize ) ) ;
1058
1077
}
1059
1078
getUIColor ( ) {
1060
- return this . _color && ( this . _color . ios as UIColor ) ;
1079
+ return this . mColor && ( this . mColor . ios as UIColor ) ;
1061
1080
}
1062
1081
1063
1082
public getTextSize ( ) : number {
1064
- return this . _font ? this . _font . fontSize : UIFont . labelFontSize ;
1083
+ return this . mFont ? this . mFont . fontSize : UIFont . labelFontSize ;
1065
1084
}
1066
1085
1067
1086
set textSize ( textSize ) {
@@ -1071,40 +1090,40 @@ export class Paint implements IPaint {
1071
1090
return this . getTextSize ( ) ;
1072
1091
}
1073
1092
setTextSize ( textSize ) {
1074
- if ( this . _font && this . _font . fontSize === textSize ) {
1093
+ if ( this . mFont && this . mFont . fontSize === textSize ) {
1075
1094
return ;
1076
1095
}
1077
- this . _font = this . font . withFontSize ( textSize ) ;
1078
- this . _textAttribs = null ;
1096
+ this . mFont = this . font . withFontSize ( textSize ) ;
1097
+ this . mTextAttribs = null ;
1079
1098
}
1080
1099
get color ( ) : Color | number | string {
1081
- return this . _color ;
1100
+ return this . mColor ;
1082
1101
}
1083
1102
set color ( color : Color | number | string ) {
1084
1103
this . setColor ( color ) ;
1085
1104
}
1086
1105
setColor ( color : Color | number | string ) {
1087
1106
if ( color instanceof Color ) {
1088
- this . _color = color ;
1107
+ this . mColor = color ;
1089
1108
} else if ( ! ! color ) {
1090
- this . _color = new Color ( color as any ) ;
1109
+ this . mColor = new Color ( color as any ) ;
1091
1110
} else {
1092
- this . _color = undefined ;
1111
+ this . mColor = undefined ;
1093
1112
}
1094
- if ( this . _color ) {
1113
+ if ( this . mColor ) {
1095
1114
// on android setColor sets the alpha too
1096
- const c = this . _color ;
1115
+ const c = this . mColor ;
1097
1116
this . alpha = c . a ;
1098
1117
// we want to ignore color alpha because on android it is not used but
1099
1118
// on ios it will add up
1100
- this . _color = new Color ( 255 , c . r , c . g , c . b ) ;
1119
+ this . mColor = new Color ( 255 , c . r , c . g , c . b ) ;
1101
1120
} else {
1102
1121
this . alpha = 255 ;
1103
1122
}
1104
- this . _textAttribs = null ;
1123
+ this . mTextAttribs = null ;
1105
1124
}
1106
1125
getColor ( ) : Color {
1107
- return this . _color ;
1126
+ return this . mColor ;
1108
1127
}
1109
1128
1110
1129
clear ( ) {
@@ -1113,12 +1132,10 @@ export class Paint implements IPaint {
1113
1132
this . shader = null ;
1114
1133
}
1115
1134
}
1116
- pathEffect : PathEffect ;
1117
1135
public setPathEffect ( param0 : PathEffect ) {
1118
1136
this . pathEffect = param0 ;
1119
1137
}
1120
1138
1121
- xfermode : IPorterDuffXfermode ;
1122
1139
public setXfermode ( param0 : IPorterDuffXfermode ) : IPorterDuffXfermode {
1123
1140
this . xfermode = param0 ;
1124
1141
return param0 ;
@@ -1200,26 +1217,25 @@ export class Paint implements IPaint {
1200
1217
// CGContextAddPath(ctx, path);
1201
1218
}
1202
1219
}
1203
- _textAttribs : NSMutableDictionary < any , any > ;
1204
1220
getDrawTextAttribs ( ) {
1205
- if ( ! this . _textAttribs ) {
1206
- this . _textAttribs = NSMutableDictionary . dictionaryWithObjectsForKeys ( [ this . getUIFont ( ) ] , [ NSFontAttributeName ] ) ;
1221
+ if ( ! this . mTextAttribs ) {
1222
+ this . mTextAttribs = NSMutableDictionary . dictionaryWithObjectsForKeys ( [ this . getUIFont ( ) ] , [ NSFontAttributeName ] ) ;
1207
1223
const color = this . getUIColor ( ) ;
1208
- this . _textAttribs = NSMutableDictionary . dictionaryWithObjectsForKeys ( [ this . getUIFont ( ) ] , [ NSFontAttributeName ] ) ;
1224
+ this . mTextAttribs = NSMutableDictionary . dictionaryWithObjectsForKeys ( [ this . getUIFont ( ) ] , [ NSFontAttributeName ] ) ;
1209
1225
if ( color ) {
1210
- this . _textAttribs . setObjectForKey ( color , NSForegroundColorAttributeName ) ;
1226
+ this . mTextAttribs . setObjectForKey ( color , NSForegroundColorAttributeName ) ;
1211
1227
}
1212
1228
if ( this . align === Align . CENTER ) {
1213
1229
const paragraphStyle = NSMutableParagraphStyle . new ( ) ;
1214
1230
paragraphStyle . alignment = NSTextAlignment . Center ;
1215
- this . _textAttribs . setObjectForKey ( paragraphStyle , NSParagraphStyleAttributeName ) ;
1231
+ this . mTextAttribs . setObjectForKey ( paragraphStyle , NSParagraphStyleAttributeName ) ;
1216
1232
} else if ( this . align === Align . RIGHT ) {
1217
1233
const paragraphStyle = NSMutableParagraphStyle . new ( ) ;
1218
1234
paragraphStyle . alignment = NSTextAlignment . Right ;
1219
- this . _textAttribs . setObjectForKey ( paragraphStyle , NSParagraphStyleAttributeName ) ;
1235
+ this . mTextAttribs . setObjectForKey ( paragraphStyle , NSParagraphStyleAttributeName ) ;
1220
1236
}
1221
1237
}
1222
- return this . _textAttribs ;
1238
+ return this . mTextAttribs ;
1223
1239
}
1224
1240
}
1225
1241
0 commit comments