如何在 c++ 中从 rosettacode 调用这个吴晓林的直线算法
How to calling this Xiaolin Wu's line algorithm from rosettacode in c++
我正在尝试调用吴的线性算法。我从rosettacode.org上找到了一个版本,但我不知道如何称呼它。
以下是链接:https://rosettacode.org/wiki/Xiaolin_Wu%27s_line_algorithm#C.2B.2B
我不理解的这个部分
const std::function<void(int x, int y, float brightness)>& plot
你能给我举个调用这个函数的例子吗。
这只是意味着最后一个参数是一个在给定坐标和所需亮度的情况下绘制点的函数。
它允许不同的风格,例如使用函数指针或lambdas。
void my_plot(int x, int y, float brightness) {
// plot things
}
int main() {
WuDrawLine(0, 0, 100, 256, my_plot);
WuDrawLine(0, 100, 0, 256, [](int x, int y, float brightness) { /*do stuff*/ });
return 0;
}
相关文章:
- 为什么这个运算符<重载函数对 STL 算法不可见?
- 基于ELO的团队匹配算法
- C++选择排序算法中的逻辑错误
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- 有没有办法将谓词中的元素偏移量传递给 std 算法?
- C++A*算法并不总是在路径中具有目标节点
- 排序算法c++
- 构建可组合有向图(扫描仪生成器的汤普森构造算法)
- 算法问题:查找从堆栈中弹出的所有序列
- 下面是排序算法O(n)吗
- KMP算法和LPS表构造的运行时间
- 为什么我的排序算法会更改数组值
- 求最大元素位置的分治算法
- 具有非整数边容量的最大流量的Dinic算法
- 到连接组件算法的问题(递归)
- STL算法函数在多个一维容器上的使用
- 读取最后一行代码算法 - c++ 时出现问题
- 括号更改 O(n) 算法
- std::unordered_map 搜索算法是如何实现的?
- 如何在 c++ 中从 rosettacode 调用这个吴晓林的直线算法