Comments (7)
(i say that because you change the cursor callback, which i highly suspect to be currently wrong)
from drawing.
While i agree it looks better, it is not be possible currently, so this issue might stay opened for years
from drawing.
Is it possible now? If you start drawing it looks strange.
from drawing.
The issue doesn't look closed
from drawing.
You can use cairo_context_translate()
in your on_draw()
to translate the canvas to the center. Here I added to the example I posted in issue #121.
def on_draw(self, area, cairo_context):
"""Signal callback. Executed when self.drawing_area is redrawn."""
surface = self.get_surface()
allocation = self.get_allocation()
width = allocation.width
height = allocation.height
image_width = surface.get_width()
image_height = surface.get_height()
# Fill background with a color
cairo_context.new_path()
cairo_context.set_source_rgb(1, 0, 0)
cairo_context.move_to(0, 0)
cairo_context.rel_line_to(height, 0)
cairo_context.rel_line_to(height, width)
cairo_context.rel_line_to(0, width)
cairo_context.close_path()
cairo_context.fill()
cairo_context.paint()
# Draw the image on top
cairo_context.translate((width / 2) - (image_width / 2), (height / 2) - (image_height / 2))
cairo_context.scale(self.zoom_level, self.zoom_level)
cairo_context.set_source_surface(surface, \
-1 * self.scroll_x, -1 * self.scroll_y)
cairo_context.paint()
self.active_tool().on_draw(area, cairo_context)
Then all the coordinates in the cursor callbacks need to be updated like this:
event_x, event_y = self.get_event_coords(event)
allocation = self.get_allocation()
width = allocation.width
height = allocation.height
surface_width = self.surface.get_width()
surface_height = self.surface.get_height()
event_x -= (width - surface_width) / 2
event_y -= (height - surface_height) / 2
I tested it out locally. Here are the results:
Let me know if you'd like me to open a pull request. :)
from drawing.
i wanted to think about this issue once the zoom will work entirely as i expect, but if you already have a solution and you don't see any major bug when you zoom in or out, or when the image is bigger than the window, you can open a PR now
from drawing.
gotcha. I will hold off on this PR then until the callbacks are in a known working state.
from drawing.
Related Issues (20)
- Eyedropper tool in color palette doesn't work HOT 1
- Clipboard from command line throws error. HOT 2
- Subtle color changes when saving without transparency
- Finally fixing the paint bucket tool
- Basic features HOT 1
- GNOME 43 runtime is no longer supported as of September 20 2023 HOT 3
- Show rectangle selection size in user interface HOT 1
- Bad parsing of Command Line arguments HOT 1
- Auto expand canvas to pasted / imported image size if it exceeds the default canvas size.
- color picker from screen doesnt work HOT 2
- Add custom preview to the GtkFileChooser
- Persistant window size HOT 3
- Save-on-exit prompt option HOT 4
- "Scale" settings don't stay set (keep proportions)
- if you apply paint to the area that you drew with a pencil, it will not be completely painted over
- font size limited to 80 px HOT 1
- Report a bug link
- Drawing still uses GNOME Circle branding
- Translation issue Fr HOT 3
- [Line tool] Bind SHIFT and ALT shortcuts at on_motion_on_area() as well HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drawing.