-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create svg_utils file #2597
Create svg_utils file #2597
Conversation
FYI @NeilFraser @RoboErikG for API/naming comments. |
core/utils/svg_paths.js
Outdated
* See developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths#Line_commands | ||
* @param {!Array.<string>} points An array containing all of the points to | ||
* draw lines to, in order. The points are represented as strings of the | ||
* format ' dx, dy '. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no space after the comma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/utils/svg_paths.js
Outdated
* These coordinates are unitless and hence in the user coordinate system. | ||
* See developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#LineTo_path_commands | ||
* @param {string} command The command to prepend to the coordinate. This | ||
* should be one of: V, v, H, h. See |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh say can you see ... what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
The basics
The details
Resolves
No issue
Proposed Changes
Create a set of helper functions for making SVG path commands.
Reason for Changes
SVG paths are defined as strings. There are a variety of commands, each represented by a single character and a sequence of numbers. These commands are really hard to read in the current code:
These functions make the SVG path code more readable, and also remove some of the confusion around number addition vs string concatenation. It also makes it easier to see when we're using negative numbers.
This is a proposed API. I would like to keep the names relatively short, since
Blockly.utils.Something
is already pretty long. I could be convinced that it should beSVGPaths
instead ofPaths
.We're not using these functions anywhere yet, so now is the time to pick names.