Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Is there a way to control the angle of a lineargradient?

 
 
Old 02-16-2006   #1 (permalink)
Gary F


 
 

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 SpecsSystem Spec
Old 02-20-2006   #2 (permalink)
Gary F


 
 

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
> newsE30A7EA-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 SpecsSystem Spec
Old 02-20-2006   #3 (permalink)
Michael Jacobs [MSFT]


 
 

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
>> newsE30A7EA-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 SpecsSystem Spec
 

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46