Updated quickstart.
@@ -51,11 +51,18 @@ Note: Use the file `debugging.h` to add some debugging features to the C interfa
The following listing uses the C++ wrapper to give a short example of TinySpline:
```c
-// Create a clamped spline of degree 3 in 2D consisting of 7 control points.
-ts::BSpline spline(3, 2, 7, TS_CLAMPED);
-
-// Setup the control points.
-std::vector<float> ctrlp = spline.ctrlp();
+#include <iostream>
+#include "tinysplinecpp.h"
+
+int main(int argc, char **argv)
+{
+ // Create a cubic spline with 7 control points in 2D using
+ // a clamped knot vector. This call is equivalent to:
+ // tinyspline::BSpline spline(7, 2, 3, TS_CLAMPED);
+ tinyspline::BSpline spline(7);
+
+ // Setup control points.
+ std::vector<tinyspline::real> ctrlp = spline.ctrlp();
ctrlp[0] = -1.75f; // x0
ctrlp[1] = -1.0f; // y0
ctrlp[2] = -1.5f; // x1
@@ -72,16 +79,22 @@ ctrlp[12] = 0.5f; // x6
ctrlp[13] = 0.0f; // y6
spline.setCtrlp(ctrlp);
-// Evaluate `spline` at u = 0.4
-std::vector<float> result = spline.evaluate(0.4f).result();
+ // Stores our evaluation results.
+ std::vector<tinyspline::real> result;
+
+ // Evaluate `spline` at u = 0.4 using 'evaluate'.
+ result = spline.evaluate(0.4f).result();
std::cout << "x = " << result[0] << ", y = " << result[1] << std::endl;
// Derive `spline` and subdivide it into a sequence of Bezier curves.
-ts::BSpline beziers = spline.derive().toBeziers();
+ tinyspline::BSpline beziers = spline.derive().toBeziers();
-// Evaluate `beziers` at u = 0.3
-result = beziers(0.3f).result(); // you can use '()' instead of 'evaluate'
+ // Evaluate `beziers` at u = 0.3 using '()' instead of 'evaluate'.
+ result = beziers(0.3f).result();
std::cout << "x = " << result[0] << ", y = " << result[1] << std::endl;
+
+ return 0;
+}
```
### Installation
