I want to draw one continuous line/curve with varying thickness using C#. If I set the width of the Pen as fixed, thickness will not vary. How is it possible to change the thickness of line as it is drawn? Any help is appreciated.
2
There are 2 best solutions below
3
olydis
On
General approach: split the line into segments/points and make several draw calls with different pens (as mentioned in other posts).
Now for curves - if you do not want to reimplement their algorithms, you might wanna use GraphicsPath to convert arbitrary paths to line segments (with sufficient resolution).
- add your path (lines, curves, beziers, ...) to a fresh
GraphicsPathinstance - call
Flattento letGraphicsPathperform the magic (= conversion to lines only) - iterate over
PathPointsto get the endpoints of corresponding line segments - subdivide them further until they are short enough for your "varying" pen strategy
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in LINE
- Attach canvas drawed line to scene in Android
- Get a single line representation for multiple close by lines clustered together in opencv
- geom_path diameter to scale with coordinate system
- Android: Intentionally Blank Lines in EditText Are Not Getting Saved
- Draw lines between divs using css border
- why hough transform detects two lines while there is only one line
- PhpStorm shortcut for line breaks
- How to read a value on a specific line in an external file into an AWK script
- How to draw a line over a GridView programmatically
- Using fabric.js hovering lines is fired around them (not only exactly over them)
- Java BufferedReader - empty line issue
- Matlab - plot bar and line graph on the same y axis
- Inserting string in file in nth line after pattern using sed
- batch file delete lines with same variable
- Read lines from file, iterate over each line and each character in that line
Related Questions in CURVE
- Chordal Catmull-Rom Splines
- shoulder detection on a segmented image
- How to transform a curve in a specific way
- Python finding a curve Length
- R- How to draw a curve that crosses specific points
- Polar curve equation with plus-minus sign (±) in Javascript
- Animation curve evaluate
- Three.js animated bezier curves
- how to make shape in svg like the image attached?
- intersection of interpolated line and an interpolated curve matlab
- Negative scale on SVG Bezier curve not working
- Maya Python How do I make a curve out of multiple collected points in a for loop
- Curve By Code how do i do it with this code?
- What is concept of degree at B-spline curve?
- de Casteljau algorithm Objective-C
Related Questions in PEN
- No built-in property editor for the WPF Pen type in Visual Studio?
- Draw line with varying thickness
- AutoHotkey script only works when this window is open
- Roblox DDOS Server How to do?
- Emulating Pen Touch Events in Chrome
- HTML5 pen tool for paint application
- how to split shape made with pen tool in flash
- Draw a line on a TabPage in C#
- Why does my Racket pen draw extra pixels where two lines join despite using 'butt and 'miter?
- Need to save pen tool drawigns in powerpoint before exiting
- How to adjust the width of an existing GDI Pen?
- Tips for developing Penlets
- iPad - biometric signature - getPressure touch
- Drawing does not remain on View
- How can I redirect my Pen-Input to Mouse-Input?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can only vary the thickness of the line if you draw the line point by point, and then vary the thickness of the points.
To find out how to draw lines point by point, look up line drawing algorithms if you don't have them handy. One example for drawing straight lines is Bresenham's algorithm. You can find out more about that at http://en.wikipedia.org/wiki/Bresenham's_line_algorithm.
Then when you plot a dot, you can choose the thickness of the dot. So instead of just drawing a single pixel, you draw a circle with radius r, where r is the thickness of the line you want at that position in the line.