Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I am starting with Direct2D and VC++2013. I am trying to draw a wide line with 50% transparency. On the Microsoft web site I can only find examples of transparency which use the Brush to fill in a transparent color. Can someone show how to draw lines that are transparent in Direct2D. Thanks.

Below should be a link to the Microsoft webpage that dealing with Opacity.

Opacity Masks Overview
Posted
Updated 17-Jul-15 17:56pm
v2
Comments
PIEBALDconsult 17-Jul-15 19:18pm    
How would you know if you didn't?

https://www.youtube.com/watch?v=BKorP55Aqvg
Afzaal Ahmad Zeeshan 17-Jul-15 23:56pm    
Just don't, don't draw anything and tell the user it is transparent. :-)

1 solution

Why don't you say that your line is a rectangle and simply fill it with your transparent colour ?

[Update]
Quote:
Most lines are DIAGONAL, so cannot be represented by a rectangle. (I didn't bother voting, but if I did, I would also downvote.)

I agree that the answer was short.
But you are making a mistake in your analyze, it looks like you believe that a rectangle is either horizontal or vertical, but you make a mistake.
When you rotate a rectangle, it stay a rectangle, even rotated.

By replacing the line by a rectangle, you make a polygon and the brush tool can be used to fill it.
 
Share this answer
 
v2
Comments
Patrice T 18-Jul-15 18:58pm    
You disliked my answer, It is your right.
You downvoted my answer, It is your right.
But since it works, it would be nice to say why you don't like it.
ToolmakerSteve2 27-Sep-17 12:24pm    
Most lines are DIAGONAL, so cannot be represented by a rectangle. (I didn't bother voting, but if I did, I would also downvote.)
Patrice T 27-Sep-17 16:11pm    
See my update.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900