MCPcopy Index your code
hub / github.com/processing/p5.js / arrayCommandsToObjects

Function arrayCommandsToObjects

src/type/p5.Font.js:1590–1613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1588
1589// Convert arrays to named objects
1590export const arrayCommandsToObjects = commands => commands.map(command => {
1591 const type = command[0];
1592 switch (type) {
1593 case 'Z': {
1594 return { type };
1595 }
1596 case 'M':
1597 case 'L': {
1598 const [, x, y] = command;
1599 return { type, x, y };
1600 }
1601 case 'Q': {
1602 const [, x1, y1, x, y] = command;
1603 return { type, x1, y1, x, y };
1604 }
1605 case 'C': {
1606 const [, x1, y1, x2, y2, x, y] = command;
1607 return { type, x1, y1, x2, y2, x, y };
1608 }
1609 default: {
1610 throw new Error(`Unexpected path command: ${type}`);
1611 }
1612 }
1613});
1614
1615export { sanitizeFontName as _sanitizeFontName };
1616export default font;

Callers 2

getGlyphInfoMethod · 0.90
pathToPointsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected