Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

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?

+1
−0

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 )
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

Post
+6
−0

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.
History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.

1 comment thread

What does "L" do? (2 comments)
What does "L" do?
Anonymous‭ wrote about 3 years ago

A command letter may be eliminated if an identical command letter would otherwise precede it; for instance, the following contains an unnecessary second "L" command:

M 100 200 L 200 100 L -100 -200

But it's not understandable to me

Anonymous‭ wrote about 3 years ago · edited about 3 years ago

Draw a line from the current point to the given (x,y) coordinate which becomes the new current point. L (uppercase) indicates that absolute coordinates will follow; l (lowercase) indicates that relative coordinates will follow. A number of coordinates pairs may be specified to draw a polyline. At the end of the command, the new current point is set to the final set of coordinates provided. ~ https://www.w3.org/TR/SVG/paths.html#PathDataLinetoCommands

found it.. it's meaningful