SlideShare uma empresa Scribd logo
1 de 26
Windows 8
Brushes and Transforms—
Part 1
Brushes and Transforms—
Parthttp://www.LearnNowOnline.com
     1


         Learn More @ http://www.learnnowonline.com
          Copyright © by Application Developers Training Company
Objectives
• Work with solid, gradient, and image brushes
• Add transparency effects, including opacity
  mask
• Investigate built-in transforms
• Add reflection effect using opacity mask and
  transforms



             Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Working with Brushes
• Never used a complex brush? Never used a
  brush at all?
  • No way to avoid it: Every Fill property uses a
    SolidColorBrush
     • Single, solid color

• Windows.UI.Xaml.Media.Brush parent for all




                Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
What’s a Brush?
• Brush provides means to paint, or fill an area
  with output
  • SolidColorBrush
     • Paints area with solid color
  • LinearGradientBrush
     • Paints with linear gradient, gradually changing colors
       along a line
  • ImageBrush
     • Paints with an image

                Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Missing in Action
• XAML for Windows Store apps not the same as
  XAML for Silverlight or WPF
• Among many other differences…
  • Missing RadialGradientBrush
  • No good workaround




             Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
SolidColorBrush Class
• Simplest brush, does one thing:
  • Paints an area with a solid color
  • Might be Fill for rectangle
  • Background for cell
  • Foreground for a text font
• Every time select a solid color, selecting a
  SolidColorBrush


               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
How to Select a Color
• Can use predefined colors by name
  • Red, MediumBlue
• Choose a color from 32-bit color palette
  • Format: #rrggbb (red, green, blue values between 0
    and 255, or 0 and #FF)
  • Can also specify alpha value: #aarrggbb
     • aa specifies opacity, where #FF is totally opaque, and 0
      is transparent


                Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
How to Select a Color
• Can use Element.Property syntax to describe
  the SolidColorBrush
  • More verbose
  • Allows you to use a named color and opacity at the
    same time
     • Without using the #aarrggbb format




                Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Use Named Colors
• Simplest way to use colors
<Rectangle Margin="0, 0, 20, 0"
           Width="90" Height="90"
            Fill="Plum"
            Stroke="Yellow"
           StrokeThickness="10" />


• Chart here:
  • http://msdn.microsoft.com/
     en-us/library/system.
     windows.media.brushes
     (v=vs.110).aspx
                 Learn More @ http://www.learnnowonline.com
                 Copyright © by Application Developers Training Company
Use #rrggbb or #aarrggbb Syntax
• Can specify using either #rrggbb or #aarrggbb
  syntax
  • Each pair of letters represents two hex digits
  • rr=red, bb=blue, gg=green
  • #FFFFFF represents white, #000000=black
  • #00FF00 = green




               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Use #rrggbb or #aarrggbb Syntax
• Can specify opacity by adding alpha value
  • #aarrggbb: aa contains value between 0 and FF
  • #FF is fully opaque, 00 is fully transparent
     • Transparent named color has alpha value set to 0
     • All other named colors have alpha set to #FF




                Learn More @ http://www.learnnowonline.com
                Copyright © by Application Developers Training Company
Use Element.Property Syntax
• Use more verbose Element.Property syntax
  gets best of both worlds:
  • Can use a named color
  • Can also specify Opacity property for brush
  • For altering opacity at runtime, this is best choice

        <Rectangle.Fill>
           <SolidColorBrush
             Color="Red" Opacity="0.5" />
         </Rectangle.Fill>



               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
DEMO
• SolidColorBrush




            Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
LinearGradientBrush Class
• Paints an area with a
  linear gradient
• You control
  • Direction and position of gradient
  • Colors that make up gradient
  • Locations at which colors change




              Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
LinearGradientBrush
• Linear gradient defines color gradient along
  line
• Set gradient line's end points using
  StartPoint and EndPoint properties
• Default line gradient is diagonal
  • Endpoints 0,0 and 1,1
  • Upper-left corner to lower-right corner
  • Coordinates relative to container

              Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
LinearGradientBrush
• Add one GradientStop to brush for each color
• For each GradientStop
  • Provide Offset along line
  • At Offset point, color is
    100% saturated
  • Offsets range from 0 (at the StartPoint) to
    1 (at the EndPoint)



               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Rotating the Gradient
• Can rotate gradient by modifying StartPoint
  and EndPoint properties
• Don't like relative coordinate mapping system?
  • Set MappingMode property of brush to Absolute
     • Default is RelativeToBoundingBox




             Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Changing the Stop Points
• Offset property indicates GradientStop location
  along gradient line
  • Must be between 0 and 1
• As Offset property altered
  • Alter the point at which fully saturated color starts




               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
DEMO
• LinearGradient1




            Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Extending the Gradient
• What happens if gradient doesn't extend fully
  across bounding area?
  • Doesn't necessarily fill entire area
  • Default behavior pads extra with most local color
    from gradient




               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Extending the Gradient
• Brush.SpreadMethod property controls
  behavior
  • Pad (default): uses solid fill of appropriate color
  • Reflect: areas outside gradient fill painted in
    original gradient, in reverse order—provides
    "reflected" look
  • Repeat: areas outside gradient fill painted in
    original gradient repeated until area filled


               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
Rectangles Only?
• Is LinearGradientBrush restricted to
  rectangular areas?
  • Absolutely not
  • Can use in ellipses, text, anywhere you need a
    brush




              Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
DEMO
• LinearGradient2




            Learn More @ http://www.learnnowonline.com
             Copyright © by Application Developers Training Company
Using Visual Studio
• Seems difficult to lay out gradients!
• Doesn’t have to be:
  • Use design tools built into Visual Studio
• Makes it easy to create linear gradients




               Learn More @ http://www.learnnowonline.com
               Copyright © by Application Developers Training Company
DEMO
• Visual Studio Design tools




             Learn More @ http://www.learnnowonline.com
              Copyright © by Application Developers Training Company
End of Part 1

    http://www.LearnNowOnline.com




         Learn More @ http://www.learnnowonline.com
         Copyright © by Application Developers Training Company

Mais conteúdo relacionado

Mais de LearnNowOnline

Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniquesLearnNowOnline
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScriptLearnNowOnline
 
SharePoint Document Management
SharePoint Document ManagementSharePoint Document Management
SharePoint Document ManagementLearnNowOnline
 
SharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathSharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathLearnNowOnline
 
Managing site collections
Managing site collectionsManaging site collections
Managing site collectionsLearnNowOnline
 
Sql 2012 development and programming
Sql 2012  development and programmingSql 2012  development and programming
Sql 2012 development and programmingLearnNowOnline
 
What's new in Silverlight 5
What's new in Silverlight 5What's new in Silverlight 5
What's new in Silverlight 5LearnNowOnline
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVCKnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVCLearnNowOnline
 
Expression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignExpression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignLearnNowOnline
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity FrameworkLearnNowOnline
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCLearnNowOnline
 
Working with Controllers and Actions in MVC
Working with Controllers and Actions in MVCWorking with Controllers and Actions in MVC
Working with Controllers and Actions in MVCLearnNowOnline
 
Creating a User Interface
Creating a User InterfaceCreating a User Interface
Creating a User InterfaceLearnNowOnline
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5LearnNowOnline
 

Mais de LearnNowOnline (20)

Introducing LINQ
Introducing LINQIntroducing LINQ
Introducing LINQ
 
Generics
GenericsGenerics
Generics
 
Object oriented techniques
Object oriented techniquesObject oriented techniques
Object oriented techniques
 
Object-Oriented JavaScript
Object-Oriented JavaScriptObject-Oriented JavaScript
Object-Oriented JavaScript
 
SharePoint Document Management
SharePoint Document ManagementSharePoint Document Management
SharePoint Document Management
 
SharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPathSharePoint: Introduction to InfoPath
SharePoint: Introduction to InfoPath
 
Managing site collections
Managing site collectionsManaging site collections
Managing site collections
 
Web API HTTP Pipeline
Web API HTTP PipelineWeb API HTTP Pipeline
Web API HTTP Pipeline
 
Web API Basics
Web API BasicsWeb API Basics
Web API Basics
 
SQL Server: Security
SQL Server: SecuritySQL Server: Security
SQL Server: Security
 
Sql 2012 development and programming
Sql 2012  development and programmingSql 2012  development and programming
Sql 2012 development and programming
 
What's new in Silverlight 5
What's new in Silverlight 5What's new in Silverlight 5
What's new in Silverlight 5
 
KnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVCKnockOutJS with ASP.NET MVC
KnockOutJS with ASP.NET MVC
 
Expression Blend Motion & Interaction Design
Expression Blend Motion & Interaction DesignExpression Blend Motion & Interaction Design
Expression Blend Motion & Interaction Design
 
The Entity Data Model
The Entity Data ModelThe Entity Data Model
The Entity Data Model
 
Introducing the Entity Framework
Introducing the Entity FrameworkIntroducing the Entity Framework
Introducing the Entity Framework
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Working with Controllers and Actions in MVC
Working with Controllers and Actions in MVCWorking with Controllers and Actions in MVC
Working with Controllers and Actions in MVC
 
Creating a User Interface
Creating a User InterfaceCreating a User Interface
Creating a User Interface
 
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5Building Windows 8 Metro Style Applications Using JavaScript and HTML5
Building Windows 8 Metro Style Applications Using JavaScript and HTML5
 

Último

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Último (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Windows 8: brushes and transforms

  • 1. Windows 8 Brushes and Transforms— Part 1 Brushes and Transforms— Parthttp://www.LearnNowOnline.com 1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 2. Objectives • Work with solid, gradient, and image brushes • Add transparency effects, including opacity mask • Investigate built-in transforms • Add reflection effect using opacity mask and transforms Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 3. Working with Brushes • Never used a complex brush? Never used a brush at all? • No way to avoid it: Every Fill property uses a SolidColorBrush • Single, solid color • Windows.UI.Xaml.Media.Brush parent for all Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 4. What’s a Brush? • Brush provides means to paint, or fill an area with output • SolidColorBrush • Paints area with solid color • LinearGradientBrush • Paints with linear gradient, gradually changing colors along a line • ImageBrush • Paints with an image Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 5. Missing in Action • XAML for Windows Store apps not the same as XAML for Silverlight or WPF • Among many other differences… • Missing RadialGradientBrush • No good workaround Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 6. SolidColorBrush Class • Simplest brush, does one thing: • Paints an area with a solid color • Might be Fill for rectangle • Background for cell • Foreground for a text font • Every time select a solid color, selecting a SolidColorBrush Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 7. How to Select a Color • Can use predefined colors by name • Red, MediumBlue • Choose a color from 32-bit color palette • Format: #rrggbb (red, green, blue values between 0 and 255, or 0 and #FF) • Can also specify alpha value: #aarrggbb • aa specifies opacity, where #FF is totally opaque, and 0 is transparent Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 8. How to Select a Color • Can use Element.Property syntax to describe the SolidColorBrush • More verbose • Allows you to use a named color and opacity at the same time • Without using the #aarrggbb format Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 9. Use Named Colors • Simplest way to use colors <Rectangle Margin="0, 0, 20, 0" Width="90" Height="90" Fill="Plum" Stroke="Yellow" StrokeThickness="10" /> • Chart here: • http://msdn.microsoft.com/ en-us/library/system. windows.media.brushes (v=vs.110).aspx Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 10. Use #rrggbb or #aarrggbb Syntax • Can specify using either #rrggbb or #aarrggbb syntax • Each pair of letters represents two hex digits • rr=red, bb=blue, gg=green • #FFFFFF represents white, #000000=black • #00FF00 = green Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 11. Use #rrggbb or #aarrggbb Syntax • Can specify opacity by adding alpha value • #aarrggbb: aa contains value between 0 and FF • #FF is fully opaque, 00 is fully transparent • Transparent named color has alpha value set to 0 • All other named colors have alpha set to #FF Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 12. Use Element.Property Syntax • Use more verbose Element.Property syntax gets best of both worlds: • Can use a named color • Can also specify Opacity property for brush • For altering opacity at runtime, this is best choice <Rectangle.Fill> <SolidColorBrush Color="Red" Opacity="0.5" /> </Rectangle.Fill> Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 13. DEMO • SolidColorBrush Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 14. LinearGradientBrush Class • Paints an area with a linear gradient • You control • Direction and position of gradient • Colors that make up gradient • Locations at which colors change Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 15. LinearGradientBrush • Linear gradient defines color gradient along line • Set gradient line's end points using StartPoint and EndPoint properties • Default line gradient is diagonal • Endpoints 0,0 and 1,1 • Upper-left corner to lower-right corner • Coordinates relative to container Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 16. LinearGradientBrush • Add one GradientStop to brush for each color • For each GradientStop • Provide Offset along line • At Offset point, color is 100% saturated • Offsets range from 0 (at the StartPoint) to 1 (at the EndPoint) Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 17. Rotating the Gradient • Can rotate gradient by modifying StartPoint and EndPoint properties • Don't like relative coordinate mapping system? • Set MappingMode property of brush to Absolute • Default is RelativeToBoundingBox Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 18. Changing the Stop Points • Offset property indicates GradientStop location along gradient line • Must be between 0 and 1 • As Offset property altered • Alter the point at which fully saturated color starts Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 19. DEMO • LinearGradient1 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 20. Extending the Gradient • What happens if gradient doesn't extend fully across bounding area? • Doesn't necessarily fill entire area • Default behavior pads extra with most local color from gradient Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 21. Extending the Gradient • Brush.SpreadMethod property controls behavior • Pad (default): uses solid fill of appropriate color • Reflect: areas outside gradient fill painted in original gradient, in reverse order—provides "reflected" look • Repeat: areas outside gradient fill painted in original gradient repeated until area filled Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 22. Rectangles Only? • Is LinearGradientBrush restricted to rectangular areas? • Absolutely not • Can use in ellipses, text, anywhere you need a brush Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 23. DEMO • LinearGradient2 Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 24. Using Visual Studio • Seems difficult to lay out gradients! • Doesn’t have to be: • Use design tools built into Visual Studio • Makes it easy to create linear gradients Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 25. DEMO • Visual Studio Design tools Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company
  • 26. End of Part 1 http://www.LearnNowOnline.com Learn More @ http://www.learnnowonline.com Copyright © by Application Developers Training Company