使用 creativescala 书中的涂鸦时,我无法以递归方法将图像旋转 180 度

While using doodle from creativescala book I can't get my Image rotated by 180 degrees in recursive method

我正在学习 Scala 中的函数式编程,但我做不到。

def lel2(bids: List[Double], vols: List[Double]): Image = {
  bids.size match {
    case 0 => Image.empty
    case n => Image.triangle(asks(n-1), vols(n-1))
      .transform(Transform.rotate(180.degrees)).above(lel2(bids.init, vols.init))
  }
}

唯一的依赖是 "org.creativescala" %% "doodle" % "0.9.20",导入是 import doodle.core._; import doodle.image._; import doodle.image.syntax._; import doodle.image.syntax.core._; import doodle.java2d._

我想要做的是输出一个三角形的旋转图像,如果这是正确的术语,水平翻转:)

我也用这个List[Double]的:

List[Double] = List(9.963005799312612, 9.964236205100441, 9.96497444857314, 9.972931072667766, 9.97317715382533, 9.979821345079607, 9.988352158541886, 10.0)

List[Double] = List(0.5617977528089887, 0.42134831460674155, 4.213483146067415, 0.5168539325842696, 0.5168539325842696, 2.6235955056179776, 2.1067415730337076, 10.0)

相关链接:

Transform docs

CreativeScala book

Doodle module

你应该在 Image.triangle(x, xx) 两边加上另一个括号来这样转换它

(Image.triangle(bids(n-1), vols(n-1))).transform(Transform.rotate(180.degrees))