Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 285431d

Browse files
authored
Merge pull request #840 from androidx/add_plotTool
adding plot tool
2 parents 357845b + 54e8f9e commit 285431d

36 files changed

+7848
-0
lines changed

desktop/PlotTool/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/PlotTool/.idea/kotlinc.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

desktop/PlotTool/.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import androidx.constraintlayout.desktop.graph.GraphEngine
2+
import androidx.constraintlayout.desktop.graph.Utils
3+
import java.awt.Color
4+
import kotlin.math.cos
5+
import kotlin.math.sin
6+
7+
fun main(args: Array<String>) {
8+
val frame = Utils.smartFrame("Simple k Plot")
9+
val p = GraphEngine.setupFrameWidthControls(frame, "wave")
10+
val min = -Math.PI
11+
val max = Math.PI
12+
p.addFunction("sin", min, max, Color.BLUE) { x -> sin(x) }
13+
p.addVelocity("dsin", min, max, Color.GREEN) { x -> sin(2 * x) }
14+
p.addFunction2("cos", min, max, Color.RED) { a -> cos(a) }
15+
p.addFunction2d("circle", min, max, Color.PINK,
16+
{ t -> Math.cos(t) },
17+
{ t -> Math.sin(t*2) })
18+
val x = DoubleArray(20)
19+
val y = DoubleArray(x.size)
20+
for (i in y.indices) {
21+
val t = min + i * (max - min) / y.size
22+
x[i] = Math.sin(t)
23+
y[i] = 2 * Math.cos(t)
24+
}
25+
p.addPoints("points", Color.WHITE, x, y)
26+
frame.isVisible = true
27+
}

0 commit comments

Comments
 (0)