bool ShadowTessellator::isClockwisePath(const SkPath& path) { SkPath::Iter iter(path, false); SkPoint pts[4]; SkPath::Verb v; Vector<Vector2> arrayForDirection; while (SkPath::kDone_Verb != (v = iter.next(pts))) { switch (v) { case SkPath::kMove_Verb: arrayForDirection.add((Vector2){pts[0].x(), pts[0].y()}); break; case SkPath::kLine_Verb: arrayForDirection.add((Vector2){pts[1].x(), pts[1].y()}); break; case SkPath::kQuad_Verb: arrayForDirection.add((Vector2){pts[1].x(), pts[1].y()}); arrayForDirection.add((Vector2){pts[2].x(), pts[2].y()}); break; case SkPath::kCubic_Verb: arrayForDirection.add((Vector2){pts[1].x(), pts[1].y()}); arrayForDirection.add((Vector2){pts[2].x(), pts[2].y()}); arrayForDirection.add((Vector2){pts[3].x(), pts[3].y()}); break; default: break; } } return isClockwise(arrayForDirection.array(), arrayForDirection.size()); }
void Sprite::draw() { ccDrawColor4F(1, 1, 1, 1); if(_isTouch) { if(isClockwise()) { _directAngle -= 7; } else { _directAngle += 7; } } float cx,cy,tx,ty,cl; cx = _radius*cos(CC_DEGREES_TO_RADIANS(_directAngle)); cy = _radius*sin(CC_DEGREES_TO_RADIANS(_directAngle)); cl = sqrtf(cx*cx+cy*cy); tx = cy/cl; ty = -cx/cl; CCPoint points[] = { CCPoint(cx+_baseLength/2*tx,cy+_baseLength/2*ty), CCPoint(cx-ty*_height,cy+tx*_height), CCPoint(cx-_baseLength/2*tx,cy-_baseLength/2*ty) }; ccDrawPoly(points, sizeof(points)/sizeof(points[0]), true); }
void m_Polygon::updateNormals() { for(int i=0; i < numVerticies; i++) { vector2f diff = getVertex(i) - getVertex(i + 1); float temp = diff.x; diff.x = diff.y; diff.y = -temp; if(!isClockwise()) diff *= -1; normals[i] = diff.normalized(); } }
void Polygon::odbOutputLayerFeature( OdbFeatureFile& file, QPointF location, Xform *xform, PolygonType type) { // island == POLYGON (must clockwise), hole == CUTOUT (must counter clockwise) bool clockwise = isClockwise(); if ((type == POLYGON && clockwise) || (type == CUTOUT && !clockwise)) { odbOutputFeature(file, location, xform, type, FORWARD); } else { odbOutputFeature(file, location, xform, type, REVERSE); } }