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 answers
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#
- How to call a C language function from x86 assembly code?
- What does: "char *argv[]" mean?
- User input sanitization program, which takes a specific amount of arguments and passes the execution to a bash script
- How to crop a BMP image in half using C
- How can I get the difference in minutes between two dates and hours?
- Why will this code compile although it defines two variables with the same name?
- Compiling eBPF program in Docker fails due to missing '__u64' type
- Why can't I use the file pointer after the first read attempt fails?
- #include Header files in C with definition too
- OpenCV2 on CLion
- What is causing the store latency in this program?
- How to refer to the filepath of test data in test sourcecode?
- 9 Digit Addresses in Hexadecimal System in MacOS
- My server TCP doesn't receive messages from the client in C
- Printing the characters obtained from the array s using printf?
Related Questions in LINE
- As a normal user, how would I know how many arguments and what arguments I need to pass in a command line arguments program?
- How can I solve this problem in Geom_line?
- Notepad++ Remove Empty Spaces or characters after the specific LAST character
- Vertical Line Plot based on Actual Calendar Days not based on Bar Index
- Line blurry issue with subpixel rendering
- Drawing huge amount of lines
- Automatic word spacing to fit line CSS
- How to download whole imageSet from LINE messenger API?
- How to filter out the line which counting up from last line from a text file thru batch command?
- How to generate lines with specific direction from points
- LineSDK Use LoginConfiguration before setup. Please call `LoginManager.setup` before you do any other things in LineSDK
- How to draw line graphs smoothly (not fitting) in R?
- "QGIS: Displaying labels outside polygons for line features inside using field values"
- out of order time points on multi line chart
- How to turn off lines in raster fill label mixed legends ggplot
Related Questions in CURVE
- How to add hyperbolic curve in lattice
- r - Plotting function curves using ggplot
- How to do outwards curves CSS?
- Generating Bezier curves/splines that have consistent variable distance from generating function
- Finding outlier points of a curve
- Finding a point on a curve given a series of points
- finding a point and its angle on a cubic Bezier curve in JavaScript
- Better approach to include two curves in the flutter UI
- What math Adobe After Effects uses for animation?
- I am trying to draw a curve and showing it with a single line . Here I face the issue that instead of joining with a single line it shows many
- Why is the path of my parametric brachistochrone cycloid inverted?
- How can I add a curved line to the outer axis of a radial bar chart in d3.js v4?
- How to draw a curve like this in Swift iOS?
- How to generate a list of coordinate pairs from a simple image of a line
- Flutter outside curved TabBar
Related Questions in PEN
- How do I disable touch input when pen input is enabled?
- Recording pen information as sequential images
- How to change the windows pen palm rejection dead-zone ranges?
- Change Pen thickness using textbox User input
- Convert handwritten input to a collection of geometry on a canvas
- Is there a way to change touch screen input location on Android devices for a stylus pen?
- How to adjust the width of an existing GDI Pen?
- Pyglet Tablet Input make weird prints
- HTML5 Canvas with Apple Pen - Only works with (position: absolute;)
- Input should only possible through Apple Pencil in HTML Canvas JavaScript
- Pen testing issue request designed as POST is accepted as GET
- How to make DrawingVisual objects in C# have unique Pen Brush colour, but share the same thickness
- OWASP ZAP, how to authenticate using Form-based Auth Login context and POST request
- WPF GeometryDrawing Pen not working from code
- Switching HTML5 Canvas pen stroke to solid, dotted, and highlighter
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?
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)
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.