Skip to content

fix flip button #307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/notebooks/simple.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"source": [
"**Use the handle on the bottom right corner of the _canvas_ to resize it. You can also pan and zoom using your mouse!**\n",
"\n",
"By default the origin is on the bottom left, you can click the flip button to flip the y-axis, or use `plot.camera.world.scale_y *= -1`"
"By default the origin is on the bottom left, you can click the flip button to flip the y-axis, or use `plot.camera.local.scale_y *= -1`"
]
},
{
Expand All @@ -120,7 +120,7 @@
},
"outputs": [],
"source": [
"plot.camera.world.scale_y *= -1"
"plot.camera.local.scale_y *= -1"
]
},
{
Expand Down Expand Up @@ -464,7 +464,7 @@
},
"outputs": [],
"source": [
"plot_rgb.camera.world.scale_y *= -1"
"plot_rgb.camera.local.scale_y *= -1"
]
},
{
Expand Down
10 changes: 7 additions & 3 deletions fastplotlib/layouts/_gridplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ def __init__(self, plot: GridPlot):
self.flip_camera_button = Button(
value=False,
disabled=False,
icon="arrows-v",
icon="arrow-up",
layout=Layout(width="auto"),
tooltip="flip",
tooltip="y-axis direction",
)

self.record_button = ToggleButton(
Expand Down Expand Up @@ -490,7 +490,11 @@ def maintain_aspect(self, obj):

def flip_camera(self, obj):
current = self.current_subplot
current.camera.world.scale_y *= -1
current.camera.local.scale_y *= -1
if current.camera.local.scale_y == -1:
self.flip_camera_button.icon = "arrow-down"
else:
self.flip_camera_button.icon = "arrow-up"

def update_current_subplot(self, ev):
for subplot in self.plot:
Expand Down
8 changes: 6 additions & 2 deletions fastplotlib/layouts/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def __init__(self, plot: Plot):
self.flip_camera_button = Button(
value=False,
disabled=False,
icon="arrows-v",
icon="arrow-up",
layout=Layout(width="auto"),
tooltip="flip",
)
Expand Down Expand Up @@ -224,7 +224,11 @@ def maintain_aspect(self, obj):
self.plot.camera.maintain_aspect = self.maintain_aspect_button.value

def flip_camera(self, obj):
self.plot.camera.world.scale_y *= -1
self.plot.camera.local.scale_y *= -1
if self.plot.camera.local.scale_y == -1:
self.flip_camera_button.icon = "arrow-down"
else:
self.flip_camera_button.icon = "arrow-up"

def add_polygon(self, obj):
ps = PolygonSelector(edge_width=3, edge_color="magenta")
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy