Changeset 521 for GraphicTest/Packages/bgrabitmap/csscolorconst.inc
- Timestamp:
- Apr 17, 2019, 12:58:41 AM (5 years ago)
- Location:
- GraphicTest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest
- Property svn:ignore
-
old new 8 8 GraphicTest.lps 9 9 GraphicTest.dbg 10 heaptrclog.trc
-
- Property svn:ignore
-
GraphicTest/Packages/bgrabitmap/csscolorconst.inc
r494 r521 99 99 constructor Create; 100 100 {** Add a color to the list } 101 procedure Add(Name: string; const Color: TBGRAPixel); 101 procedure Add(Name: string; const Color: TBGRAPixel); overload; 102 102 {** Ends the color list and prevents further modifications } 103 103 procedure Finished; … … 137 137 {* Converts a fully defined string into a ''TBGRAPixel'' value. Color names from ''VGAColors'' and ''CSSColors'' 138 138 are used if there is an exact match } 139 function StrToBGRA(str: string): TBGRAPixel; 139 function StrToBGRA(str: string): TBGRAPixel; overload; 140 140 {* Converts a string into a ''TBGRAPixel'' value. If the value is not fully defined or that 141 141 there is an error, ''DefaultColor'' is returned. 142 142 Color names from ''VGAColors'' and ''CSSColors'' are used if there is an exact match. } 143 function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; 143 function StrToBGRA(str: string; const DefaultColor: TBGRAPixel): TBGRAPixel; overload; 144 144 {* Converts a string into a ''TBGRAPixel'' value. If the value is not fully defined, missing channels (expressed with '?') 145 145 are filled with fallbackValues. You can check if there was an error with the provided boolean. … … 311 311 function ParseColorValue(str: string; var flagError: boolean): byte; 312 312 var pourcent,unclipped,{%H-}errPos: integer; 313 pourcentF: single; 314 pourcentStr: string; 313 315 begin 314 316 if str = '' then result := 0 else … … 316 318 if str[length(str)]='%' then 317 319 begin 318 val(copy(str,1,length(str)-1),pourcent,errPos); 319 if errPos <> 0 then flagError := true; 320 if pourcent < 0 then result := 0 else 321 if pourcent > 100 then result := 255 else 322 result := pourcent*255 div 100; 320 pourcentStr := copy(str,1,length(str)-1); 321 val(pourcentStr,pourcent,errPos); 322 if errPos <> 0 then 323 begin 324 val(pourcentStr,pourcentF,errPos); 325 if errPos <> 0 then 326 begin 327 flagError := true; 328 result := 0; 329 end 330 else 331 begin 332 if pourcentF < 0 then result := 0 else 333 if pourcentF > 100 then result := 255 else 334 result := round(pourcentF*255 / 100); 335 end; 336 end else 337 begin 338 if pourcent < 0 then result := 0 else 339 if pourcent > 100 then result := 255 else 340 result := pourcent*255 div 100; 341 end; 323 342 end else 324 343 begin
Note:
See TracChangeset
for help on using the changeset viewer.