Sha256: b99902778bb00f618c1090fd7b3f6121fc112a3292acb12082f6b31a6e022e51

Contents?: true

Size: 855 Bytes

Versions: 6

Compression:

Stored size: 855 Bytes

Contents

#include "SVGPointsParser.h"

#include <iostream>
#include <cstring>

using namespace std;

namespace SWF {

void PointsParser::parse(const char *points) {
	string tmp;

	coords.clear();
	
	for(int i = 0; i < strlen(points); i++) {
		char currentChar = points[i];
		
		if(currentChar == ',' || currentChar == ' ') {
			if(tmp.length() > 0) {
				coords.push_back(atof(tmp.c_str()));
				tmp.clear();
			}			
		} else {
			tmp += currentChar;
		}
	}
	
	if(tmp.length() > 0) {
		coords.push_back(atof(tmp.c_str()));
	}
	
	if(coords.size() % 2) {
		cerr << "WARNING: odd number of coordinates in points attribute" << endl;
	}
}

int PointsParser::getPointCount() {
	return coords.size() / 2;
}

Point PointsParser::getPoint() {
	double x = coords.front();
	coords.pop_front();
		
	double y = coords.front();
	coords.pop_front();
	
	return Point(x, y);
}
	
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
swfmill-0.0.6 ext/swfmill/src/swft/SVGPointsParser.cpp
swfmill-0.0.5 ext/swfmill/src/swft/SVGPointsParser.cpp
swfmill-0.0.4 ext/swfmill/src/swft/SVGPointsParser.cpp
swfmill-0.0.3 ext/swfmill/src/swft/SVGPointsParser.cpp
swfmill-0.0.2 ext/swfmill/src/swft/SVGPointsParser.cpp
swfmill-0.0.1 ext/swfmill/src/swft/SVGPointsParser.cpp