mirror of https://github.com/SixLabors/ImageSharp
committed by
GitHub
1030 changed files with 30249 additions and 16690 deletions
@ -1,20 +1,371 @@ |
|||||
# top-most EditorConfig file |
############################################################################### |
||||
|
# EditorConfig is awesome: http://EditorConfig.org |
||||
|
############################################################################### |
||||
|
|
||||
|
############################################################################### |
||||
|
# Top-most EditorConfig file |
||||
|
############################################################################### |
||||
root = true |
root = true |
||||
|
|
||||
[*.cs] |
############################################################################### |
||||
|
# Set default behavior to: |
||||
|
# a UTF-8 encoding, |
||||
|
# Unix-style line endings, |
||||
|
# a newline ending the file, |
||||
|
# 4 space indentation, and |
||||
|
# trimming of trailing whitespace |
||||
|
############################################################################### |
||||
|
[*] |
||||
|
charset = utf-8 |
||||
|
end_of_line = lf |
||||
|
insert_final_newline = true |
||||
indent_style = space |
indent_style = space |
||||
indent_size = 4 |
indent_size = 4 |
||||
csharp_style_var_for_built_in_types = false:warning |
trim_trailing_whitespace = true |
||||
csharp_style_var_elsewhere = false:warning |
|
||||
csharp_style_var_when_type_is_apparent = true:warning |
############################################################################### |
||||
|
# Set file behavior to: |
||||
|
# 2 space indentation |
||||
|
############################################################################### |
||||
|
[*.{cmd,config,csproj,json,props,ps1,resx,sh,targets}] |
||||
|
indent_size = 2 |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set file behavior to: |
||||
|
# Windows-style line endings, and |
||||
|
# tabular indentation |
||||
|
############################################################################### |
||||
|
[*.sln] |
||||
end_of_line = crlf |
end_of_line = crlf |
||||
|
indent_style = tab |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set dotnet naming rules to: |
||||
|
# suggest async members be pascal case suffixed with Async |
||||
|
# suggest const declarations be pascal case |
||||
|
# suggest interfaces be pascal case prefixed with I |
||||
|
# suggest parameters be camel case |
||||
|
# suggest private and internal static fields be camel case |
||||
|
# suggest private and internal fields be camel case |
||||
|
# suggest public and protected declarations be pascal case |
||||
|
# suggest static readonly declarations be pascal case |
||||
|
# suggest type parameters be prefixed with T |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_naming_rule.async_members_should_be_pascal_case_suffixed_with_async.severity = suggestion |
||||
|
dotnet_naming_rule.async_members_should_be_pascal_case_suffixed_with_async.style = pascal_case_suffixed_with_async |
||||
|
dotnet_naming_rule.async_members_should_be_pascal_case_suffixed_with_async.symbols = async_members |
||||
|
|
||||
|
dotnet_naming_rule.const_declarations_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.const_declarations_should_be_pascal_case.style = pascal_case |
||||
|
dotnet_naming_rule.const_declarations_should_be_pascal_case.symbols = const_declarations |
||||
|
|
||||
|
dotnet_naming_rule.interfaces_should_be_pascal_case_prefixed_with_i.severity = suggestion |
||||
|
dotnet_naming_rule.interfaces_should_be_pascal_case_prefixed_with_i.style = pascal_case_prefixed_with_i |
||||
|
dotnet_naming_rule.interfaces_should_be_pascal_case_prefixed_with_i.symbols = interfaces |
||||
|
|
||||
|
dotnet_naming_rule.parameters_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.parameters_should_be_camel_case.style = camel_case |
||||
|
dotnet_naming_rule.parameters_should_be_camel_case.symbols = parameters |
||||
|
|
||||
|
dotnet_naming_rule.private_and_internal_static_fields_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.private_and_internal_static_fields_should_be_camel_case.style = camel_case |
||||
|
dotnet_naming_rule.private_and_internal_static_fields_should_be_camel_case.symbols = private_and_internal_static_fields |
||||
|
|
||||
|
dotnet_naming_rule.private_and_internal_fields_should_be_camel_case.severity = suggestion |
||||
|
dotnet_naming_rule.private_and_internal_fields_should_be_camel_case.style = camel_case |
||||
|
dotnet_naming_rule.private_and_internal_fields_should_be_camel_case.symbols = private_and_internal_fields |
||||
|
|
||||
|
dotnet_naming_rule.public_and_protected_declarations_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.public_and_protected_declarations_should_be_pascal_case.style = pascal_case |
||||
|
dotnet_naming_rule.public_and_protected_declarations_should_be_pascal_case.symbols = public_and_protected_declarations |
||||
|
|
||||
|
dotnet_naming_rule.static_readonly_declarations_should_be_pascal_case.severity = suggestion |
||||
|
dotnet_naming_rule.static_readonly_declarations_should_be_pascal_case.style = pascal_case |
||||
|
dotnet_naming_rule.static_readonly_declarations_should_be_pascal_case.symbols = static_readonly_declarations |
||||
|
|
||||
|
dotnet_naming_rule.type_parameters_should_be_pascal_case_prefixed_with_t.severity = suggestion |
||||
|
dotnet_naming_rule.type_parameters_should_be_pascal_case_prefixed_with_t.style = pascal_case_prefixed_with_t |
||||
|
dotnet_naming_rule.type_parameters_should_be_pascal_case_prefixed_with_t.symbols = type_parameters |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set dotnet naming styles to define: |
||||
|
# camel case |
||||
|
# pascal case |
||||
|
# pascal case suffixed with Async |
||||
|
# pascal case prefixed with I |
||||
|
# pascal case prefixed with T |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_naming_style.camel_case.capitalization = camel_case |
||||
|
|
||||
|
dotnet_naming_style.pascal_case.capitalization = pascal_case |
||||
|
|
||||
|
dotnet_naming_style.pascal_case_suffixed_with_async.capitalization = pascal_case |
||||
|
dotnet_naming_style.pascal_case_suffixed_with_async.required_suffix = Async |
||||
|
|
||||
|
dotnet_naming_style.pascal_case_prefixed_with_i.capitalization = pascal_case |
||||
|
dotnet_naming_style.pascal_case_prefixed_with_i.required_prefix = I |
||||
|
|
||||
|
dotnet_naming_style.pascal_case_prefixed_with_t.capitalization = pascal_case |
||||
|
dotnet_naming_style.pascal_case_prefixed_with_t.required_prefix = T |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set dotnet naming symbols to: |
||||
|
# async members |
||||
|
# const declarations |
||||
|
# interfaces |
||||
|
# private and internal fields |
||||
|
# private and internal static fields |
||||
|
# public and protected declarations |
||||
|
# static readonly declarations |
||||
|
# type parameters |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_naming_symbols.async_members.required_modifiers = async |
||||
|
|
||||
|
dotnet_naming_symbols.const_declarations.required_modifiers = const |
||||
|
|
||||
|
dotnet_naming_symbols.interfaces.applicable_kinds = interface |
||||
|
|
||||
|
dotnet_naming_symbols.parameters.applicable_kinds = parameter |
||||
|
|
||||
|
dotnet_naming_symbols.private_and_internal_fields.applicable_accessibilities = private, internal |
||||
|
dotnet_naming_symbols.private_and_internal_fields.applicable_kinds = field |
||||
|
|
||||
|
dotnet_naming_symbols.private_and_internal_static_fields.applicable_accessibilities = private, internal |
||||
|
dotnet_naming_symbols.private_and_internal_static_fields.applicable_kinds = field |
||||
|
dotnet_naming_symbols.private_and_internal_static_fields.required_modifiers = static |
||||
|
|
||||
|
dotnet_naming_symbols.public_and_protected_declarations.applicable_accessibilities = public, protected |
||||
|
|
||||
|
dotnet_naming_symbols.static_readonly_declarations.required_modifiers = static, readonly |
||||
|
|
||||
|
dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set dotnet sort options to: |
||||
|
# do not separate import directives into groups, and |
||||
|
# sort system directives first |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_separate_import_directive_groups = false |
||||
dotnet_sort_system_directives_first = true |
dotnet_sort_system_directives_first = true |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set dotnet style options to: |
||||
|
# suggest null-coalescing expressions, |
||||
|
# suggest collection-initializers, |
||||
|
# suggest explicit tuple names, |
||||
|
# suggest null-propogation |
||||
|
# suggest object-initializers, |
||||
|
# generate parentheses in arithmetic binary operators for clarity, |
||||
|
# generate parentheses in other binary operators for clarity, |
||||
|
# don't generate parentheses in other operators if unnecessary, |
||||
|
# generate parentheses in relational binary operators for clarity, |
||||
|
# warn when not using predefined-types for locals, parameters, and members, |
||||
|
# generate predefined-types of type names for member access, |
||||
|
# generate auto properties, |
||||
|
# suggest compound assignment, |
||||
|
# generate conditional expression over assignment, |
||||
|
# generate conditional expression over return, |
||||
|
# suggest inferred anonymous types, |
||||
|
# suggest inferred tuple names, |
||||
|
# suggest 'is null' checks over '== null', |
||||
|
# don't generate 'this.' and 'Me.' for events, |
||||
|
# warn when not using 'this.' and 'Me.' for fields, |
||||
|
# warn when not using 'this.' and 'Me.' for methods, |
||||
|
# warn when not using 'this.' and 'Me.' for properties, |
||||
|
# suggest readonly fields, and |
||||
|
# generate accessibility modifiers for non interface members |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_style_coalesce_expression = true:suggestion |
||||
|
dotnet_style_collection_initializer = true:suggestion |
||||
|
dotnet_style_explicit_tuple_names = true:suggestion |
||||
|
dotnet_style_null_propagation = true:suggestion |
||||
|
dotnet_style_object_initializer = true:suggestion |
||||
|
|
||||
|
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent |
||||
|
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent |
||||
|
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent |
||||
|
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent |
||||
|
|
||||
dotnet_style_predefined_type_for_locals_parameters_members = true:warning |
dotnet_style_predefined_type_for_locals_parameters_members = true:warning |
||||
dotnet_style_predefined_type_for_member_access = true:warning |
dotnet_style_predefined_type_for_member_access = true:silent |
||||
|
|
||||
|
dotnet_style_prefer_auto_properties = true:silent |
||||
|
dotnet_style_prefer_compound_assignment = true:suggestion |
||||
|
dotnet_style_prefer_conditional_expression_over_assignment = true:silent |
||||
|
dotnet_style_prefer_conditional_expression_over_return = true:silent |
||||
|
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
||||
|
dotnet_style_prefer_inferred_tuple_names = true:suggestion |
||||
|
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
||||
|
|
||||
|
dotnet_style_qualification_for_event = false:silent |
||||
dotnet_style_qualification_for_field = true:warning |
dotnet_style_qualification_for_field = true:warning |
||||
dotnet_style_qualification_for_method = true:warning |
dotnet_style_qualification_for_method = true:warning |
||||
dotnet_style_qualification_for_property = true:warning |
dotnet_style_qualification_for_property = true:warning |
||||
|
|
||||
[*.tt] |
dotnet_style_readonly_field = true:suggestion |
||||
indent_style = space |
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent |
||||
indent_size = 4 |
|
||||
|
############################################################################### |
||||
|
# Set dotnet style options to: |
||||
|
# suggest removing all unused parameters |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
dotnet_code_quality_unused_parameters = all:suggestion |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set csharp indent options to: |
||||
|
# indent block contents, |
||||
|
# not indent braces, |
||||
|
# indent case contents, |
||||
|
# not indent case contents when block, |
||||
|
# indent labels one less than the current, and |
||||
|
# indent switch labels |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
csharp_indent_block_contents = true |
||||
|
csharp_indent_braces = false |
||||
|
csharp_indent_case_contents = true |
||||
|
csharp_indent_case_contents_when_block = false |
||||
|
csharp_indent_labels = one_less_than_current |
||||
|
csharp_indent_switch_labels = true |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set csharp new-line options to: |
||||
|
# insert a new-line before "catch", |
||||
|
# insert a new-line before "else", |
||||
|
# insert a new-line before "finally", |
||||
|
# insert a new-line before members in anonymous-types, |
||||
|
# insert a new-line before members in object-initializers, and |
||||
|
# insert a new-line before all open braces |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
csharp_new_line_before_catch = true |
||||
|
csharp_new_line_before_else = true |
||||
|
csharp_new_line_before_finally = true |
||||
|
|
||||
|
csharp_new_line_before_members_in_anonymous_types = true |
||||
|
csharp_new_line_before_members_in_object_initializers = true |
||||
|
|
||||
|
csharp_new_line_before_open_brace = all |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set csharp preserve options to: |
||||
|
# preserve single-line blocks, and |
||||
|
# preserve single-line statements |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
csharp_preserve_single_line_blocks = true |
||||
|
csharp_preserve_single_line_statements = true |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set csharp space options to: |
||||
|
# remove any space after a cast, |
||||
|
# add a space after the colon in an inheritance clause, |
||||
|
# add a space after a comma, |
||||
|
# remove any space after a dot, |
||||
|
# add a space after keywords in control flow statements, |
||||
|
# add a space after a semicolon in a "for" statement, |
||||
|
# add a space before and after binary operators, |
||||
|
# remove space around declaration statements, |
||||
|
# add a space before the colon in an inheritance clause, |
||||
|
# remove any space before a comma, |
||||
|
# remove any space before a dot, |
||||
|
# remove any space before an open square-bracket, |
||||
|
# remove any space before a semicolon in a "for" statement, |
||||
|
# remove any space between empty square-brackets, |
||||
|
# remove any space between a method call's empty parameter list parenthesis, |
||||
|
# remove any space between a method call's name and its opening parenthesis, |
||||
|
# remove any space between a method call's parameter list parenthesis, |
||||
|
# remove any space between a method declaration's empty parameter list parenthesis, |
||||
|
# remove any space between a method declaration's name and its openening parenthesis, |
||||
|
# remove any space between a method declaration's parameter list parenthesis, |
||||
|
# remove any space between parentheses, and |
||||
|
# remove any space between square brackets |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
csharp_space_after_cast = false |
||||
|
csharp_space_after_colon_in_inheritance_clause = true |
||||
|
csharp_space_after_comma = true |
||||
|
csharp_space_after_dot = false |
||||
|
csharp_space_after_keywords_in_control_flow_statements = true |
||||
|
csharp_space_after_semicolon_in_for_statement = true |
||||
|
|
||||
|
csharp_space_around_binary_operators = before_and_after |
||||
|
csharp_space_around_declaration_statements = do_not_ignore |
||||
|
|
||||
|
csharp_space_before_colon_in_inheritance_clause = true |
||||
|
csharp_space_before_comma = false |
||||
|
csharp_space_before_dot = false |
||||
|
csharp_space_before_open_square_brackets = false |
||||
|
csharp_space_before_semicolon_in_for_statement = false |
||||
|
|
||||
|
csharp_space_between_empty_square_brackets = false |
||||
|
csharp_space_between_method_call_empty_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_call_name_and_opening_parenthesis = false |
||||
|
csharp_space_between_method_call_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
||||
|
csharp_space_between_method_declaration_name_and_open_parenthesis = false |
||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false |
||||
|
csharp_space_between_parentheses = false |
||||
|
csharp_space_between_square_brackets = false |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set csharp style options to: |
||||
|
# generate braces, |
||||
|
# suggest simple default expressions, |
||||
|
# generate a preferred modifier order, |
||||
|
# suggest conditional delegate calls, |
||||
|
# suggest deconstructed variable declarations, |
||||
|
# generate expression-bodied accessors, |
||||
|
# don't generate expression-bodied constructors, |
||||
|
# generate expression-bodied indexers, |
||||
|
# generate expression-bodied lambdas, |
||||
|
# don't generate expression-bodied methods, |
||||
|
# don't generate expression-bodied operators, |
||||
|
# generate expression-bodied properties, |
||||
|
# suggest inlined variable declarations, |
||||
|
# suggest local over anonymous functions, |
||||
|
# suggest pattern-matching over "as" with "null" check, |
||||
|
# suggest pattern-matching over "is" with "cast" check, |
||||
|
# suggest throw expressions, |
||||
|
# generate a discard variable for unused value expression statements, |
||||
|
# suggest a discard variable for unused assignments, |
||||
|
# warn when using var for built-in types, |
||||
|
# warn when using var when the type is not apparent, and |
||||
|
# warn when not using var when the type is apparent |
||||
|
############################################################################### |
||||
|
[*.cs] |
||||
|
csharp_prefer_braces = true:silent |
||||
|
csharp_prefer_simple_default_expression = true:suggestion |
||||
|
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent |
||||
|
|
||||
|
csharp_style_conditional_delegate_call = true:suggestion |
||||
|
csharp_style_deconstructed_variable_declaration = true:suggestion |
||||
|
|
||||
|
csharp_style_expression_bodied_accessors = true:silent |
||||
|
csharp_style_expression_bodied_constructors = false:silent |
||||
|
csharp_style_expression_bodied_indexers = true:silent |
||||
|
csharp_style_expression_bodied_lambdas = true:silent |
||||
|
csharp_style_expression_bodied_methods = false:silent |
||||
|
csharp_style_expression_bodied_operators = false:silent |
||||
|
csharp_style_expression_bodied_properties = true:silent |
||||
|
|
||||
|
csharp_style_inlined_variable_declaration = true:suggestion |
||||
|
|
||||
|
csharp_style_pattern_local_over_anonymous_function = true:suggestion |
||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
||||
|
|
||||
|
csharp_style_throw_expression = true:suggestion |
||||
|
|
||||
|
csharp_style_unused_value_expression_statement_preference = discard_variable:silent |
||||
|
csharp_style_unused_value_assignment_preference = discard_variable:suggestion |
||||
|
|
||||
|
csharp_style_var_for_built_in_types = false:warning |
||||
|
csharp_style_var_elsewhere = false:warning |
||||
|
csharp_style_var_when_type_is_apparent = true:warning |
||||
|
|||||
@ -1,49 +1,108 @@ |
|||||
*.doc diff=astextplain |
############################################################################### |
||||
*.DOC diff=astextplain |
# Set default behavior to: |
||||
*.docx diff=astextplain |
# treat as text and |
||||
*.DOCX diff=astextplain |
# normalize to Unix-style line endings |
||||
*.dot diff=astextplain |
############################################################################### |
||||
*.DOT diff=astextplain |
* text eol=lf |
||||
*.pdf diff=astextplain |
|
||||
*.PDF diff=astextplain |
|
||||
*.rtf diff=astextplain |
|
||||
*.RTF diff=astextplain |
|
||||
|
|
||||
*.jpg binary |
############################################################################### |
||||
*.png binary |
# Set explicit file behavior to: |
||||
*.gif binary |
# treat as text and |
||||
|
# normalize to Unix-style line endings |
||||
|
############################################################################### |
||||
|
*.asm text eol=lf |
||||
|
*.c text eol=lf |
||||
|
*.clj text eol=lf |
||||
|
*.cmd text eol=lf |
||||
|
*.cpp text eol=lf |
||||
|
*.css text eol=lf |
||||
|
*.cxx text eol=lf |
||||
|
*.config text eol=lf |
||||
|
*.DotSettings text eol=lf |
||||
|
*.erl text eol=lf |
||||
|
*.fs text eol=lf |
||||
|
*.fsx text eol=lf |
||||
|
*.h text eol=lf |
||||
|
*.htm text eol=lf |
||||
|
*.html text eol=lf |
||||
|
*.hs text eol=lf |
||||
|
*.hxx text eol=lf |
||||
|
*.java text eol=lf |
||||
|
*.js text eol=lf |
||||
|
*.json text eol=lf |
||||
|
*.less text eol=lf |
||||
|
*.lisp text eol=lf |
||||
|
*.lua text eol=lf |
||||
|
*.m text eol=lf |
||||
|
*.md text eol=lf |
||||
|
*.php text eol=lf |
||||
|
*.props text eol=lf |
||||
|
*.ps1 text eol=lf |
||||
|
*.py text eol=lf |
||||
|
*.rb text eol=lf |
||||
|
*.resx text eol=lf |
||||
|
*.runsettings text eol=lf |
||||
|
*.ruleset text eol=lf |
||||
|
*.sass text eol=lf |
||||
|
*.scss text eol=lf |
||||
|
*.sh text eol=lf |
||||
|
*.sql text eol=lf |
||||
|
*.svg text eol=lf |
||||
|
*.targets text eol=lf |
||||
|
*.tt text eol=lf |
||||
|
*.ttinclude text eol=crlf |
||||
|
*.txt text eol=lf |
||||
|
*.vb text eol=lf |
||||
|
*.yml text eol=lf |
||||
|
|
||||
*.cs text=auto diff=csharp |
############################################################################### |
||||
*.vb text=auto |
# Set explicit file behavior to: |
||||
*.c text=auto |
# treat as text |
||||
*.cpp text=auto |
# normalize to Unix-style line endings and |
||||
*.cxx text=auto |
# diff as csharp |
||||
*.h text=auto |
############################################################################### |
||||
*.hxx text=auto |
*.cs text eol=lf diff=csharp |
||||
*.py text=auto |
|
||||
*.rb text=auto |
|
||||
*.java text=auto |
|
||||
*.html text=auto |
|
||||
*.htm text=auto |
|
||||
*.css text=auto |
|
||||
*.scss text=auto |
|
||||
*.sass text=auto |
|
||||
*.less text=auto |
|
||||
*.js text=auto |
|
||||
*.lisp text=auto |
|
||||
*.clj text=auto |
|
||||
*.sql text=auto |
|
||||
*.php text=auto |
|
||||
*.lua text=auto |
|
||||
*.m text=auto |
|
||||
*.asm text=auto |
|
||||
*.erl text=auto |
|
||||
*.fs text=auto |
|
||||
*.fsx text=auto |
|
||||
*.hs text=auto |
|
||||
|
|
||||
*.csproj text=auto merge=union |
############################################################################### |
||||
*.vbproj text=auto merge=union |
# Set explicit file behavior to: |
||||
*.fsproj text=auto merge=union |
# treat as text |
||||
*.dbproj text=auto merge=union |
# normalize to Unix-style line endings and |
||||
*.sln text=auto eol=crlf merge=union |
# use a union merge when resoling conflicts |
||||
|
############################################################################### |
||||
|
*.csproj text eol=lf merge=union |
||||
|
*.dbproj text eol=lf merge=union |
||||
|
*.fsproj text eol=lf merge=union |
||||
|
*.ncrunchproject text eol=lf merge=union |
||||
|
*.vbproj text eol=lf merge=union |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set explicit file behavior to: |
||||
|
# treat as text |
||||
|
# normalize to Windows-style line endings and |
||||
|
# use a union merge when resoling conflicts |
||||
|
############################################################################### |
||||
|
*.sln text eol=crlf merge=union |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set explicit file behavior to: |
||||
|
# treat as binary |
||||
|
############################################################################### |
||||
|
*.bmp binary |
||||
|
*.dll binary |
||||
|
*.exe binary |
||||
|
*.gif binary |
||||
|
*.jpg binary |
||||
|
*.png binary |
||||
|
*.ttf binary |
||||
|
*.snk binary |
||||
|
|
||||
|
############################################################################### |
||||
|
# Set explicit file behavior to: |
||||
|
# diff as plain text |
||||
|
############################################################################### |
||||
|
*.doc diff=astextplain |
||||
|
*.docx diff=astextplain |
||||
|
*.dot diff=astextplain |
||||
|
*.pdf diff=astextplain |
||||
|
*.pptx diff=astextplain |
||||
|
*.rtf diff=astextplain |
||||
|
|||||
@ -0,0 +1 @@ |
|||||
|
open_collective: imagesharp |
||||
@ -0,0 +1,81 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project> |
||||
|
|
||||
|
<!-- |
||||
|
Directory.Build.props is automatically picked up and imported by |
||||
|
Microsoft.Common.props. This file needs to exist, even if empty so that |
||||
|
files in the parent directory tree, with the same name, are not imported |
||||
|
instead. The import fairly early and only Sdk.props will have been imported |
||||
|
beforehand. We also don't need to add ourselves to MSBuildAllProjects, as |
||||
|
that is done by the file that imports us. |
||||
|
--> |
||||
|
|
||||
|
<!-- Default settings that are used by other settings --> |
||||
|
<PropertyGroup> |
||||
|
<BaseArtifactsPath>$(MSBuildThisFileDirectory)artifacts/</BaseArtifactsPath> |
||||
|
<BaseArtifactsPathSuffix>$(ImageSharpProjectCategory)/$(MSBuildProjectName)</BaseArtifactsPathSuffix> |
||||
|
<RepositoryUrl>https://github.com/SixLabors/ImageSharp/</RepositoryUrl> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!-- Default settings that explicitly differ from the Sdk.props defaults --> |
||||
|
<PropertyGroup> |
||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
||||
|
<BaseIntermediateOutputPath>$(BaseArtifactsPath)obj/$(BaseArtifactsPathSuffix)/</BaseIntermediateOutputPath> |
||||
|
<DebugType>portable</DebugType> |
||||
|
<DebugType Condition="'$(codecov)' != ''">full</DebugType> |
||||
|
<NullableContextOptions>disable</NullableContextOptions> |
||||
|
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> |
||||
|
<SignAssembly>false</SignAssembly> |
||||
|
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Release'"> |
||||
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!--TODO: Check what this is testing for and why does it fail?--> |
||||
|
<PropertyGroup Condition="'$(Configuration)' == 'Debug'"> |
||||
|
<CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!-- Default settings that explicitly differ from the Sdk.targets defaults--> |
||||
|
<PropertyGroup> |
||||
|
<Authors>Six Labors and contributors</Authors> |
||||
|
<BaseOutputPath>$(BaseArtifactsPath)bin/$(BaseArtifactsPathSuffix)/</BaseOutputPath> |
||||
|
<Company>Six Labors</Company> |
||||
|
<PackageOutputPath>$(BaseArtifactsPath)pkg/$(BaseArtifactsPathSuffix)/$(Configuration)/</PackageOutputPath> |
||||
|
<Product>SixLabors.ImageSharp</Product> |
||||
|
<VersionPrefix>0.0.1</VersionPrefix> |
||||
|
<VersionPrefix Condition="'$(packageversion)' != ''">$(PackageVersion)</VersionPrefix> |
||||
|
<VersionSuffix></VersionSuffix> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!-- Default settings that are otherwise undefined --> |
||||
|
<PropertyGroup> |
||||
|
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)standards/SixLabors.snk</AssemblyOriginatorKeyFile> |
||||
|
<Copyright>Copyright © Six Labors and Contributors</Copyright> |
||||
|
<Features>strict;IOperation</Features> |
||||
|
<HighEntropyVA>true</HighEntropyVA> |
||||
|
<LangVersion>7.3</LangVersion> |
||||
|
<NeutralLanguage>en</NeutralLanguage> |
||||
|
<OverwriteReadOnlyFiles>true</OverwriteReadOnlyFiles> |
||||
|
<PackageIconUrl>https://raw.githubusercontent.com/SixLabors/Branding/master/icons/imagesharp/sixlabors.imagesharp.128.png</PackageIconUrl> |
||||
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> |
||||
|
<PackageProjectUrl>$(RepositoryUrl)</PackageProjectUrl> |
||||
|
<ProduceReferenceAssembly>true</ProduceReferenceAssembly> |
||||
|
<RepositoryType>git</RepositoryType> |
||||
|
<RestoreSources> |
||||
|
https://www.myget.org/F/sixlabors/api/v3/index.json; |
||||
|
https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json; |
||||
|
https://api.nuget.org/v3/index.json; |
||||
|
</RestoreSources> |
||||
|
<SixLaborsPublicKey>002400000c8000009400000006020000002400005253413100040000010001000147e6fe6766715eec6cfed61f1e7dcdbf69748a3e355c67e9d8dfd953acab1d5e012ba34b23308166fdc61ee1d0390d5f36d814a6091dd4b5ed9eda5a26afced924c683b4bfb4b3d64b0586a57eff9f02b1f84e3cb0ddd518bd1697f2c84dcbb97eb8bb5c7801be12112ed0ec86db934b0e9a5171e6bb1384b6d2f7d54dfa97</SixLaborsPublicKey> |
||||
|
<UseSharedCompilation>true</UseSharedCompilation> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!-- Package references which are consumed by all projects --> |
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.Net.Compilers.Toolset" IsImplicitlyDefined="true" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,47 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project> |
||||
|
|
||||
|
<!-- |
||||
|
Directory.Build.targets is automatically picked up and imported by |
||||
|
Microsoft.Common.targets. This file needs to exist, even if empty so that |
||||
|
files in the parent directory tree, with the same name, are not imported |
||||
|
instead. The import fairly late and most other props/targets will have been |
||||
|
imported beforehand. We also don't need to add ourselves to |
||||
|
MSBuildAllProjects, as that is done by the file that imports us. |
||||
|
--> |
||||
|
|
||||
|
<!-- Settings that append the existing setting value --> |
||||
|
<PropertyGroup> |
||||
|
<DefineConstants>$(DefineConstants);$(OS)</DefineConstants> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<!-- Tool versions for tool references across all projects --> |
||||
|
<ItemGroup> |
||||
|
<DotNetCliToolReference Update="dotnet-xunit" Version="2.3.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<!-- Package versions for package references across all projects --> |
||||
|
<ItemGroup> |
||||
|
<PackageReference Update="BenchmarkDotNet" Version="0.11.5" /> |
||||
|
<PackageReference Update="Colourful" Version="2.0.2" /> |
||||
|
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.12.0" /> |
||||
|
<PackageReference Update="Microsoft.Net.Compilers.Toolset" Version="3.1.0" /> |
||||
|
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="15.9.0" /> |
||||
|
<PackageReference Update="Moq" Version="4.10.0" /> |
||||
|
<PackageReference Update="SixLabors.Core" Version="1.0.0-dev000101" /> |
||||
|
<PackageReference Update="SixLabors.Fonts" Version="1.0.0-beta0008" /> |
||||
|
<PackageReference Update="SixLabors.Shapes" Version="1.0.0-beta0008" /> |
||||
|
<PackageReference Update="SixLabors.Shapes.Text" Version="1.0.0-beta0007" /> |
||||
|
<PackageReference Update="StyleCop.Analyzers" Version="1.1.118" /> |
||||
|
<PackageReference Update="System.Drawing.Common" Version="4.5.1" /> |
||||
|
<PackageReference Update="System.IO.Compression" Version="4.3.0" /> |
||||
|
<PackageReference Update="System.IO.UnmanagedMemoryStream" Version="4.3.0" /> |
||||
|
<PackageReference Update="System.Runtime.CompilerServices.Unsafe" Version="4.5.1" /> |
||||
|
<PackageReference Update="System.Threading.Tasks.Parallel" Version="4.3.0" /> |
||||
|
<PackageReference Update="System.ValueTuple" Version="4.5.0" /> |
||||
|
<PackageReference Update="xunit" Version="2.3.1" /> |
||||
|
<PackageReference Update="xunit.runner.console" Version="2.3.1" /> |
||||
|
<PackageReference Update="xunit.runner.visualstudio" Version="2.3.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -1,15 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<RuleSet Name="ImageSharp" ToolsVersion="15.0"> |
|
||||
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers"> |
|
||||
<Rule Id="AD0001" Action="None" /> |
|
||||
<Rule Id="SA1413" Action="None" /> |
|
||||
<!-- <Rule Id="SA1405" Action="None" /> |
|
||||
temp remove the header requirement as stylecop is currently failing to read the stylecop.json file from 'dotnet build' |
|
||||
<Rule Id="SA1636" Action="None" />--> |
|
||||
<Rule Id="SA1633" Action="None" /> |
|
||||
<!--1.1.0-beta6 incorrectly throws a wobbler here for multiline matrices--> |
|
||||
<Rule Id="SA1500" Action="None" /> |
|
||||
<!--Comments should end with a period. I like this but there's 3000+ errors to fix--> |
|
||||
<Rule Id="SA1629" Action="None" /> |
|
||||
</Rules> |
|
||||
</RuleSet> |
|
||||
@ -1,9 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<packageSources> |
|
||||
<add key="myget.org sixlabors" value="https://www.myget.org/F/sixlabors/api/v3/index.json" /> |
|
||||
<add key="myget.org dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" /> |
|
||||
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> |
|
||||
<add key="nuget.org" value="https://www.nuget.org/api/v2/" /> |
|
||||
</packageSources> |
|
||||
</configuration> |
|
||||
@ -0,0 +1,41 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project> |
||||
|
|
||||
|
<!-- |
||||
|
Directory.Build.props is automatically picked up and imported by |
||||
|
Microsoft.Common.props. This file needs to exist, even if empty so that |
||||
|
files in the parent directory tree, with the same name, are not imported |
||||
|
instead. The import fairly early and only Sdk.props will have been |
||||
|
imported beforehand. We also don't need to add ourselves to |
||||
|
MSBuildAllProjects, as that is done by the file that imports us. |
||||
|
--> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.props</MSBuildAllProjects> |
||||
|
<ImageSharpProjectCategory>src</ImageSharpProjectCategory> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\standards\SixLabors.ruleset</CodeAnalysisRuleSet> |
||||
|
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\standards\stylecop.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" /> |
||||
|
<InternalsVisibleTo Include="DynamicProxyGenAssembly2, PublicKeyToken=null" /> |
||||
|
<InternalsVisibleTo Include="ImageSharp.Benchmarks" /> |
||||
|
<InternalsVisibleTo Include="SixLabors.ImageSharp.Sandbox46" /> |
||||
|
<InternalsVisibleTo Include="SixLabors.ImageSharp.Tests" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="StyleCop.Analyzers" PrivateAssets="All" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,55 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project> |
||||
|
|
||||
|
<!-- |
||||
|
Directory.Build.targets is automatically picked up and imported by |
||||
|
Microsoft.Common.targets. This file needs to exist, even if empty so that |
||||
|
files in the parent directory tree, with the same name, are not imported |
||||
|
instead. The import fairly late and most other props/targets will have |
||||
|
been imported beforehand. We also don't need to add ourselves to |
||||
|
MSBuildAllProjects, as that is done by the file that imports us. |
||||
|
--> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileDirectory)..\Directory.Build.targets</MSBuildAllProjects> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Import Project="$(MSBuildThisFileDirectory)..\Directory.Build.targets" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemDefinitionGroup> |
||||
|
<InternalsVisibleTo> |
||||
|
<Visible>false</Visible> |
||||
|
</InternalsVisibleTo> |
||||
|
</ItemDefinitionGroup> |
||||
|
|
||||
|
<Target Name="GenerateInternalsVisibleTo" |
||||
|
BeforeTargets="CoreCompile" |
||||
|
DependsOnTargets="PrepareForBuild;CoreGenerateInternalsVisibleTo" |
||||
|
Condition="'@(InternalsVisibleTo)' != ''" /> |
||||
|
|
||||
|
<Target Name="CoreGenerateInternalsVisibleTo" |
||||
|
Condition="'$(Language)' == 'VB' or '$(Language)' == 'C#'" |
||||
|
Inputs="$(MSBuildAllProjects)" |
||||
|
Outputs="$(GeneratedInternalsVisibleToFile)"> |
||||
|
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity)" Condition="'%(InternalsVisibleTo.PublicKey)' == ''"> |
||||
|
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" /> |
||||
|
</CreateItem> |
||||
|
<CreateItem Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute" AdditionalMetadata="_Parameter1=%(InternalsVisibleTo.Identity), PublicKey=%(InternalsVisibleTo.PublicKey)" Condition="'%(InternalsVisibleTo.PublicKey)' != ''"> |
||||
|
<Output TaskParameter="Include" ItemName="InternalsVisibleToAttribute" /> |
||||
|
</CreateItem> |
||||
|
|
||||
|
<WriteCodeFragment AssemblyAttributes="@(InternalsVisibleToAttribute)" Language="$(Language)" OutputFile="$(GeneratedInternalsVisibleToFile)"> |
||||
|
<Output TaskParameter="OutputFile" ItemName="Compile" /> |
||||
|
<Output TaskParameter="OutputFile" ItemName="FileWrites" /> |
||||
|
</WriteCodeFragment> |
||||
|
</Target> |
||||
|
|
||||
|
<!-- Empty target so that `dotnet test` will work on the solution --> |
||||
|
<!-- https://github.com/Microsoft/vstest/issues/411 --> |
||||
|
<Target Name="VSTest" /> |
||||
|
|
||||
|
</Project> |
||||
@ -1,50 +1,23 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<PropertyGroup> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
<AssemblyTitle>SixLabors.ImageSharp.Drawing</AssemblyTitle> |
|
||||
<Authors>SixLabors and contributors</Authors> |
|
||||
<Company>Six Labors</Company> |
|
||||
<Copyright>Copyright (c) Six Labors and contributors.</Copyright> |
|
||||
<Product>SixLabors.ImageSharp</Product> |
|
||||
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> |
|
||||
<NeutralLanguage>en</NeutralLanguage> |
|
||||
|
|
||||
<VersionPrefix Condition="$(packageversion) != ''">$(packageversion)</VersionPrefix> |
<PropertyGroup> |
||||
<VersionPrefix Condition="$(packageversion) == ''">0.0.1</VersionPrefix> |
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName> |
||||
<TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks> |
<AssemblyTitle>SixLabors.ImageSharp.Drawing</AssemblyTitle> |
||||
<LangVersion>7.3</LangVersion> |
<Description>An extension to ImageSharp that allows the drawing of images, paths, and text.</Description> |
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
<PackageId>SixLabors.ImageSharp.Drawing</PackageId> |
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile> |
<PackageTags>Image Draw Shape Path Font</PackageTags> |
||||
<AssemblyName>SixLabors.ImageSharp.Drawing</AssemblyName> |
<RootNamespace>SixLabors.ImageSharp</RootNamespace> |
||||
<PackageId>SixLabors.ImageSharp.Drawing</PackageId> |
<TargetFrameworks>netcoreapp2.1;netstandard1.3;netstandard2.0</TargetFrameworks> |
||||
<PackageTags>Image Draw Shape Path Font</PackageTags> |
</PropertyGroup> |
||||
<PackageIconUrl>https://raw.githubusercontent.com/SixLabors/Branding/master/icons/imagesharp/sixlabors.imagesharp.128.png</PackageIconUrl> |
|
||||
<PackageProjectUrl>https://github.com/SixLabors/ImageSharp</PackageProjectUrl> |
<ItemGroup> |
||||
<PackageLicenseUrl>http://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl> |
<PackageReference Include="SixLabors.Fonts" /> |
||||
<RepositoryType>git</RepositoryType> |
<PackageReference Include="SixLabors.Shapes" /> |
||||
<RepositoryUrl>https://github.com/SixLabors/ImageSharp</RepositoryUrl> |
</ItemGroup> |
||||
<DebugType Condition="$(codecov) != ''">full</DebugType> |
|
||||
<DebugType Condition="$(codecov) == ''">portable</DebugType> |
<ItemGroup> |
||||
<DebugSymbols>True</DebugSymbols> |
<ProjectReference Include="..\ImageSharp\ImageSharp.csproj" /> |
||||
</PropertyGroup> |
</ItemGroup> |
||||
<ItemGroup> |
|
||||
<Compile Include="..\Shared\*.cs" Exclude="bin\**;obj\**;**\*.xproj;packages\**" /> |
</Project> |
||||
</ItemGroup> |
|
||||
<ItemGroup> |
|
||||
<ProjectReference Include="..\ImageSharp\ImageSharp.csproj" /> |
|
||||
</ItemGroup> |
|
||||
<ItemGroup> |
|
||||
<AdditionalFiles Include="..\..\stylecop.json" /> |
|
||||
<PackageReference Include="SixLabors.Fonts" Version="1.0.0-dev000119" /> |
|
||||
<PackageReference Include="SixLabors.Shapes" Version="1.0.0-dev000102" /> |
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta007"> |
|
||||
<PrivateAssets>All</PrivateAssets> |
|
||||
</PackageReference> |
|
||||
</ItemGroup> |
|
||||
<PropertyGroup> |
|
||||
<CodeAnalysisRuleSet>..\..\ImageSharp.ruleset</CodeAnalysisRuleSet> |
|
||||
<RootNamespace>SixLabors.ImageSharp</RootNamespace> |
|
||||
</PropertyGroup> |
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> |
|
||||
</PropertyGroup> |
|
||||
</Project> |
|
||||
|
|||||
@ -0,0 +1,2 @@ |
|||||
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> |
||||
|
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=processing_005Cextensions/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
||||
@ -1,137 +0,0 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
|
|
||||
using SixLabors.ImageSharp.PixelFormats; |
|
||||
using SixLabors.ImageSharp.Processing.Processors.Drawing; |
|
||||
using SixLabors.Primitives; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Adds extensions that allow the drawing of images to the <see cref="Image{TPixel}"/> type.
|
|
||||
/// </summary>
|
|
||||
public static class DrawImageExtensions |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="colorBlending">The blending mode.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="colorBlending">The color blending mode.</param>
|
|
||||
/// <param name="alphaComposition">The alpha composition mode.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, colorBlending, alphaComposition, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="options">The options, including the blending type and blending amount.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, GraphicsOptions options) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
|
||||
/// <param name="colorBlending">The color blending to apply.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
|
||||
/// <param name="colorBlending">The color blending to apply.</param>
|
|
||||
/// <param name="alphaComposition">The alpha composition mode.</param>
|
|
||||
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, colorBlending, alphaComposition, opacity)); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Draws the given image together with the current one by blending their pixels.
|
|
||||
/// </summary>
|
|
||||
/// <typeparam name="TPixelDst">The pixel format of the destination image.</typeparam>
|
|
||||
/// <typeparam name="TPixelSrc">The pixel format of the source image.</typeparam>
|
|
||||
/// <param name="source">The image this method extends.</param>
|
|
||||
/// <param name="image">The image to blend with the currently processing image.</param>
|
|
||||
/// <param name="location">The location to draw the blended image.</param>
|
|
||||
/// <param name="options">The options containing the blend mode and opacity.</param>
|
|
||||
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
|
||||
public static IImageProcessingContext<TPixelDst> DrawImage<TPixelDst, TPixelSrc>(this IImageProcessingContext<TPixelDst> source, Image<TPixelSrc> image, Point location, GraphicsOptions options) |
|
||||
where TPixelDst : struct, IPixel<TPixelDst> |
|
||||
where TPixelSrc : struct, IPixel<TPixelSrc> |
|
||||
=> source.ApplyProcessor(new DrawImageProcessor<TPixelDst, TPixelSrc>(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage)); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,22 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing |
||||
|
{ |
||||
|
internal static class DrawingHelpers |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Convert a <see cref="DenseMatrix{Color}"/> to a <see cref="DenseMatrix{T}"/> of the given pixel type.
|
||||
|
/// </summary>
|
||||
|
public static DenseMatrix<TPixel> ToPixelMatrix<TPixel>(this DenseMatrix<Color> colorMatrix, Configuration configuration) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
DenseMatrix<TPixel> result = new DenseMatrix<TPixel>(colorMatrix.Columns, colorMatrix.Rows); |
||||
|
Color.ToPixel(configuration, colorMatrix.Span, result.Span); |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,175 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Processing.Processors.Drawing; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Adds extensions that allow the drawing of images to the <see cref="Image{TPixel}"/> type.
|
||||
|
/// </summary>
|
||||
|
public static class DrawImageExtensions |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
Point.Empty, |
||||
|
GraphicsOptions.Default.ColorBlendingMode, |
||||
|
GraphicsOptions.Default.AlphaCompositionMode, |
||||
|
opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="colorBlending">The blending mode.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
PixelColorBlendingMode colorBlending, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
Point.Empty, |
||||
|
colorBlending, |
||||
|
GraphicsOptions.Default.AlphaCompositionMode, |
||||
|
opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="colorBlending">The color blending mode.</param>
|
||||
|
/// <param name="alphaComposition">The alpha composition mode.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
PixelColorBlendingMode colorBlending, |
||||
|
PixelAlphaCompositionMode alphaComposition, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="options">The options, including the blending type and blending amount.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
GraphicsOptions options) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
Point.Empty, |
||||
|
options.ColorBlendingMode, |
||||
|
options.AlphaCompositionMode, |
||||
|
options.BlendPercentage)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
Point location, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
location, |
||||
|
GraphicsOptions.Default.ColorBlendingMode, |
||||
|
GraphicsOptions.Default.AlphaCompositionMode, |
||||
|
opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
|
/// <param name="colorBlending">The color blending to apply.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
Point location, |
||||
|
PixelColorBlendingMode colorBlending, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
location, |
||||
|
colorBlending, |
||||
|
GraphicsOptions.Default.AlphaCompositionMode, |
||||
|
opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
|
/// <param name="colorBlending">The color blending to apply.</param>
|
||||
|
/// <param name="alphaComposition">The alpha composition mode.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
Point location, |
||||
|
PixelColorBlendingMode colorBlending, |
||||
|
PixelAlphaCompositionMode alphaComposition, |
||||
|
float opacity) => |
||||
|
source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity)); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Draws the given image together with the current one by blending their pixels.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The image this method extends.</param>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
|
/// <param name="options">The options containing the blend mode and opacity.</param>
|
||||
|
/// <returns>The <see cref="Image{TPixelDst}"/>.</returns>
|
||||
|
public static IImageProcessingContext DrawImage( |
||||
|
this IImageProcessingContext source, |
||||
|
Image image, |
||||
|
Point location, |
||||
|
GraphicsOptions options) => |
||||
|
source.ApplyProcessor( |
||||
|
new DrawImageProcessor( |
||||
|
image, |
||||
|
location, |
||||
|
options.ColorBlendingMode, |
||||
|
options.AlphaCompositionMode, |
||||
|
options.BlendPercentage)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,111 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
using SixLabors.ImageSharp.Advanced; |
||||
|
using SixLabors.ImageSharp.ParallelUtils; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Combines two images together by blending the pixels.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixelBg">The pixel format of destination image.</typeparam>
|
||||
|
/// <typeparam name="TPixelFg">The pixel format of source image.</typeparam>
|
||||
|
internal class DrawImageProcessor<TPixelBg, TPixelFg> : ImageProcessor<TPixelBg> |
||||
|
where TPixelBg : struct, IPixel<TPixelBg> |
||||
|
where TPixelFg : struct, IPixel<TPixelFg> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="DrawImageProcessor{TPixelDst, TPixelSrc}"/> class.
|
||||
|
/// </summary>
|
||||
|
/// <param name="image">The image to blend with the currently processing image.</param>
|
||||
|
/// <param name="location">The location to draw the blended image.</param>
|
||||
|
/// <param name="colorBlendingMode">The blending mode to use when drawing the image.</param>
|
||||
|
/// <param name="alphaCompositionMode">The Alpha blending mode to use when drawing the image.</param>
|
||||
|
/// <param name="opacity">The opacity of the image to blend. Must be between 0 and 1.</param>
|
||||
|
public DrawImageProcessor( |
||||
|
Image<TPixelFg> image, |
||||
|
Point location, |
||||
|
PixelColorBlendingMode colorBlendingMode, |
||||
|
PixelAlphaCompositionMode alphaCompositionMode, |
||||
|
float opacity) |
||||
|
{ |
||||
|
Guard.MustBeBetweenOrEqualTo(opacity, 0, 1, nameof(opacity)); |
||||
|
|
||||
|
this.Image = image; |
||||
|
this.Opacity = opacity; |
||||
|
this.Blender = PixelOperations<TPixelBg>.Instance.GetPixelBlender(colorBlendingMode, alphaCompositionMode); |
||||
|
this.Location = location; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the image to blend
|
||||
|
/// </summary>
|
||||
|
public Image<TPixelFg> Image { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the opacity of the image to blend
|
||||
|
/// </summary>
|
||||
|
public float Opacity { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the pixel blender
|
||||
|
/// </summary>
|
||||
|
public PixelBlender<TPixelBg> Blender { get; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the location to draw the blended image
|
||||
|
/// </summary>
|
||||
|
public Point Location { get; } |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
protected override void OnFrameApply( |
||||
|
ImageFrame<TPixelBg> source, |
||||
|
Rectangle sourceRectangle, |
||||
|
Configuration configuration) |
||||
|
{ |
||||
|
Image<TPixelFg> targetImage = this.Image; |
||||
|
PixelBlender<TPixelBg> blender = this.Blender; |
||||
|
int locationY = this.Location.Y; |
||||
|
|
||||
|
// Align start/end positions.
|
||||
|
Rectangle bounds = targetImage.Bounds(); |
||||
|
|
||||
|
int minX = Math.Max(this.Location.X, sourceRectangle.X); |
||||
|
int maxX = Math.Min(this.Location.X + bounds.Width, sourceRectangle.Right); |
||||
|
int targetX = minX - this.Location.X; |
||||
|
|
||||
|
int minY = Math.Max(this.Location.Y, sourceRectangle.Y); |
||||
|
int maxY = Math.Min(this.Location.Y + bounds.Height, sourceRectangle.Bottom); |
||||
|
|
||||
|
int width = maxX - minX; |
||||
|
|
||||
|
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY); |
||||
|
|
||||
|
// not a valid operation because rectangle does not overlap with this image.
|
||||
|
if (workingRect.Width <= 0 || workingRect.Height <= 0) |
||||
|
{ |
||||
|
throw new ImageProcessingException( |
||||
|
"Cannot draw image because the source image does not overlap the target image."); |
||||
|
} |
||||
|
|
||||
|
ParallelHelper.IterateRows( |
||||
|
workingRect, |
||||
|
configuration, |
||||
|
rows => |
||||
|
{ |
||||
|
for (int y = rows.Min; y < rows.Max; y++) |
||||
|
{ |
||||
|
Span<TPixelBg> background = source.GetPixelRowSpan(y).Slice(minX, width); |
||||
|
Span<TPixelFg> foreground = |
||||
|
targetImage.GetPixelRowSpan(y - locationY).Slice(targetX, width); |
||||
|
blender.Blend<TPixelFg>(configuration, background, background, foreground, this.Opacity); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,124 +1,45 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using System; |
|
||||
using System.Buffers; |
|
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
using SixLabors.ImageSharp.Advanced; |
|
||||
using SixLabors.ImageSharp.Memory; |
|
||||
using SixLabors.ImageSharp.ParallelUtils; |
|
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.PixelFormats; |
||||
using SixLabors.Memory; |
using SixLabors.Memory; |
||||
using SixLabors.Primitives; |
|
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Using the brush as a source of pixels colors blends the brush color with source.
|
/// Defines a processor to fill an <see cref="Image"/> with the given <see cref="IBrush"/>
|
||||
|
/// using blending defined by the given <see cref="GraphicsOptions"/>.
|
||||
/// </summary>
|
/// </summary>
|
||||
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
public class FillProcessor : IImageProcessor |
||||
internal class FillProcessor<TPixel> : ImageProcessor<TPixel> |
|
||||
where TPixel : struct, IPixel<TPixel> |
|
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// The brush.
|
/// Initializes a new instance of the <see cref="FillProcessor"/> class.
|
||||
/// </summary>
|
/// </summary>
|
||||
private readonly IBrush<TPixel> brush; |
/// <param name="brush">The brush to use for filling.</param>
|
||||
private readonly GraphicsOptions options; |
/// <param name="options">The <see cref="GraphicsOptions"/> defining how to blend the brush pixels over the image pixels.</param>
|
||||
|
public FillProcessor(IBrush brush, GraphicsOptions options) |
||||
/// <summary>
|
|
||||
/// Initializes a new instance of the <see cref="FillProcessor{TPixel}"/> class.
|
|
||||
/// </summary>
|
|
||||
/// <param name="brush">The brush to source pixel colors from.</param>
|
|
||||
/// <param name="options">The options</param>
|
|
||||
public FillProcessor(IBrush<TPixel> brush, GraphicsOptions options) |
|
||||
{ |
{ |
||||
this.brush = brush; |
this.Brush = brush; |
||||
this.options = options; |
this.Options = options; |
||||
} |
} |
||||
|
|
||||
/// <inheritdoc/>
|
/// <summary>
|
||||
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration) |
/// Gets the <see cref="IBrush"/> used for filling the destination image.
|
||||
{ |
/// </summary>
|
||||
int startX = sourceRectangle.X; |
public IBrush Brush { get; } |
||||
int endX = sourceRectangle.Right; |
|
||||
int startY = sourceRectangle.Y; |
|
||||
int endY = sourceRectangle.Bottom; |
|
||||
|
|
||||
// Align start/end positions.
|
|
||||
int minX = Math.Max(0, startX); |
|
||||
int maxX = Math.Min(source.Width, endX); |
|
||||
int minY = Math.Max(0, startY); |
|
||||
int maxY = Math.Min(source.Height, endY); |
|
||||
|
|
||||
int width = maxX - minX; |
|
||||
|
|
||||
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY); |
|
||||
|
|
||||
// If there's no reason for blending, then avoid it.
|
|
||||
if (this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush)) |
|
||||
{ |
|
||||
ParallelExecutionSettings parallelSettings = configuration.GetParallelSettings().MultiplyMinimumPixelsPerTask(4); |
|
||||
|
|
||||
ParallelHelper.IterateRows( |
|
||||
workingRect, |
|
||||
parallelSettings, |
|
||||
rows => |
|
||||
{ |
|
||||
for (int y = rows.Min; y < rows.Max; y++) |
|
||||
{ |
|
||||
source.GetPixelRowSpan(y).Slice(minX, width).Fill(solidBrush.Color); |
|
||||
} |
|
||||
}); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
// Reset offset if necessary.
|
|
||||
if (minX > 0) |
|
||||
{ |
|
||||
startX = 0; |
|
||||
} |
|
||||
|
|
||||
if (minY > 0) |
|
||||
{ |
|
||||
startY = 0; |
|
||||
} |
|
||||
|
|
||||
using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width)) |
|
||||
using (BrushApplicator<TPixel> applicator = this.brush.CreateApplicator( |
|
||||
source, |
|
||||
sourceRectangle, |
|
||||
this.options)) |
|
||||
{ |
|
||||
amount.GetSpan().Fill(1f); |
|
||||
|
|
||||
ParallelHelper.IterateRows( |
|
||||
workingRect, |
|
||||
configuration, |
|
||||
rows => |
|
||||
{ |
|
||||
for (int y = rows.Min; y < rows.Max; y++) |
|
||||
{ |
|
||||
int offsetY = y - startY; |
|
||||
int offsetX = minX - startX; |
|
||||
|
|
||||
applicator.Apply(amount.GetSpan(), offsetX, offsetY); |
/// <summary>
|
||||
} |
/// Gets the <see cref="GraphicsOptions"/> defining how to blend the brush pixels over the image pixels.
|
||||
}); |
/// </summary>
|
||||
} |
public GraphicsOptions Options { get; } |
||||
} |
|
||||
} |
|
||||
|
|
||||
private bool IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush) |
/// <inheritdoc />
|
||||
|
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>() |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
{ |
{ |
||||
solidBrush = this.brush as SolidBrush<TPixel>; |
return new FillProcessor<TPixel>(this); |
||||
|
|
||||
if (solidBrush == null) |
|
||||
{ |
|
||||
return false; |
|
||||
} |
|
||||
|
|
||||
return this.options.IsOpaqueColorWithoutBlending(solidBrush.Color); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,118 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
|
||||
|
using SixLabors.ImageSharp.Advanced; |
||||
|
using SixLabors.ImageSharp.Memory; |
||||
|
using SixLabors.ImageSharp.ParallelUtils; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Using the brush as a source of pixels colors blends the brush color with source.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
||||
|
internal class FillProcessor<TPixel> : ImageProcessor<TPixel> |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
private readonly FillProcessor definition; |
||||
|
|
||||
|
public FillProcessor(FillProcessor definition) |
||||
|
{ |
||||
|
this.definition = definition; |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration) |
||||
|
{ |
||||
|
int startX = sourceRectangle.X; |
||||
|
int endX = sourceRectangle.Right; |
||||
|
int startY = sourceRectangle.Y; |
||||
|
int endY = sourceRectangle.Bottom; |
||||
|
|
||||
|
// Align start/end positions.
|
||||
|
int minX = Math.Max(0, startX); |
||||
|
int maxX = Math.Min(source.Width, endX); |
||||
|
int minY = Math.Max(0, startY); |
||||
|
int maxY = Math.Min(source.Height, endY); |
||||
|
|
||||
|
int width = maxX - minX; |
||||
|
|
||||
|
var workingRect = Rectangle.FromLTRB(minX, minY, maxX, maxY); |
||||
|
|
||||
|
IBrush brush = this.definition.Brush; |
||||
|
GraphicsOptions options = this.definition.Options; |
||||
|
|
||||
|
// If there's no reason for blending, then avoid it.
|
||||
|
if (this.IsSolidBrushWithoutBlending(out SolidBrush solidBrush)) |
||||
|
{ |
||||
|
ParallelExecutionSettings parallelSettings = configuration.GetParallelSettings().MultiplyMinimumPixelsPerTask(4); |
||||
|
|
||||
|
TPixel colorPixel = solidBrush.Color.ToPixel<TPixel>(); |
||||
|
|
||||
|
ParallelHelper.IterateRows( |
||||
|
workingRect, |
||||
|
parallelSettings, |
||||
|
rows => |
||||
|
{ |
||||
|
for (int y = rows.Min; y < rows.Max; y++) |
||||
|
{ |
||||
|
source.GetPixelRowSpan(y).Slice(minX, width).Fill(colorPixel); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// Reset offset if necessary.
|
||||
|
if (minX > 0) |
||||
|
{ |
||||
|
startX = 0; |
||||
|
} |
||||
|
|
||||
|
if (minY > 0) |
||||
|
{ |
||||
|
startY = 0; |
||||
|
} |
||||
|
|
||||
|
using (IMemoryOwner<float> amount = source.MemoryAllocator.Allocate<float>(width)) |
||||
|
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator( |
||||
|
source, |
||||
|
sourceRectangle, |
||||
|
options)) |
||||
|
{ |
||||
|
amount.GetSpan().Fill(1f); |
||||
|
|
||||
|
ParallelHelper.IterateRows( |
||||
|
workingRect, |
||||
|
configuration, |
||||
|
rows => |
||||
|
{ |
||||
|
for (int y = rows.Min; y < rows.Max; y++) |
||||
|
{ |
||||
|
int offsetY = y - startY; |
||||
|
int offsetX = minX - startX; |
||||
|
|
||||
|
applicator.Apply(amount.GetSpan(), offsetX, offsetY); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush) |
||||
|
{ |
||||
|
solidBrush = this.definition.Brush as SolidBrush; |
||||
|
|
||||
|
if (solidBrush == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return this.definition.Options.IsOpaqueColorWithoutBlending(solidBrush.Color); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,195 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
|
||||
|
using SixLabors.ImageSharp.Advanced; |
||||
|
using SixLabors.ImageSharp.Memory; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Primitives; |
||||
|
using SixLabors.ImageSharp.Utils; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Using a brush and a shape fills shape with contents of brush the
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The type of the color.</typeparam>
|
||||
|
/// <seealso cref="ImageProcessor{TPixel}" />
|
||||
|
internal class FillRegionProcessor<TPixel> : ImageProcessor<TPixel> |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
private readonly FillRegionProcessor definition; |
||||
|
|
||||
|
public FillRegionProcessor(FillRegionProcessor definition) |
||||
|
{ |
||||
|
this.definition = definition; |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration) |
||||
|
{ |
||||
|
GraphicsOptions options = this.definition.Options; |
||||
|
IBrush brush = this.definition.Brush; |
||||
|
Region region = this.definition.Region; |
||||
|
Rectangle rect = region.Bounds; |
||||
|
|
||||
|
// Align start/end positions.
|
||||
|
int minX = Math.Max(0, rect.Left); |
||||
|
int maxX = Math.Min(source.Width, rect.Right); |
||||
|
int minY = Math.Max(0, rect.Top); |
||||
|
int maxY = Math.Min(source.Height, rect.Bottom); |
||||
|
if (minX >= maxX) |
||||
|
{ |
||||
|
return; // no effect inside image;
|
||||
|
} |
||||
|
|
||||
|
if (minY >= maxY) |
||||
|
{ |
||||
|
return; // no effect inside image;
|
||||
|
} |
||||
|
|
||||
|
int maxIntersections = region.MaxIntersections; |
||||
|
float subpixelCount = 4; |
||||
|
|
||||
|
// we need to offset the pixel grid to account for when we outline a path.
|
||||
|
// basically if the line is [1,2] => [3,2] then when outlining at 1 we end up with a region of [0.5,1.5],[1.5, 1.5],[3.5,2.5],[2.5,2.5]
|
||||
|
// and this can cause missed fills when not using antialiasing.so we offset the pixel grid by 0.5 in the x & y direction thus causing the#
|
||||
|
// region to align with the pixel grid.
|
||||
|
float offset = 0.5f; |
||||
|
if (options.Antialias) |
||||
|
{ |
||||
|
offset = 0f; // we are antialiasing skip offsetting as real antialiasing should take care of offset.
|
||||
|
subpixelCount = options.AntialiasSubpixelDepth; |
||||
|
if (subpixelCount < 4) |
||||
|
{ |
||||
|
subpixelCount = 4; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
using (BrushApplicator<TPixel> applicator = brush.CreateApplicator(source, rect, options)) |
||||
|
{ |
||||
|
int scanlineWidth = maxX - minX; |
||||
|
using (IMemoryOwner<float> bBuffer = source.MemoryAllocator.Allocate<float>(maxIntersections)) |
||||
|
using (IMemoryOwner<float> bScanline = source.MemoryAllocator.Allocate<float>(scanlineWidth)) |
||||
|
{ |
||||
|
bool scanlineDirty = true; |
||||
|
float subpixelFraction = 1f / subpixelCount; |
||||
|
float subpixelFractionPoint = subpixelFraction / subpixelCount; |
||||
|
|
||||
|
Span<float> buffer = bBuffer.GetSpan(); |
||||
|
Span<float> scanline = bScanline.GetSpan(); |
||||
|
|
||||
|
bool isSolidBrushWithoutBlending = this.IsSolidBrushWithoutBlending(out SolidBrush solidBrush); |
||||
|
TPixel solidBrushColor = isSolidBrushWithoutBlending ? solidBrush.Color.ToPixel<TPixel>() : default; |
||||
|
|
||||
|
for (int y = minY; y < maxY; y++) |
||||
|
{ |
||||
|
if (scanlineDirty) |
||||
|
{ |
||||
|
scanline.Clear(); |
||||
|
scanlineDirty = false; |
||||
|
} |
||||
|
|
||||
|
float yPlusOne = y + 1; |
||||
|
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) |
||||
|
{ |
||||
|
int pointsFound = region.Scan(subPixel + offset, buffer, configuration); |
||||
|
if (pointsFound == 0) |
||||
|
{ |
||||
|
// nothing on this line, skip
|
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
QuickSort.Sort(buffer.Slice(0, pointsFound)); |
||||
|
|
||||
|
for (int point = 0; point < pointsFound; point += 2) |
||||
|
{ |
||||
|
// points will be paired up
|
||||
|
float scanStart = buffer[point] - minX; |
||||
|
float scanEnd = buffer[point + 1] - minX; |
||||
|
int startX = (int)MathF.Floor(scanStart + offset); |
||||
|
int endX = (int)MathF.Floor(scanEnd + offset); |
||||
|
|
||||
|
if (startX >= 0 && startX < scanline.Length) |
||||
|
{ |
||||
|
for (float x = scanStart; x < startX + 1; x += subpixelFraction) |
||||
|
{ |
||||
|
scanline[startX] += subpixelFractionPoint; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (endX >= 0 && endX < scanline.Length) |
||||
|
{ |
||||
|
for (float x = endX; x < scanEnd; x += subpixelFraction) |
||||
|
{ |
||||
|
scanline[endX] += subpixelFractionPoint; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
int nextX = startX + 1; |
||||
|
endX = Math.Min(endX, scanline.Length); // reduce to end to the right edge
|
||||
|
nextX = Math.Max(nextX, 0); |
||||
|
for (int x = nextX; x < endX; x++) |
||||
|
{ |
||||
|
scanline[x] += subpixelFraction; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (scanlineDirty) |
||||
|
{ |
||||
|
if (!options.Antialias) |
||||
|
{ |
||||
|
bool hasOnes = false; |
||||
|
bool hasZeros = false; |
||||
|
for (int x = 0; x < scanlineWidth; x++) |
||||
|
{ |
||||
|
if (scanline[x] >= 0.5) |
||||
|
{ |
||||
|
scanline[x] = 1; |
||||
|
hasOnes = true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
scanline[x] = 0; |
||||
|
hasZeros = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (isSolidBrushWithoutBlending && hasOnes != hasZeros) |
||||
|
{ |
||||
|
if (hasOnes) |
||||
|
{ |
||||
|
source.GetPixelRowSpan(y).Slice(minX, scanlineWidth).Fill(solidBrushColor); |
||||
|
} |
||||
|
|
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
applicator.Apply(scanline, minX, y); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool IsSolidBrushWithoutBlending(out SolidBrush solidBrush) |
||||
|
{ |
||||
|
solidBrush = this.definition.Brush as SolidBrush; |
||||
|
|
||||
|
if (solidBrush == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
return this.definition.Options.IsOpaqueColorWithoutBlending(solidBrush.Color); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,446 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Buffers; |
||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
using SixLabors.Fonts; |
||||
|
using SixLabors.ImageSharp.Advanced; |
||||
|
using SixLabors.ImageSharp.Memory; |
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Utils; |
||||
|
using SixLabors.Memory; |
||||
|
using SixLabors.Primitives; |
||||
|
using SixLabors.Shapes; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Processing.Processors.Text |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Using the brush as a source of pixels colors blends the brush color with source.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The pixel format.</typeparam>
|
||||
|
internal class DrawTextProcessor<TPixel> : ImageProcessor<TPixel> |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
private CachingGlyphRenderer textRenderer; |
||||
|
|
||||
|
private readonly DrawTextProcessor definition; |
||||
|
|
||||
|
public DrawTextProcessor(DrawTextProcessor definition) |
||||
|
{ |
||||
|
this.definition = definition; |
||||
|
} |
||||
|
|
||||
|
private TextGraphicsOptions Options => this.definition.Options; |
||||
|
|
||||
|
private Font Font => this.definition.Font; |
||||
|
|
||||
|
private PointF Location => this.definition.Location; |
||||
|
|
||||
|
private string Text => this.definition.Text; |
||||
|
|
||||
|
private IPen Pen => this.definition.Pen; |
||||
|
|
||||
|
private IBrush Brush => this.definition.Brush; |
||||
|
|
||||
|
protected override void BeforeImageApply(Image<TPixel> source, Rectangle sourceRectangle) |
||||
|
{ |
||||
|
base.BeforeImageApply(source, sourceRectangle); |
||||
|
|
||||
|
// do everything at the image level as we are delegating the processing down to other processors
|
||||
|
var style = new RendererOptions(this.Font, this.Options.DpiX, this.Options.DpiY, this.Location) |
||||
|
{ |
||||
|
ApplyKerning = this.Options.ApplyKerning, |
||||
|
TabWidth = this.Options.TabWidth, |
||||
|
WrappingWidth = this.Options.WrapTextWidth, |
||||
|
HorizontalAlignment = this.Options.HorizontalAlignment, |
||||
|
VerticalAlignment = this.Options.VerticalAlignment |
||||
|
}; |
||||
|
|
||||
|
this.textRenderer = new CachingGlyphRenderer(source.GetMemoryAllocator(), this.Text.Length, this.Pen, this.Brush != null); |
||||
|
this.textRenderer.Options = (GraphicsOptions)this.Options; |
||||
|
var renderer = new TextRenderer(this.textRenderer); |
||||
|
renderer.RenderText(this.Text, style); |
||||
|
} |
||||
|
|
||||
|
protected override void AfterImageApply(Image<TPixel> source, Rectangle sourceRectangle) |
||||
|
{ |
||||
|
base.AfterImageApply(source, sourceRectangle); |
||||
|
this.textRenderer?.Dispose(); |
||||
|
this.textRenderer = null; |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc/>
|
||||
|
protected override void OnFrameApply(ImageFrame<TPixel> source, Rectangle sourceRectangle, Configuration configuration) |
||||
|
{ |
||||
|
// this is a no-op as we have processes all as an image, we should be able to pass out of before email apply a skip frames outcome
|
||||
|
Draw(this.textRenderer.FillOperations, this.Brush); |
||||
|
Draw(this.textRenderer.OutlineOperations, this.Pen?.StrokeFill); |
||||
|
|
||||
|
void Draw(List<DrawingOperation> operations, IBrush brush) |
||||
|
{ |
||||
|
if (operations?.Count > 0) |
||||
|
{ |
||||
|
using (BrushApplicator<TPixel> app = brush.CreateApplicator(source, sourceRectangle, this.textRenderer.Options)) |
||||
|
{ |
||||
|
foreach (DrawingOperation operation in operations) |
||||
|
{ |
||||
|
Buffer2D<float> buffer = operation.Map; |
||||
|
int startY = operation.Location.Y; |
||||
|
int startX = operation.Location.X; |
||||
|
int offSetSpan = 0; |
||||
|
if (startX < 0) |
||||
|
{ |
||||
|
offSetSpan = -startX; |
||||
|
startX = 0; |
||||
|
} |
||||
|
|
||||
|
int fistRow = 0; |
||||
|
if (startY < 0) |
||||
|
{ |
||||
|
fistRow = -startY; |
||||
|
} |
||||
|
|
||||
|
int maxHeight = source.Height - startY; |
||||
|
int end = Math.Min(operation.Map.Height, maxHeight); |
||||
|
|
||||
|
for (int row = fistRow; row < end; row++) |
||||
|
{ |
||||
|
int y = startY + row; |
||||
|
Span<float> span = buffer.GetRowSpan(row).Slice(offSetSpan); |
||||
|
app.Apply(span, startX, y); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private struct DrawingOperation |
||||
|
{ |
||||
|
public Buffer2D<float> Map { get; set; } |
||||
|
|
||||
|
public Point Location { get; set; } |
||||
|
} |
||||
|
|
||||
|
private class CachingGlyphRenderer : IGlyphRenderer, IDisposable |
||||
|
{ |
||||
|
// just enough accuracy to allow for 1/8 pixel differences which
|
||||
|
// later are accumulated while rendering, but do not grow into full pixel offsets
|
||||
|
// The value 8 is benchmarked to:
|
||||
|
// - Provide a good accuracy (smaller than 0.2% image difference compared to the non-caching variant)
|
||||
|
// - Cache hit ratio above 60%
|
||||
|
private const float AccuracyMultiple = 8; |
||||
|
|
||||
|
private readonly PathBuilder builder; |
||||
|
|
||||
|
private Point currentRenderPosition = default; |
||||
|
private (GlyphRendererParameters glyph, PointF subPixelOffset) currentGlyphRenderParams = default; |
||||
|
private readonly int offset = 0; |
||||
|
private PointF currentPoint = default(PointF); |
||||
|
|
||||
|
private readonly Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData> |
||||
|
glyphData = new Dictionary<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData>(); |
||||
|
|
||||
|
private readonly bool renderOutline = false; |
||||
|
private readonly bool renderFill = false; |
||||
|
private bool rasterizationRequired = false; |
||||
|
|
||||
|
public CachingGlyphRenderer(MemoryAllocator memoryAllocator, int size, IPen pen, bool renderFill) |
||||
|
{ |
||||
|
this.MemoryAllocator = memoryAllocator; |
||||
|
this.Pen = pen; |
||||
|
this.renderFill = renderFill; |
||||
|
this.renderOutline = pen != null; |
||||
|
this.offset = 2; |
||||
|
if (this.renderFill) |
||||
|
{ |
||||
|
this.FillOperations = new List<DrawingOperation>(size); |
||||
|
} |
||||
|
|
||||
|
if (this.renderOutline) |
||||
|
{ |
||||
|
this.offset = (int)MathF.Ceiling((pen.StrokeWidth * 2) + 2); |
||||
|
this.OutlineOperations = new List<DrawingOperation>(size); |
||||
|
} |
||||
|
|
||||
|
this.builder = new PathBuilder(); |
||||
|
} |
||||
|
|
||||
|
public List<DrawingOperation> FillOperations { get; } |
||||
|
|
||||
|
public List<DrawingOperation> OutlineOperations { get; } |
||||
|
|
||||
|
public MemoryAllocator MemoryAllocator { get; internal set; } |
||||
|
|
||||
|
public IPen Pen { get; internal set; } |
||||
|
|
||||
|
public GraphicsOptions Options { get; internal set; } |
||||
|
|
||||
|
public void BeginFigure() |
||||
|
{ |
||||
|
this.builder.StartFigure(); |
||||
|
} |
||||
|
|
||||
|
public bool BeginGlyph(RectangleF bounds, GlyphRendererParameters parameters) |
||||
|
{ |
||||
|
this.currentRenderPosition = Point.Truncate(bounds.Location); |
||||
|
PointF subPixelOffset = bounds.Location - this.currentRenderPosition; |
||||
|
|
||||
|
subPixelOffset.X = MathF.Round(subPixelOffset.X * AccuracyMultiple) / AccuracyMultiple; |
||||
|
subPixelOffset.Y = MathF.Round(subPixelOffset.Y * AccuracyMultiple) / AccuracyMultiple; |
||||
|
|
||||
|
// we have offset our rendering origion a little bit down to prevent edge cropping, move the draw origin up to compensate
|
||||
|
this.currentRenderPosition = new Point(this.currentRenderPosition.X - this.offset, this.currentRenderPosition.Y - this.offset); |
||||
|
this.currentGlyphRenderParams = (parameters, subPixelOffset); |
||||
|
|
||||
|
if (this.glyphData.ContainsKey(this.currentGlyphRenderParams)) |
||||
|
{ |
||||
|
// we have already drawn the glyph vectors skip trying again
|
||||
|
this.rasterizationRequired = false; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
// we check to see if we have a render cache and if we do then we render else
|
||||
|
this.builder.Clear(); |
||||
|
|
||||
|
// ensure all glyphs render around [zero, zero] so offset negative root positions so when we draw the glyph we can offet it back
|
||||
|
this.builder.SetOrigin(new PointF(-(int)bounds.X + this.offset, -(int)bounds.Y + this.offset)); |
||||
|
|
||||
|
this.rasterizationRequired = true; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
public void BeginText(RectangleF bounds) |
||||
|
{ |
||||
|
// not concerned about this one
|
||||
|
this.OutlineOperations?.Clear(); |
||||
|
this.FillOperations?.Clear(); |
||||
|
} |
||||
|
|
||||
|
public void CubicBezierTo(PointF secondControlPoint, PointF thirdControlPoint, PointF point) |
||||
|
{ |
||||
|
this.builder.AddBezier(this.currentPoint, secondControlPoint, thirdControlPoint, point); |
||||
|
this.currentPoint = point; |
||||
|
} |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
foreach (KeyValuePair<(GlyphRendererParameters glyph, PointF subPixelOffset), GlyphRenderData> kv in this.glyphData) |
||||
|
{ |
||||
|
kv.Value.Dispose(); |
||||
|
} |
||||
|
|
||||
|
this.glyphData.Clear(); |
||||
|
} |
||||
|
|
||||
|
public void EndFigure() |
||||
|
{ |
||||
|
this.builder.CloseFigure(); |
||||
|
} |
||||
|
|
||||
|
public void EndGlyph() |
||||
|
{ |
||||
|
GlyphRenderData renderData = default; |
||||
|
|
||||
|
// has the glyoh been rendedered already????
|
||||
|
if (this.rasterizationRequired) |
||||
|
{ |
||||
|
IPath path = this.builder.Build(); |
||||
|
|
||||
|
if (this.renderFill) |
||||
|
{ |
||||
|
renderData.FillMap = this.Render(path); |
||||
|
} |
||||
|
|
||||
|
if (this.renderOutline) |
||||
|
{ |
||||
|
if (this.Pen.StrokePattern.Length == 0) |
||||
|
{ |
||||
|
path = path.GenerateOutline(this.Pen.StrokeWidth); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
path = path.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern); |
||||
|
} |
||||
|
|
||||
|
renderData.OutlineMap = this.Render(path); |
||||
|
} |
||||
|
|
||||
|
this.glyphData[this.currentGlyphRenderParams] = renderData; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
renderData = this.glyphData[this.currentGlyphRenderParams]; |
||||
|
} |
||||
|
|
||||
|
if (this.renderFill) |
||||
|
{ |
||||
|
this.FillOperations.Add(new DrawingOperation |
||||
|
{ |
||||
|
Location = this.currentRenderPosition, |
||||
|
Map = renderData.FillMap |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
if (this.renderOutline) |
||||
|
{ |
||||
|
this.OutlineOperations.Add(new DrawingOperation |
||||
|
{ |
||||
|
Location = this.currentRenderPosition, |
||||
|
Map = renderData.OutlineMap |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private Buffer2D<float> Render(IPath path) |
||||
|
{ |
||||
|
Size size = Rectangle.Ceiling(path.Bounds).Size; |
||||
|
size = new Size(size.Width + (this.offset * 2), size.Height + (this.offset * 2)); |
||||
|
|
||||
|
float subpixelCount = 4; |
||||
|
float offset = 0.5f; |
||||
|
if (this.Options.Antialias) |
||||
|
{ |
||||
|
offset = 0f; // we are antialising skip offsetting as real antalising should take care of offset.
|
||||
|
subpixelCount = this.Options.AntialiasSubpixelDepth; |
||||
|
if (subpixelCount < 4) |
||||
|
{ |
||||
|
subpixelCount = 4; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// take the path inside the path builder, scan thing and generate a Buffer2d representing the glyph and cache it.
|
||||
|
Buffer2D<float> fullBuffer = this.MemoryAllocator.Allocate2D<float>(size.Width + 1, size.Height + 1, AllocationOptions.Clean); |
||||
|
|
||||
|
using (IMemoryOwner<float> bufferBacking = this.MemoryAllocator.Allocate<float>(path.MaxIntersections)) |
||||
|
using (IMemoryOwner<PointF> rowIntersectionBuffer = this.MemoryAllocator.Allocate<PointF>(size.Width)) |
||||
|
{ |
||||
|
float subpixelFraction = 1f / subpixelCount; |
||||
|
float subpixelFractionPoint = subpixelFraction / subpixelCount; |
||||
|
|
||||
|
for (int y = 0; y <= size.Height; y++) |
||||
|
{ |
||||
|
Span<float> scanline = fullBuffer.GetRowSpan(y); |
||||
|
bool scanlineDirty = false; |
||||
|
float yPlusOne = y + 1; |
||||
|
|
||||
|
for (float subPixel = (float)y; subPixel < yPlusOne; subPixel += subpixelFraction) |
||||
|
{ |
||||
|
var start = new PointF(path.Bounds.Left - 1, subPixel); |
||||
|
var end = new PointF(path.Bounds.Right + 1, subPixel); |
||||
|
Span<PointF> intersectionSpan = rowIntersectionBuffer.GetSpan(); |
||||
|
Span<float> buffer = bufferBacking.GetSpan(); |
||||
|
int pointsFound = path.FindIntersections(start, end, intersectionSpan); |
||||
|
|
||||
|
if (pointsFound == 0) |
||||
|
{ |
||||
|
// nothing on this line skip
|
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
for (int i = 0; i < pointsFound && i < intersectionSpan.Length; i++) |
||||
|
{ |
||||
|
buffer[i] = intersectionSpan[i].X; |
||||
|
} |
||||
|
|
||||
|
QuickSort.Sort(buffer.Slice(0, pointsFound)); |
||||
|
|
||||
|
for (int point = 0; point < pointsFound; point += 2) |
||||
|
{ |
||||
|
// points will be paired up
|
||||
|
float scanStart = buffer[point]; |
||||
|
float scanEnd = buffer[point + 1]; |
||||
|
int startX = (int)MathF.Floor(scanStart + offset); |
||||
|
int endX = (int)MathF.Floor(scanEnd + offset); |
||||
|
|
||||
|
if (startX >= 0 && startX < scanline.Length) |
||||
|
{ |
||||
|
for (float x = scanStart; x < startX + 1; x += subpixelFraction) |
||||
|
{ |
||||
|
scanline[startX] += subpixelFractionPoint; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (endX >= 0 && endX < scanline.Length) |
||||
|
{ |
||||
|
for (float x = endX; x < scanEnd; x += subpixelFraction) |
||||
|
{ |
||||
|
scanline[endX] += subpixelFractionPoint; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
int nextX = startX + 1; |
||||
|
endX = Math.Min(endX, scanline.Length); // reduce to end to the right edge
|
||||
|
nextX = Math.Max(nextX, 0); |
||||
|
for (int x = nextX; x < endX; x++) |
||||
|
{ |
||||
|
scanline[x] += subpixelFraction; |
||||
|
scanlineDirty = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (scanlineDirty) |
||||
|
{ |
||||
|
if (!this.Options.Antialias) |
||||
|
{ |
||||
|
for (int x = 0; x < size.Width; x++) |
||||
|
{ |
||||
|
if (scanline[x] >= 0.5) |
||||
|
{ |
||||
|
scanline[x] = 1; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
scanline[x] = 0; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return fullBuffer; |
||||
|
} |
||||
|
|
||||
|
public void EndText() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public void LineTo(PointF point) |
||||
|
{ |
||||
|
this.builder.AddLine(this.currentPoint, point); |
||||
|
this.currentPoint = point; |
||||
|
} |
||||
|
|
||||
|
public void MoveTo(PointF point) |
||||
|
{ |
||||
|
this.builder.StartFigure(); |
||||
|
this.currentPoint = point; |
||||
|
} |
||||
|
|
||||
|
public void QuadraticBezierTo(PointF secondControlPoint, PointF point) |
||||
|
{ |
||||
|
this.builder.AddBezier(this.currentPoint, secondControlPoint, point); |
||||
|
this.currentPoint = point; |
||||
|
} |
||||
|
|
||||
|
private struct GlyphRenderData : IDisposable |
||||
|
{ |
||||
|
public Buffer2D<float> FillMap; |
||||
|
|
||||
|
public Buffer2D<float> OutlineMap; |
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
this.FillMap?.Dispose(); |
||||
|
this.OutlineMap?.Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,169 +1,163 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
// Copyright (c) Six Labors and contributors.
|
||||
// Licensed under the Apache License, Version 2.0.
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
using SixLabors.Fonts; |
using SixLabors.Fonts; |
||||
using SixLabors.ImageSharp.PixelFormats; |
using SixLabors.ImageSharp.PixelFormats; |
||||
|
|
||||
namespace SixLabors.ImageSharp.Processing |
namespace SixLabors.ImageSharp.Processing |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// Options for influencing the drawing functions.
|
/// Options for influencing the drawing functions.
|
||||
/// </summary>
|
/// </summary>
|
||||
public struct TextGraphicsOptions |
public struct TextGraphicsOptions |
||||
{ |
{ |
||||
private const int DefaultTextDpi = 72; |
private const int DefaultTextDpi = 72; |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// Represents the default <see cref="TextGraphicsOptions"/>.
|
/// Represents the default <see cref="TextGraphicsOptions"/>.
|
||||
/// </summary>
|
/// </summary>
|
||||
public static readonly TextGraphicsOptions Default = new TextGraphicsOptions(true); |
public static readonly TextGraphicsOptions Default = new TextGraphicsOptions(true); |
||||
|
|
||||
private float? blendPercentage; |
private float? blendPercentage; |
||||
|
|
||||
private int? antialiasSubpixelDepth; |
private int? antialiasSubpixelDepth; |
||||
|
|
||||
private bool? antialias; |
private bool? antialias; |
||||
|
|
||||
private bool? applyKerning; |
private bool? applyKerning; |
||||
|
|
||||
private float? tabWidth; |
private float? tabWidth; |
||||
|
|
||||
private float? dpiX; |
private float? dpiX; |
||||
|
|
||||
private float? dpiY; |
private float? dpiY; |
||||
|
|
||||
private PixelColorBlendingMode colorBlendingMode; |
private HorizontalAlignment? horizontalAlignment; |
||||
|
|
||||
private PixelAlphaCompositionMode alphaCompositionMode; |
private VerticalAlignment? verticalAlignment; |
||||
|
|
||||
private float wrapTextWidth; |
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="TextGraphicsOptions" /> struct.
|
||||
private HorizontalAlignment? horizontalAlignment; |
/// </summary>
|
||||
|
/// <param name="enableAntialiasing">If set to <c>true</c> [enable antialiasing].</param>
|
||||
private VerticalAlignment? verticalAlignment; |
public TextGraphicsOptions(bool enableAntialiasing) |
||||
|
{ |
||||
/// <summary>
|
this.applyKerning = true; |
||||
/// Initializes a new instance of the <see cref="TextGraphicsOptions" /> struct.
|
this.tabWidth = 4; |
||||
/// </summary>
|
this.WrapTextWidth = 0; |
||||
/// <param name="enableAntialiasing">If set to <c>true</c> [enable antialiasing].</param>
|
this.horizontalAlignment = HorizontalAlignment.Left; |
||||
public TextGraphicsOptions(bool enableAntialiasing) |
this.verticalAlignment = VerticalAlignment.Top; |
||||
{ |
|
||||
this.applyKerning = true; |
this.antialiasSubpixelDepth = 16; |
||||
this.tabWidth = 4; |
this.ColorBlendingMode = PixelColorBlendingMode.Normal; |
||||
this.wrapTextWidth = 0; |
this.AlphaCompositionMode = PixelAlphaCompositionMode.SrcOver; |
||||
this.horizontalAlignment = HorizontalAlignment.Left; |
this.blendPercentage = 1; |
||||
this.verticalAlignment = VerticalAlignment.Top; |
this.antialias = enableAntialiasing; |
||||
|
this.dpiX = DefaultTextDpi; |
||||
this.antialiasSubpixelDepth = 16; |
this.dpiY = DefaultTextDpi; |
||||
this.colorBlendingMode = PixelColorBlendingMode.Normal; |
} |
||||
this.alphaCompositionMode = PixelAlphaCompositionMode.SrcOver; |
|
||||
this.blendPercentage = 1; |
/// <summary>
|
||||
this.antialias = enableAntialiasing; |
/// Gets or sets a value indicating whether antialiasing should be applied.
|
||||
this.dpiX = DefaultTextDpi; |
/// </summary>
|
||||
this.dpiY = DefaultTextDpi; |
public bool Antialias { get => this.antialias ?? true; set => this.antialias = value; } |
||||
} |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the number of subpixels to use while rendering with antialiasing enabled.
|
||||
/// Gets or sets a value indicating whether antialiasing should be applied.
|
/// </summary>
|
||||
/// </summary>
|
public int AntialiasSubpixelDepth { get => this.antialiasSubpixelDepth ?? 16; set => this.antialiasSubpixelDepth = value; } |
||||
public bool Antialias { get => this.antialias ?? true; set => this.antialias = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the blending percentage to apply to the drawing operation
|
||||
/// Gets or sets a value indicating the number of subpixels to use while rendering with antialiasing enabled.
|
/// </summary>
|
||||
/// </summary>
|
public float BlendPercentage { get => (this.blendPercentage ?? 1).Clamp(0, 1); set => this.blendPercentage = value; } |
||||
public int AntialiasSubpixelDepth { get => this.antialiasSubpixelDepth ?? 16; set => this.antialiasSubpixelDepth = value; } |
|
||||
|
// In the future we could expose a PixelBlender<TPixel> directly on here
|
||||
/// <summary>
|
// or some forms of PixelBlender factory for each pixel type. Will need
|
||||
/// Gets or sets a value indicating the blending percentage to apply to the drawing operation
|
// some API thought post V1.
|
||||
/// </summary>
|
|
||||
public float BlendPercentage { get => (this.blendPercentage ?? 1).Clamp(0, 1); set => this.blendPercentage = value; } |
/// <summary>
|
||||
|
/// Gets or sets a value indicating the color blending percentage to apply to the drawing operation
|
||||
// In the future we could expose a PixelBlender<TPixel> directly on here
|
/// </summary>
|
||||
// or some forms of PixelBlender factory for each pixel type. Will need
|
public PixelColorBlendingMode ColorBlendingMode { get; set; } |
||||
// some API thought post V1.
|
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the color blending percentage to apply to the drawing operation
|
||||
/// Gets or sets a value indicating the color blending percentage to apply to the drawing operation
|
/// </summary>
|
||||
/// </summary>
|
public PixelAlphaCompositionMode AlphaCompositionMode { get; set; } |
||||
public PixelColorBlendingMode ColorBlendingMode { get => this.colorBlendingMode; set => this.colorBlendingMode = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating whether the text should be drawing with kerning enabled.
|
||||
/// Gets or sets a value indicating the color blending percentage to apply to the drawing operation
|
/// </summary>
|
||||
/// </summary>
|
public bool ApplyKerning { get => this.applyKerning ?? true; set => this.applyKerning = value; } |
||||
public PixelAlphaCompositionMode AlphaCompositionMode { get => this.alphaCompositionMode; set => this.alphaCompositionMode = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the number of space widths a tab should lock to.
|
||||
/// Gets or sets a value indicating whether the text should be drawing with kerning enabled.
|
/// </summary>
|
||||
/// </summary>
|
public float TabWidth { get => this.tabWidth ?? 4; set => this.tabWidth = value; } |
||||
public bool ApplyKerning { get => this.applyKerning ?? true; set => this.applyKerning = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating if greater than zero determine the width at which text should wrap.
|
||||
/// Gets or sets a value indicating the number of space widths a tab should lock to.
|
/// </summary>
|
||||
/// </summary>
|
public float WrapTextWidth { get; set; } |
||||
public float TabWidth { get => this.tabWidth ?? 4; set => this.tabWidth = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the DPI to render text along the X axis.
|
||||
/// Gets or sets a value indicating if greater than zero determine the width at which text should wrap.
|
/// </summary>
|
||||
/// </summary>
|
public float DpiX { get => this.dpiX ?? DefaultTextDpi; set => this.dpiX = value; } |
||||
public float WrapTextWidth { get => this.wrapTextWidth; set => this.wrapTextWidth = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating the DPI to render text along the Y axis.
|
||||
/// Gets or sets a value indicating the DPI to render text along the X axis.
|
/// </summary>
|
||||
/// </summary>
|
public float DpiY { get => this.dpiY ?? DefaultTextDpi; set => this.dpiY = value; } |
||||
public float DpiX { get => this.dpiX ?? DefaultTextDpi; set => this.dpiX = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Gets or sets a value indicating how to align the text relative to the rendering space.
|
||||
/// Gets or sets a value indicating the DPI to render text along the Y axis.
|
/// If <see cref="WrapTextWidth"/> is greater than zero it will align relative to the space
|
||||
/// </summary>
|
/// defined by the location and width, if <see cref="WrapTextWidth"/> equals zero, and thus
|
||||
public float DpiY { get => this.dpiY ?? DefaultTextDpi; set => this.dpiY = value; } |
/// wrapping disabled, then the alignment is relative to the drawing location.
|
||||
|
/// </summary>
|
||||
/// <summary>
|
public HorizontalAlignment HorizontalAlignment { get => this.horizontalAlignment ?? HorizontalAlignment.Left; set => this.horizontalAlignment = value; } |
||||
/// Gets or sets a value indicating how to align the text relative to the rendering space.
|
|
||||
/// If <see cref="WrapTextWidth"/> is greater than zero it will align relative to the space
|
/// <summary>
|
||||
/// defined by the location and width, if <see cref="WrapTextWidth"/> equals zero, and thus
|
/// Gets or sets a value indicating how to align the text relative to the rendering space.
|
||||
/// wrapping disabled, then the alignment is relative to the drawing location.
|
/// </summary>
|
||||
/// </summary>
|
public VerticalAlignment VerticalAlignment { get => this.verticalAlignment ?? VerticalAlignment.Top; set => this.verticalAlignment = value; } |
||||
public HorizontalAlignment HorizontalAlignment { get => this.horizontalAlignment ?? HorizontalAlignment.Left; set => this.horizontalAlignment = value; } |
|
||||
|
/// <summary>
|
||||
/// <summary>
|
/// Performs an implicit conversion from <see cref="GraphicsOptions"/> to <see cref="TextGraphicsOptions"/>.
|
||||
/// Gets or sets a value indicating how to align the text relative to the rendering space.
|
/// </summary>
|
||||
/// </summary>
|
/// <param name="options">The options.</param>
|
||||
public VerticalAlignment VerticalAlignment { get => this.verticalAlignment ?? VerticalAlignment.Top; set => this.verticalAlignment = value; } |
/// <returns>
|
||||
|
/// The result of the conversion.
|
||||
/// <summary>
|
/// </returns>
|
||||
/// Performs an implicit conversion from <see cref="GraphicsOptions"/> to <see cref="TextGraphicsOptions"/>.
|
public static implicit operator TextGraphicsOptions(GraphicsOptions options) |
||||
/// </summary>
|
{ |
||||
/// <param name="options">The options.</param>
|
return new TextGraphicsOptions(options.Antialias) |
||||
/// <returns>
|
{ |
||||
/// The result of the conversion.
|
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, |
||||
/// </returns>
|
blendPercentage = options.BlendPercentage, |
||||
public static implicit operator TextGraphicsOptions(GraphicsOptions options) |
ColorBlendingMode = options.ColorBlendingMode, |
||||
{ |
AlphaCompositionMode = options.AlphaCompositionMode |
||||
return new TextGraphicsOptions(options.Antialias) |
}; |
||||
{ |
} |
||||
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, |
|
||||
blendPercentage = options.BlendPercentage, |
/// <summary>
|
||||
colorBlendingMode = options.ColorBlendingMode, |
/// Performs an explicit conversion from <see cref="TextGraphicsOptions"/> to <see cref="GraphicsOptions"/>.
|
||||
alphaCompositionMode = options.AlphaCompositionMode |
/// </summary>
|
||||
}; |
/// <param name="options">The options.</param>
|
||||
} |
/// <returns>
|
||||
|
/// The result of the conversion.
|
||||
/// <summary>
|
/// </returns>
|
||||
/// Performs an explicit conversion from <see cref="TextGraphicsOptions"/> to <see cref="GraphicsOptions"/>.
|
public static explicit operator GraphicsOptions(TextGraphicsOptions options) |
||||
/// </summary>
|
{ |
||||
/// <param name="options">The options.</param>
|
return new GraphicsOptions(options.Antialias) |
||||
/// <returns>
|
{ |
||||
/// The result of the conversion.
|
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, |
||||
/// </returns>
|
|
||||
public static explicit operator GraphicsOptions(TextGraphicsOptions options) |
|
||||
{ |
|
||||
return new GraphicsOptions(options.Antialias) |
|
||||
{ |
|
||||
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth, |
|
||||
ColorBlendingMode = options.ColorBlendingMode, |
ColorBlendingMode = options.ColorBlendingMode, |
||||
AlphaCompositionMode = options.AlphaCompositionMode, |
AlphaCompositionMode = options.AlphaCompositionMode, |
||||
BlendPercentage = options.BlendPercentage |
BlendPercentage = options.BlendPercentage |
||||
}; |
}; |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,4 +0,0 @@ |
|||||
// Copyright (c) Six Labors and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
|
|
||||
// Common values read from `AssemblyInfo.Common.cs`
|
|
||||
@ -0,0 +1,98 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <content>
|
||||
|
/// Contains constructors and implicit conversion methods.
|
||||
|
/// </content>
|
||||
|
public readonly partial struct Color |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Rgba64"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Rgba64 pixel) => this.data = pixel; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Rgba32"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Rgba32 pixel) => this.data = new Rgba64(pixel); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Argb32"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Argb32 pixel) => this.data = new Rgba64(pixel); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Bgra32"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Bgra32 pixel) => this.data = new Rgba64(pixel); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Rgb24"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Rgb24 pixel) => this.data = new Rgba64(pixel); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="pixel">The <see cref="Bgr24"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Bgr24 pixel) => this.data = new Rgba64(pixel); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of the <see cref="Color"/> struct.
|
||||
|
/// </summary>
|
||||
|
/// <param name="vector">The <see cref="Vector4"/> containing the color information.</param>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public Color(Vector4 vector) => this.data = new Rgba64(vector); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Converts a <see cref="Color"/> to <see cref="Vector4"/>.
|
||||
|
/// </summary>
|
||||
|
/// <param name="color">The <see cref="Color"/>.</param>
|
||||
|
/// <returns>The <see cref="Vector4"/>.</returns>
|
||||
|
public static explicit operator Vector4(Color color) => color.data.ToVector4(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Converts an <see cref="Vector4"/> to <see cref="Color"/>.
|
||||
|
/// </summary>
|
||||
|
/// <param name="source">The <see cref="Vector4"/>.</param>
|
||||
|
/// <returns>The <see cref="Color"/>.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static explicit operator Color(Vector4 source) => new Color(source); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Rgba32 ToRgba32() => this.data.ToRgba32(); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Bgra32 ToBgra32() => this.data.ToBgra32(); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Argb32 ToArgb32() => this.data.ToArgb32(); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Rgb24 ToRgb24() => this.data.ToRgb24(); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Bgr24 ToBgr24() => this.data.ToBgr24(); |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal Vector4 ToVector4() => this.data.ToVector4(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,721 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <content>
|
||||
|
/// Contains static named color values.
|
||||
|
/// </content>
|
||||
|
public readonly partial struct Color |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F0F8FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color AliceBlue = FromRgba(240, 248, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FAEBD7.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color AntiqueWhite = FromRgba(250, 235, 215, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Aqua = FromRgba(0, 255, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #7FFFD4.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Aquamarine = FromRgba(127, 255, 212, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F0FFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Azure = FromRgba(240, 255, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F5F5DC.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Beige = FromRgba(245, 245, 220, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFE4C4.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Bisque = FromRgba(255, 228, 196, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #000000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Black = FromRgba(0, 0, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFEBCD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color BlanchedAlmond = FromRgba(255, 235, 205, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #0000FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Blue = FromRgba(0, 0, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #8A2BE2.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color BlueViolet = FromRgba(138, 43, 226, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #A52A2A.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Brown = FromRgba(165, 42, 42, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DEB887.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color BurlyWood = FromRgba(222, 184, 135, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #5F9EA0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color CadetBlue = FromRgba(95, 158, 160, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #7FFF00.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Chartreuse = FromRgba(127, 255, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #D2691E.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Chocolate = FromRgba(210, 105, 30, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF7F50.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Coral = FromRgba(255, 127, 80, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #6495ED.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color CornflowerBlue = FromRgba(100, 149, 237, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFF8DC.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Cornsilk = FromRgba(255, 248, 220, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DC143C.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Crimson = FromRgba(220, 20, 60, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00FFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Cyan = FromRgba(0, 255, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00008B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkBlue = FromRgba(0, 0, 139, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #008B8B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkCyan = FromRgba(0, 139, 139, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #B8860B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkGoldenrod = FromRgba(184, 134, 11, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #A9A9A9.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkGray = FromRgba(169, 169, 169, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #006400.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkGreen = FromRgba(0, 100, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #BDB76B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkKhaki = FromRgba(189, 183, 107, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #8B008B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkMagenta = FromRgba(139, 0, 139, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #556B2F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkOliveGreen = FromRgba(85, 107, 47, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF8C00.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkOrange = FromRgba(255, 140, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #9932CC.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkOrchid = FromRgba(153, 50, 204, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #8B0000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkRed = FromRgba(139, 0, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #E9967A.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkSalmon = FromRgba(233, 150, 122, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #8FBC8B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkSeaGreen = FromRgba(143, 188, 139, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #483D8B.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkSlateBlue = FromRgba(72, 61, 139, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #2F4F4F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkSlateGray = FromRgba(47, 79, 79, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00CED1.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkTurquoise = FromRgba(0, 206, 209, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #9400D3.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DarkViolet = FromRgba(148, 0, 211, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF1493.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DeepPink = FromRgba(255, 20, 147, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00BFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DeepSkyBlue = FromRgba(0, 191, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #696969.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DimGray = FromRgba(105, 105, 105, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #1E90FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color DodgerBlue = FromRgba(30, 144, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #B22222.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Firebrick = FromRgba(178, 34, 34, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFAF0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color FloralWhite = FromRgba(255, 250, 240, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #228B22.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color ForestGreen = FromRgba(34, 139, 34, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Fuchsia = FromRgba(255, 0, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DCDCDC.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Gainsboro = FromRgba(220, 220, 220, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F8F8FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color GhostWhite = FromRgba(248, 248, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFD700.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Gold = FromRgba(255, 215, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DAA520.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Goldenrod = FromRgba(218, 165, 32, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #808080.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Gray = FromRgba(128, 128, 128, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #008000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Green = FromRgba(0, 128, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #ADFF2F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color GreenYellow = FromRgba(173, 255, 47, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F0FFF0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Honeydew = FromRgba(240, 255, 240, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF69B4.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color HotPink = FromRgba(255, 105, 180, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #CD5C5C.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color IndianRed = FromRgba(205, 92, 92, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #4B0082.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Indigo = FromRgba(75, 0, 130, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFFF0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Ivory = FromRgba(255, 255, 240, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F0E68C.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Khaki = FromRgba(240, 230, 140, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #E6E6FA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Lavender = FromRgba(230, 230, 250, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFF0F5.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LavenderBlush = FromRgba(255, 240, 245, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #7CFC00.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LawnGreen = FromRgba(124, 252, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFACD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LemonChiffon = FromRgba(255, 250, 205, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #ADD8E6.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightBlue = FromRgba(173, 216, 230, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F08080.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightCoral = FromRgba(240, 128, 128, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #E0FFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightCyan = FromRgba(224, 255, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FAFAD2.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightGoldenrodYellow = FromRgba(250, 250, 210, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #D3D3D3.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightGray = FromRgba(211, 211, 211, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #90EE90.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightGreen = FromRgba(144, 238, 144, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFB6C1.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightPink = FromRgba(255, 182, 193, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFA07A.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightSalmon = FromRgba(255, 160, 122, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #20B2AA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightSeaGreen = FromRgba(32, 178, 170, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #87CEFA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightSkyBlue = FromRgba(135, 206, 250, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #778899.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightSlateGray = FromRgba(119, 136, 153, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #B0C4DE.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightSteelBlue = FromRgba(176, 196, 222, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFFE0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LightYellow = FromRgba(255, 255, 224, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00FF00.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Lime = FromRgba(0, 255, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #32CD32.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color LimeGreen = FromRgba(50, 205, 50, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FAF0E6.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Linen = FromRgba(250, 240, 230, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF00FF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Magenta = FromRgba(255, 0, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #800000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Maroon = FromRgba(128, 0, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #66CDAA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumAquamarine = FromRgba(102, 205, 170, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #0000CD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumBlue = FromRgba(0, 0, 205, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #BA55D3.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumOrchid = FromRgba(186, 85, 211, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #9370DB.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumPurple = FromRgba(147, 112, 219, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #3CB371.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumSeaGreen = FromRgba(60, 179, 113, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #7B68EE.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumSlateBlue = FromRgba(123, 104, 238, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00FA9A.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumSpringGreen = FromRgba(0, 250, 154, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #48D1CC.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumTurquoise = FromRgba(72, 209, 204, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #C71585.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MediumVioletRed = FromRgba(199, 21, 133, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #191970.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MidnightBlue = FromRgba(25, 25, 112, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F5FFFA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MintCream = FromRgba(245, 255, 250, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFE4E1.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color MistyRose = FromRgba(255, 228, 225, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFE4B5.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Moccasin = FromRgba(255, 228, 181, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFDEAD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color NavajoWhite = FromRgba(255, 222, 173, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #000080.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Navy = FromRgba(0, 0, 128, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FDF5E6.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color OldLace = FromRgba(253, 245, 230, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #808000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Olive = FromRgba(128, 128, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #6B8E23.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color OliveDrab = FromRgba(107, 142, 35, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFA500.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Orange = FromRgba(255, 165, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF4500.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color OrangeRed = FromRgba(255, 69, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DA70D6.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Orchid = FromRgba(218, 112, 214, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #EEE8AA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PaleGoldenrod = FromRgba(238, 232, 170, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #98FB98.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PaleGreen = FromRgba(152, 251, 152, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #AFEEEE.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PaleTurquoise = FromRgba(175, 238, 238, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DB7093.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PaleVioletRed = FromRgba(219, 112, 147, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFEFD5.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PapayaWhip = FromRgba(255, 239, 213, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFDAB9.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PeachPuff = FromRgba(255, 218, 185, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #CD853F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Peru = FromRgba(205, 133, 63, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFC0CB.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Pink = FromRgba(255, 192, 203, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #DDA0DD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Plum = FromRgba(221, 160, 221, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #B0E0E6.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color PowderBlue = FromRgba(176, 224, 230, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #800080.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Purple = FromRgba(128, 0, 128, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #663399.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color RebeccaPurple = FromRgba(102, 51, 153, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF0000.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Red = FromRgba(255, 0, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #BC8F8F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color RosyBrown = FromRgba(188, 143, 143, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #4169E1.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color RoyalBlue = FromRgba(65, 105, 225, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #8B4513.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SaddleBrown = FromRgba(139, 69, 19, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FA8072.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Salmon = FromRgba(250, 128, 114, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F4A460.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SandyBrown = FromRgba(244, 164, 96, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #2E8B57.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SeaGreen = FromRgba(46, 139, 87, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFF5EE.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SeaShell = FromRgba(255, 245, 238, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #A0522D.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Sienna = FromRgba(160, 82, 45, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #C0C0C0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Silver = FromRgba(192, 192, 192, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #87CEEB.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SkyBlue = FromRgba(135, 206, 235, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #6A5ACD.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SlateBlue = FromRgba(106, 90, 205, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #708090.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SlateGray = FromRgba(112, 128, 144, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFAFA.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Snow = FromRgba(255, 250, 250, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #00FF7F.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SpringGreen = FromRgba(0, 255, 127, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #4682B4.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color SteelBlue = FromRgba(70, 130, 180, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #D2B48C.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Tan = FromRgba(210, 180, 140, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #008080.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Teal = FromRgba(0, 128, 128, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #D8BFD8.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Thistle = FromRgba(216, 191, 216, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FF6347.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Tomato = FromRgba(255, 99, 71, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Transparent = FromRgba(255, 255, 255, 0); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #40E0D0.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Turquoise = FromRgba(64, 224, 208, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #EE82EE.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Violet = FromRgba(238, 130, 238, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F5DEB3.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Wheat = FromRgba(245, 222, 179, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFFFF.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color White = FromRgba(255, 255, 255, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #F5F5F5.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color WhiteSmoke = FromRgba(245, 245, 245, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #FFFF00.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color Yellow = FromRgba(255, 255, 0, 255); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Represents a <see paramref="Color"/> matching the W3C definition that has an hex value of #9ACD32.
|
||||
|
/// </summary>
|
||||
|
public static readonly Color YellowGreen = FromRgba(154, 205, 50, 255); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,166 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <content>
|
||||
|
/// Contains the definition of <see cref="WebSafePalette"/>.
|
||||
|
/// </content>
|
||||
|
public partial struct Color |
||||
|
{ |
||||
|
private static readonly Lazy<Color[]> WebSafePaletteLazy = new Lazy<Color[]>(CreateWebSafePalette, true); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a collection of named, web safe colors as defined in the CSS Color Module Level 4.
|
||||
|
/// </summary>
|
||||
|
public static ReadOnlyMemory<Color> WebSafePalette => WebSafePaletteLazy.Value; |
||||
|
|
||||
|
private static Color[] CreateWebSafePalette() => new[] |
||||
|
{ |
||||
|
AliceBlue, |
||||
|
AntiqueWhite, |
||||
|
Aqua, |
||||
|
Aquamarine, |
||||
|
Azure, |
||||
|
Beige, |
||||
|
Bisque, |
||||
|
Black, |
||||
|
BlanchedAlmond, |
||||
|
Blue, |
||||
|
BlueViolet, |
||||
|
Brown, |
||||
|
BurlyWood, |
||||
|
CadetBlue, |
||||
|
Chartreuse, |
||||
|
Chocolate, |
||||
|
Coral, |
||||
|
CornflowerBlue, |
||||
|
Cornsilk, |
||||
|
Crimson, |
||||
|
Cyan, |
||||
|
DarkBlue, |
||||
|
DarkCyan, |
||||
|
DarkGoldenrod, |
||||
|
DarkGray, |
||||
|
DarkGreen, |
||||
|
DarkKhaki, |
||||
|
DarkMagenta, |
||||
|
DarkOliveGreen, |
||||
|
DarkOrange, |
||||
|
DarkOrchid, |
||||
|
DarkRed, |
||||
|
DarkSalmon, |
||||
|
DarkSeaGreen, |
||||
|
DarkSlateBlue, |
||||
|
DarkSlateGray, |
||||
|
DarkTurquoise, |
||||
|
DarkViolet, |
||||
|
DeepPink, |
||||
|
DeepSkyBlue, |
||||
|
DimGray, |
||||
|
DodgerBlue, |
||||
|
Firebrick, |
||||
|
FloralWhite, |
||||
|
ForestGreen, |
||||
|
Fuchsia, |
||||
|
Gainsboro, |
||||
|
GhostWhite, |
||||
|
Gold, |
||||
|
Goldenrod, |
||||
|
Gray, |
||||
|
Green, |
||||
|
GreenYellow, |
||||
|
Honeydew, |
||||
|
HotPink, |
||||
|
IndianRed, |
||||
|
Indigo, |
||||
|
Ivory, |
||||
|
Khaki, |
||||
|
Lavender, |
||||
|
LavenderBlush, |
||||
|
LawnGreen, |
||||
|
LemonChiffon, |
||||
|
LightBlue, |
||||
|
LightCoral, |
||||
|
LightCyan, |
||||
|
LightGoldenrodYellow, |
||||
|
LightGray, |
||||
|
LightGreen, |
||||
|
LightPink, |
||||
|
LightSalmon, |
||||
|
LightSeaGreen, |
||||
|
LightSkyBlue, |
||||
|
LightSlateGray, |
||||
|
LightSteelBlue, |
||||
|
LightYellow, |
||||
|
Lime, |
||||
|
LimeGreen, |
||||
|
Linen, |
||||
|
Magenta, |
||||
|
Maroon, |
||||
|
MediumAquamarine, |
||||
|
MediumBlue, |
||||
|
MediumOrchid, |
||||
|
MediumPurple, |
||||
|
MediumSeaGreen, |
||||
|
MediumSlateBlue, |
||||
|
MediumSpringGreen, |
||||
|
MediumTurquoise, |
||||
|
MediumVioletRed, |
||||
|
MidnightBlue, |
||||
|
MintCream, |
||||
|
MistyRose, |
||||
|
Moccasin, |
||||
|
NavajoWhite, |
||||
|
Navy, |
||||
|
OldLace, |
||||
|
Olive, |
||||
|
OliveDrab, |
||||
|
Orange, |
||||
|
OrangeRed, |
||||
|
Orchid, |
||||
|
PaleGoldenrod, |
||||
|
PaleGreen, |
||||
|
PaleTurquoise, |
||||
|
PaleVioletRed, |
||||
|
PapayaWhip, |
||||
|
PeachPuff, |
||||
|
Peru, |
||||
|
Pink, |
||||
|
Plum, |
||||
|
PowderBlue, |
||||
|
Purple, |
||||
|
RebeccaPurple, |
||||
|
Red, |
||||
|
RosyBrown, |
||||
|
RoyalBlue, |
||||
|
SaddleBrown, |
||||
|
Salmon, |
||||
|
SandyBrown, |
||||
|
SeaGreen, |
||||
|
SeaShell, |
||||
|
Sienna, |
||||
|
Silver, |
||||
|
SkyBlue, |
||||
|
SlateBlue, |
||||
|
SlateGray, |
||||
|
Snow, |
||||
|
SpringGreen, |
||||
|
SteelBlue, |
||||
|
Tan, |
||||
|
Teal, |
||||
|
Thistle, |
||||
|
Tomato, |
||||
|
Transparent, |
||||
|
Turquoise, |
||||
|
Violet, |
||||
|
Wheat, |
||||
|
White, |
||||
|
WhiteSmoke, |
||||
|
Yellow, |
||||
|
YellowGreen |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,135 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <content>
|
||||
|
/// Contains the definition of <see cref="WernerPalette"/>.
|
||||
|
/// </content>
|
||||
|
public partial struct Color |
||||
|
{ |
||||
|
private static readonly Lazy<Color[]> WernerPaletteLazy = new Lazy<Color[]>(CreateWernerPalette, true); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets a collection of colors as defined in the original second edition of Werner’s Nomenclature of Colours 1821.
|
||||
|
/// The hex codes were collected and defined by Nicholas Rougeux <see href="https://www.c82.net/werner"/>.
|
||||
|
/// </summary>
|
||||
|
public static ReadOnlyMemory<Color> WernerPalette => WernerPaletteLazy.Value; |
||||
|
|
||||
|
private static Color[] CreateWernerPalette() => new[] |
||||
|
{ |
||||
|
FromHex("#f1e9cd"), |
||||
|
FromHex("#f2e7cf"), |
||||
|
FromHex("#ece6d0"), |
||||
|
FromHex("#f2eacc"), |
||||
|
FromHex("#f3e9ca"), |
||||
|
FromHex("#f2ebcd"), |
||||
|
FromHex("#e6e1c9"), |
||||
|
FromHex("#e2ddc6"), |
||||
|
FromHex("#cbc8b7"), |
||||
|
FromHex("#bfbbb0"), |
||||
|
FromHex("#bebeb3"), |
||||
|
FromHex("#b7b5ac"), |
||||
|
FromHex("#bab191"), |
||||
|
FromHex("#9c9d9a"), |
||||
|
FromHex("#8a8d84"), |
||||
|
FromHex("#5b5c61"), |
||||
|
FromHex("#555152"), |
||||
|
FromHex("#413f44"), |
||||
|
FromHex("#454445"), |
||||
|
FromHex("#423937"), |
||||
|
FromHex("#433635"), |
||||
|
FromHex("#252024"), |
||||
|
FromHex("#241f20"), |
||||
|
FromHex("#281f3f"), |
||||
|
FromHex("#1c1949"), |
||||
|
FromHex("#4f638d"), |
||||
|
FromHex("#383867"), |
||||
|
FromHex("#5c6b8f"), |
||||
|
FromHex("#657abb"), |
||||
|
FromHex("#6f88af"), |
||||
|
FromHex("#7994b5"), |
||||
|
FromHex("#6fb5a8"), |
||||
|
FromHex("#719ba2"), |
||||
|
FromHex("#8aa1a6"), |
||||
|
FromHex("#d0d5d3"), |
||||
|
FromHex("#8590ae"), |
||||
|
FromHex("#3a2f52"), |
||||
|
FromHex("#39334a"), |
||||
|
FromHex("#6c6d94"), |
||||
|
FromHex("#584c77"), |
||||
|
FromHex("#533552"), |
||||
|
FromHex("#463759"), |
||||
|
FromHex("#bfbac0"), |
||||
|
FromHex("#77747f"), |
||||
|
FromHex("#4a475c"), |
||||
|
FromHex("#b8bfaf"), |
||||
|
FromHex("#b2b599"), |
||||
|
FromHex("#979c84"), |
||||
|
FromHex("#5d6161"), |
||||
|
FromHex("#61ac86"), |
||||
|
FromHex("#a4b6a7"), |
||||
|
FromHex("#adba98"), |
||||
|
FromHex("#93b778"), |
||||
|
FromHex("#7d8c55"), |
||||
|
FromHex("#33431e"), |
||||
|
FromHex("#7c8635"), |
||||
|
FromHex("#8e9849"), |
||||
|
FromHex("#c2c190"), |
||||
|
FromHex("#67765b"), |
||||
|
FromHex("#ab924b"), |
||||
|
FromHex("#c8c76f"), |
||||
|
FromHex("#ccc050"), |
||||
|
FromHex("#ebdd99"), |
||||
|
FromHex("#ab9649"), |
||||
|
FromHex("#dbc364"), |
||||
|
FromHex("#e6d058"), |
||||
|
FromHex("#ead665"), |
||||
|
FromHex("#d09b2c"), |
||||
|
FromHex("#a36629"), |
||||
|
FromHex("#a77d35"), |
||||
|
FromHex("#f0d696"), |
||||
|
FromHex("#d7c485"), |
||||
|
FromHex("#f1d28c"), |
||||
|
FromHex("#efcc83"), |
||||
|
FromHex("#f3daa7"), |
||||
|
FromHex("#dfa837"), |
||||
|
FromHex("#ebbc71"), |
||||
|
FromHex("#d17c3f"), |
||||
|
FromHex("#92462f"), |
||||
|
FromHex("#be7249"), |
||||
|
FromHex("#bb603c"), |
||||
|
FromHex("#c76b4a"), |
||||
|
FromHex("#a75536"), |
||||
|
FromHex("#b63e36"), |
||||
|
FromHex("#b5493a"), |
||||
|
FromHex("#cd6d57"), |
||||
|
FromHex("#711518"), |
||||
|
FromHex("#e9c49d"), |
||||
|
FromHex("#eedac3"), |
||||
|
FromHex("#eecfbf"), |
||||
|
FromHex("#ce536b"), |
||||
|
FromHex("#b74a70"), |
||||
|
FromHex("#b7757c"), |
||||
|
FromHex("#612741"), |
||||
|
FromHex("#7a4848"), |
||||
|
FromHex("#3f3033"), |
||||
|
FromHex("#8d746f"), |
||||
|
FromHex("#4d3635"), |
||||
|
FromHex("#6e3b31"), |
||||
|
FromHex("#864735"), |
||||
|
FromHex("#553d3a"), |
||||
|
FromHex("#613936"), |
||||
|
FromHex("#7a4b3a"), |
||||
|
FromHex("#946943"), |
||||
|
FromHex("#c39e6d"), |
||||
|
FromHex("#513e32"), |
||||
|
FromHex("#8b7859"), |
||||
|
FromHex("#9b856b"), |
||||
|
FromHex("#766051"), |
||||
|
FromHex("#453b32") |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,186 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Buffers.Binary; |
||||
|
using System.Globalization; |
||||
|
using System.Numerics; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Represents a color value that is convertible to any <see cref="IPixel{TSelf}"/> type.
|
||||
|
/// </summary>
|
||||
|
/// <remarks>
|
||||
|
/// The internal representation and layout of this structure is hidden by intention.
|
||||
|
/// It's not serializable, and it should not be considered as part of a contract.
|
||||
|
/// Unlike System.Drawing.Color, <see cref="Color"/> has to be converted to a specific pixel value
|
||||
|
/// to query the color components.
|
||||
|
/// </remarks>
|
||||
|
public readonly partial struct Color : IEquatable<Color> |
||||
|
{ |
||||
|
private readonly Rgba64 data; |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
private Color(byte r, byte g, byte b, byte a) |
||||
|
{ |
||||
|
this.data = new Rgba64( |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(r), |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(g), |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(b), |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(a)); |
||||
|
} |
||||
|
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
private Color(byte r, byte g, byte b) |
||||
|
{ |
||||
|
this.data = new Rgba64( |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(r), |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(g), |
||||
|
ImageMaths.UpscaleFrom8BitTo16Bit(b), |
||||
|
ushort.MaxValue); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Checks whether two <see cref="Color"/> structures are equal.
|
||||
|
/// </summary>
|
||||
|
/// <param name="left">The left hand <see cref="Color"/> operand.</param>
|
||||
|
/// <param name="right">The right hand <see cref="Color"/> operand.</param>
|
||||
|
/// <returns>
|
||||
|
/// True if the <paramref name="left"/> parameter is equal to the <paramref name="right"/> parameter;
|
||||
|
/// otherwise, false.
|
||||
|
/// </returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static bool operator ==(Color left, Color right) |
||||
|
{ |
||||
|
return left.Equals(right); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Checks whether two <see cref="Color"/> structures are equal.
|
||||
|
/// </summary>
|
||||
|
/// <param name="left">The left hand <see cref="Color"/> operand.</param>
|
||||
|
/// <param name="right">The right hand <see cref="Color"/> operand.</param>
|
||||
|
/// <returns>
|
||||
|
/// True if the <paramref name="left"/> parameter is not equal to the <paramref name="right"/> parameter;
|
||||
|
/// otherwise, false.
|
||||
|
/// </returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static bool operator !=(Color left, Color right) |
||||
|
{ |
||||
|
return !left.Equals(right); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a <see cref="Color"/> from RGBA bytes.
|
||||
|
/// </summary>
|
||||
|
/// <param name="r">The red component (0-255).</param>
|
||||
|
/// <param name="g">The green component (0-255).</param>
|
||||
|
/// <param name="b">The blue component (0-255).</param>
|
||||
|
/// <param name="a">The alpha component (0-255).</param>
|
||||
|
/// <returns>The <see cref="Color"/>.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static Color FromRgba(byte r, byte g, byte b, byte a) => new Color(r, g, b, a); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a <see cref="Color"/> from RGB bytes.
|
||||
|
/// </summary>
|
||||
|
/// <param name="r">The red component (0-255).</param>
|
||||
|
/// <param name="g">The green component (0-255).</param>
|
||||
|
/// <param name="b">The blue component (0-255).</param>
|
||||
|
/// <returns>The <see cref="Color"/>.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static Color FromRgb(byte r, byte g, byte b) => new Color(r, g, b); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Creates a new <see cref="Color"/> instance from the string representing a color in hexadecimal form.
|
||||
|
/// </summary>
|
||||
|
/// <param name="hex">
|
||||
|
/// The hexadecimal representation of the combined color components arranged
|
||||
|
/// in rgb, rgba, rrggbb, or rrggbbaa format to match web syntax.
|
||||
|
/// </param>
|
||||
|
/// <returns>Returns a <see cref="Color"/> that represents the color defined by the provided RGBA hex string.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public static Color FromHex(string hex) |
||||
|
{ |
||||
|
Rgba32 rgba = Rgba32.FromHex(hex); |
||||
|
|
||||
|
return new Color(rgba); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Alters the alpha channel of the color, returning a new instance.
|
||||
|
/// </summary>
|
||||
|
/// <param name="alpha">The new value of alpha [0..1].</param>
|
||||
|
/// <returns>The color having it's alpha channel altered.</returns>
|
||||
|
public Color WithAlpha(float alpha) |
||||
|
{ |
||||
|
Vector4 v = (Vector4)this; |
||||
|
v.W = alpha; |
||||
|
return new Color(v); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets the hexadecimal representation of the color instance in rrggbbaa form.
|
||||
|
/// </summary>
|
||||
|
/// <returns>A hexadecimal string representation of the value.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public string ToHex() => this.data.ToRgba32().ToHex(); |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
public override string ToString() => this.ToHex(); |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Converts the color instance to an <see cref="IPixel{TSelf}"/>
|
||||
|
/// implementation defined by <typeparamref name="TPixel"/>.
|
||||
|
/// </summary>
|
||||
|
/// <typeparam name="TPixel">The pixel type to convert to.</typeparam>
|
||||
|
/// <returns>The pixel value.</returns>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public TPixel ToPixel<TPixel>() |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
TPixel pixel = default; |
||||
|
pixel.FromRgba64(this.data); |
||||
|
return pixel; |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public bool Equals(Color other) |
||||
|
{ |
||||
|
return this.data.PackedValue == other.data.PackedValue; |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
public override bool Equals(object obj) |
||||
|
{ |
||||
|
return obj is Color other && this.Equals(other); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
public override int GetHashCode() |
||||
|
{ |
||||
|
return this.data.PackedValue.GetHashCode(); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Bulk convert a span of <see cref="Color"/> to a span of a specified pixel type.
|
||||
|
/// </summary>
|
||||
|
[MethodImpl(InliningOptions.ShortMethod)] |
||||
|
internal static void ToPixel<TPixel>( |
||||
|
Configuration configuration, |
||||
|
ReadOnlySpan<Color> source, |
||||
|
Span<TPixel> destination) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
ReadOnlySpan<Rgba64> rgba64Span = MemoryMarshal.Cast<Color, Rgba64>(source); |
||||
|
PixelOperations<TPixel>.Instance.FromRgba64(Configuration.Default, rgba64Span, destination); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue