Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on How does PathData work?
Parent
How does PathData work?
What is pathData? I was thinking to convert SVG to XML. I found it. In the code, I had seen that
android:pathData="M 64 2 C 98.2416544895 2 126 29.7583455105 126 64 C 126 98.2416544895 98.2416544895 126 64 126 C 29.7583455105 126 2 98.2416544895 2 64 C 2 29.7583455105 29.7583455105 2 64 2 Z" />
I am interested to draw pictures using XML. But without understanding of PathData I can't redraw anything. What I understood (from changing those data) that is : the pathData is usually used for bending-curving which means the PathData is making shape. But I am curious about which variable is doing what. There's lots of number and some English "M", "C" and "Z". What does they do? Could you please clarify each variables?
I have found following lines in SO. But I wonder my code doesn't contain any single comma.
Parameters :(rx, ry x-axis-rotation large-arc-flag, sweep-flag x, y )
(10, 10 0 1, 1 42, 32 )
(10, 10 0 1, 1 22, 32 )
Post
The Android VectorDrawable builds upon the SVG file format. (https://developer.android.com/reference/android/graphics/drawable/VectorDrawable)
android:pathData Defines path data using exactly same format as "d" attribute in the SVG's path data. This is defined in the viewport space.
You can read full documentation about SVG file formats for paths here: https://www.w3.org/TR/SVG/paths.html
To get you started, the contents are a list of commands and locations. For the ones you asked about:
- M - Move To - Moves the pen to a location
- C - Cubic Bezier Curve - Draws a curve from one point to a second using control points to define the curve
- Z - Close Path - Closes the path you are drawing.
0 comment threads