![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | Is there a way to control the angle of a lineargradient? I have added a lineargradient to a rectangle. I have specified the direction of the gradient as StartPoint=0,0 to EndPoint=1,1. When I change the shape of the rectangle, the lineargradient changes its direction because it's drawn from 0,0 to 1,1 of the bounding rectangle. Is there a way to control the angle of the lineargradient so that it is always 45 degrees? I want the angle of the gradient to be the same no mather what size the rectangle is. TIA. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Is there a way to control the angle of a lineargradient? Yes, now my linear gradient is always at 45 degrees. However, the gradient does not fill the element equally. This is because the gradient is rotated about 0,0 instead of half the width, half the height of the element. It would be nice if on the RotateTransform I could specify CenterX=0.5 and CenterY=0.5 as half the bounding area of the element. However, I have to specify half the width and height, which is only known at runtime. Any suggestions? "Adam Smith [MS]" wrote: > The easiest way to do this is to start with a horizontal linear gradient and > then rotate it 45 degrees: > > <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> > <LinearGradientBrush.Transform> > <RotateTransform Angle="45"/> > </LinearGradientBrush.Transform> > </LinearGradientBrush> > > -Adam Smith [MS] > > "Gary F" <GaryF@discussions.microsoft.com> wrote in message > news E30A7EA-DAD8-4AC6-938F-9313F1F0643A@microsoft.com...> >I have added a lineargradient to a rectangle. I have specified the > >direction > > of the gradient as StartPoint=0,0 to EndPoint=1,1. When I change the shape > > of > > the rectangle, the lineargradient changes its direction because it's drawn > > from 0,0 to 1,1 of the bounding rectangle. Is there a way to control the > > angle of the lineargradient so that it is always 45 degrees? I want the > > angle of the gradient to be the same no mather what size the rectangle is. > > TIA. > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Is there a way to control the angle of a lineargradient? Gary, Use the RelativeTransform property instead of the Transform property and you can specify the relative center of the rotation: <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <LinearGradientBrush.RelativeTransform> <RotateTransform Angle="45" CenterX="0.5" CenterY="0.5" /> </LinearGradientBrush.RelativeTransform> </LinearGradientBrush> **** Mike Jacobs [MSFT] This posting is provided "AS IS" with no warranties, and confers no rights. "Gary F" <GaryF@discussions.microsoft.com> wrote in message news:5E7ED7D3-B4E1-4441-AFAD-8E397CCF9E62@microsoft.com... > Yes, now my linear gradient is always at 45 degrees. However, the > gradient > does not fill the element equally. This is because the gradient is > rotated > about 0,0 instead of half the width, half the height of the element. It > would be nice if on the RotateTransform I could specify CenterX=0.5 and > CenterY=0.5 as half the bounding area of the element. However, I have to > specify half the width and height, which is only known at runtime. Any > suggestions? > > "Adam Smith [MS]" wrote: > >> The easiest way to do this is to start with a horizontal linear gradient >> and >> then rotate it 45 degrees: >> >> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> >> <LinearGradientBrush.Transform> >> <RotateTransform Angle="45"/> >> </LinearGradientBrush.Transform> >> </LinearGradientBrush> >> >> -Adam Smith [MS] >> >> "Gary F" <GaryF@discussions.microsoft.com> wrote in message >> news E30A7EA-DAD8-4AC6-938F-9313F1F0643A@microsoft.com...>> >I have added a lineargradient to a rectangle. I have specified the >> >direction >> > of the gradient as StartPoint=0,0 to EndPoint=1,1. When I change the >> > shape >> > of >> > the rectangle, the lineargradient changes its direction because it's >> > drawn >> > from 0,0 to 1,1 of the bounding rectangle. Is there a way to control >> > the >> > angle of the lineargradient so that it is always 45 degrees? I want >> > the >> > angle of the gradient to be the same no mather what size the rectangle >> > is. >> > TIA. >> >> >> |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How do I get from the sine of an angle to the actual angle | .NET General | |||
| Converting the sine of an angle to degrees, minutes, and seconds | .NET General | |||
| Researchers Claim New Solar Panel Can Collect 90% of Sunlight From Any Angle | Chillout Room | |||
| Dell 24" viewing angle | Vista hardware & devices | |||