MCPcopy Create free account
hub / github.com/Tencent/tgfx / parseViewBox

Method parseViewBox

src/svg/SVGAttributeParser.cpp:571–589  ·  view source on GitHub ↗

https://www.w3.org/TR/SVG11/coords.html#ViewBoxAttribute

Source from the content-addressed store, hash-verified

569
570// https://www.w3.org/TR/SVG11/coords.html#ViewBoxAttribute
571bool SVGAttributeParser::parseViewBox(SVGViewBoxType* vb) {
572 float x = 0.0f;
573 float y = 0.0f;
574 float w = 0.0f;
575 float h = 0.0f;
576 this->parseWSToken();
577
578 bool parsedValue = false;
579 if (this->parseScalarToken(&x) && this->parseSepToken() && this->parseScalarToken(&y) &&
580 this->parseSepToken() && this->parseScalarToken(&w) && this->parseSepToken() &&
581 this->parseScalarToken(&h)) {
582
583 *vb = static_cast<SVGViewBoxType>(Rect::MakeXYWH(x, y, w, h));
584 parsedValue = true;
585 // consume trailing whitespace
586 this->parseWSToken();
587 }
588 return parsedValue && this->parseEOSToken();
589}
590
591template <typename Func, typename T>
592bool SVGAttributeParser::parseParenthesized(const char* prefix, Func f, T* result) {

Callers 1

SetViewBoxAttributeMethod · 0.80

Calls 4

parseWSTokenMethod · 0.95
parseScalarTokenMethod · 0.95
parseSepTokenMethod · 0.95
parseEOSTokenMethod · 0.95

Tested by

no test coverage detected