/tmp/duangsuse.sock
23 subscribers
303 photos
3 videos
92 files
337 links
从 duangsuse::Echo (@dsuse) 跟进出来的分支,将在作者恢复原帐号访问的时候合并删除。
Download Telegram
Forwarded from Pani Ram
Q(x0+d*cos(theta), y0+d*sin(theta))
Forwarded from Pani Ram
theta 是弧度值的
Forwarded from Pani Ram
deg2rad _deg = _deg / 180.0 * _PI
Forwarded from Deleted Account
艹好像失败了
Forwarded from Deleted Account
看起来好像还是不对……算了吧 90+30 度……
Forwarded from Deleted Account
修好 bug,75 行终于弄成了,感动 😥
Forwarded from Deleted Account
KochHill.kt
2.1 KB
@iseki 我的基础工作已经做完了,你可以继续下去,画那个分形了啊 🌝 (注:感谢 @DuckSoft 大佬提供的公式)
Turtle.kt
2.3 KB
#Kotlin #code 画画的程序 当然只是核心部分
import kotlin.math.sin
import kotlin.math.cos
import kotlin.math.PI

protected fun forward(distance: Double) {
val pA = position
val distanceAB = distance.distanceDegree(rotation)
val pB = pA + distanceAB
canvas.drawLine(pA.x, pA.y, pB.x, pB.y)
position.assign(pB)
}
private fun Double.distanceDegree(rotation: Deg): Point2 {
val d = this; val r = rotation.coerceRad()
return Point( (d*cos(r)).toInt(), (d*sin(r)).toInt() )
}

最核心的科技
protected var rotation: Deg get() = rawRotation*FULL_DEG
set(d) { rawRotation = d/FULL_DEG }
protected fun rotate(deg: Double) { rotation += deg }
protected fun forward(distance: Double) {
val pA = position
val distanceAB = distance.lineDegreed(rotation)
val pB = pA + distanceAB
canvas.drawLine(pA.x, pA.y, pB.x, pB.y)
position.assign(pB)
}
private fun Double.lineDegreed(rotation: Deg): Point2 {
val d = this; val r = rotation.coerceRad()
return Point( (d*cos(r)).toInt(), (d*sin(r)).toInt() )
}
/** Coerce to radix from degree */
fun Deg.coerceRad() = this / 180.0 * PI
Turtle.kt
2.6 KB
#Kotlin #code Turtle 最终版本。“我真的不更了”——duangsuse
“我们就是死,也不会再多编辑一次的。”——duangsuse
Forwarded from KU 39
修复了一个关于 rotate 的 bug,看起来现在不错哦
新的 Turtle 基本操作
Turtle.kt
2.9 KB
#Kotlin #code 又更新了一次
Turtle.kt
4.1 KB
最后一次了!下次就是带脚本语言的版本了! #Kotlin #code
/tmp/duangsuse.sock
#GithHub 这么好玩的东西,我没精力维护就直接堆 Share 了,也真是可惜(迫真)
说起来,现在 Share 还没人打星,谁愿意抢个前排???(
本苏可是做好了包装哦,
LICENSE README.md .gitignore
三 大 文 件 缺一不可