Blame view

ios/Runner/Wowgame/Classes/game_toy/ToyDrawingUtils.cpp 1.73 KB
5daad4bc   xiaoyu   游戏源码添加编译(现存问题:游戏内...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  //
  //  ToyDrawingUtils.cpp
  //  SteveMaggieCpp
  //
  //  Created by Katarzyna Kalinowska-Górska on 20.05.2017.
  //
  //
  
  #include <stdio.h>
  #include "ToyDrawingUtils.h"
  #include "ToyGeometryUtils.h"
  
  //TODO: this is not so needed here, maybe for thinner lines in scribbles. but it needs to be improved, because it causes android to get stuck.
  std::vector<cocos2d::Point> ToyDrawingUtils::calculateSmoothLinePoints(std::vector<cocos2d::Point> threeLastPoints)
  {
  //    if(threeLastPoints.size() != 3){
  ////        log("ToyDrawingUtils: calculateSmoothLinePoints: argument should be an array with exactly three elements");
  //        return threeLastPoints;
  //    }
  //
  //    std::vector<cocos2d::Point> smoothedPoints;
  //
  //    auto point1 = threeLastPoints[0], point2 = threeLastPoints[1], point3 = threeLastPoints[2];
  //
  //    auto midPoint1 = point1.getMidpoint(point2);
  //    auto midPoint2 = point2.getMidpoint(point3);
  //
  //    auto distance = midPoint1.distance(midPoint2);
  //    auto segmentDistance = 2; //2 pixels
  //    auto numberOfSegments = MIN(128, MAX(floor(distance / segmentDistance), 32));
  //
  //    float t = 0;
  //    float step = 1 / numberOfSegments;
  //
  //    for(int i = 0; i < numberOfSegments; ++i){
  //
  //        std::vector<cocos2d::Point> argumentPoints;
  //        auto p1 = midPoint1 * (1-t)*(1-t);
  //        auto p2 = point2 * t*(1-t)*2;
  //        auto p3 = midPoint2 * t*t;
  //        argumentPoints.push_back(p1);
  //        argumentPoints.push_back(p2);
  //        argumentPoints.push_back(p3);
  //
  //        auto newPoint = ToyGeometryUtils::addPoints(argumentPoints);
  //
  //        smoothedPoints.push_back(newPoint);
  //        t += step;
  //    }
  //
  //    smoothedPoints.push_back(midPoint2);
  
  //    return smoothedPoints;
      return threeLastPoints;
  }