Reputation: 9891
I want to set the opacity of a Stroke which is obtained from a user drawing on the screen. I can get the drawing, size, outline of the stroke to set but not the Opacity of it.
This is my code
StylusPointCollection spTemp = e.StylusDevice.GetStylusPoints(MyIP);
tempStroke.StylusPoints.Add(spTemp);
tempStroke.DrawingAttributes.Color = Colors.Red;
tempStroke.DrawingAttributes.OutlineColor = Colors.Black;
tempStroke.DrawingAttributes.Width = BrushSize.Value;
tempStroke.DrawingAttributes.Height = BrushSize.Value;
MyIP.Strokes.Add(tempStroke);
Any help is appreciated
Simple Code
Upvotes: 0
Views: 1171
Reputation: 18832
Set the alpha value on the color. eg for an opacity of +-0.5 and color red:
tempStroke.DrawingAttributes.Color = Colors.FromArgb(125,255,0,0);
Upvotes: 2
Reputation: 29256
I think your going to have to set the Alpha on the color. for example:
//the first 00 would be your alpha channel, then red, then green, then blue
tempStroke.DrawingAttributes.Color = Colors.FromArgb(0x00,0xFF,0x00,0x00);
Upvotes: 1
Reputation: 390
You can set the Color.A property to a value from 0 to 255 or set the Color.ScA property to a decimal value from 0 to 1. The two properties are kept in sync, so if you change one, expect the other to update to an equivalent value.
http://msdn.microsoft.com/en-us/library/system.windows.media.color.aspx
Upvotes: 0