bool pointsListFromSVGData(SVGPointList& pointsList, const String& points) { if (points.isEmpty()) return true; const UChar* cur = points.characters(); const UChar* end = cur + points.length(); skipOptionalSVGSpaces(cur, end); bool delimParsed = false; while (cur < end) { delimParsed = false; float xPos = 0.0f; if (!parseNumber(cur, end, xPos)) return false; float yPos = 0.0f; if (!parseNumber(cur, end, yPos, false)) return false; skipOptionalSVGSpaces(cur, end); if (cur < end && *cur == ',') { delimParsed = true; cur++; } skipOptionalSVGSpaces(cur, end); pointsList.append(FloatPoint(xPos, yPos)); } return cur == end && !delimParsed; }
static bool genericParsePointsList(SVGPointList& pointsList, const CharType*& ptr, const CharType* end) { skipOptionalSVGSpaces(ptr, end); bool delimParsed = false; while (ptr < end) { delimParsed = false; float xPos = 0.0f; if (!parseNumber(ptr, end, xPos)) return false; float yPos = 0.0f; if (!parseNumber(ptr, end, yPos, false)) return false; skipOptionalSVGSpaces(ptr, end); if (ptr < end && *ptr == ',') { delimParsed = true; ptr++; } skipOptionalSVGSpaces(ptr, end); pointsList.append(FloatPoint(xPos, yPos)); } return ptr == end && !delimParsed; }
bool SVGPointList::createAnimated(const SVGPointList& fromList, const SVGPointList& toList, SVGPointList& resultList, float progress) { unsigned itemCount = fromList.size(); if (!itemCount || itemCount != toList.size()) return false; for (unsigned n = 0; n < itemCount; ++n) { const FloatPoint& from = fromList.at(n); const FloatPoint& to = toList.at(n); FloatPoint segment = FloatPoint(adjustAnimatedValue(from.x(), to.x(), progress), adjustAnimatedValue(from.y(), to.y(), progress)); resultList.append(segment); } return true; }
SVGPropertyBase* SVGPointListInterpolationType::appliedSVGValue( const InterpolableValue& interpolableValue, const NonInterpolableValue*) const { SVGPointList* result = SVGPointList::create(); const InterpolableList& list = toInterpolableList(interpolableValue); DCHECK_EQ(list.length() % 2, 0U); for (size_t i = 0; i < list.length(); i += 2) { FloatPoint point = FloatPoint(toInterpolableNumber(list.get(i))->value(), toInterpolableNumber(list.get(i + 1))->value()); result->append(SVGPoint::create(point)); } return result; }