SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Mehr von LearnNowOnline

Mehr von 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
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

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...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

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