Skip to content

Commit

Permalink
simplified slider
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jun 11, 2024
1 parent 6f2452a commit 7055ce6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/sidedock.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from compas.geometry import Box
from compas.geometry import Translation
from compas_viewer import Viewer
from compas_viewer.components import Button
from compas_viewer.components import Slider

box = Box(1)

viewer = Viewer()

box = Box(1, 1, 1)
boxobj = viewer.scene.add(box)


Expand All @@ -23,13 +25,13 @@ def slider_changed(slider: Slider, value: int):

v = (value - vmin) / (vmax - vmin)

boxobj.item.frame.point.x = v * 10

boxobj.transformation = Translation.from_vector([10 * v, 0, 0])
boxobj.update()
viewer.renderer.update()


viewer.ui.sidedock.show = True
viewer.ui.sidedock.add(Button(text="Toggle Box", action=toggle_box))
viewer.ui.sidedock.add(Slider(title="test", min_val=0, max_val=100, action=slider_changed))

viewer.show()

0 comments on commit 7055ce6

Please sign in to comment.