aseprite / aseprite/api

useTool ellipse should support rotation

Open
#17 0 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
No language data
Stars
307
Forks
68
PR merge metrics
No merged PRs in 30d

Description

goal: use ellipse tool to generate a sort of spinning ring effect:

![spinning_ring_effect](https://user-images.githubusercontent.com/24925338/59150518-89471380-89ea-11e9-92a0-b07a5ee7dc2b.gif)

To achieve this, I need to be able to specify an angle somehow for the ellipse tool.
At present, there is no way to specify modifiers for any points in a `useTool` call.

For my own education, I have tried to trace how this is achieved in a regular (non-script) workflow. Not sure how accurate it is:

1. A user presses the correct modifier key ('alt' by default on windows, I think)
2. `Editor::onProcessMessage` is called, which calls
3. `Editor::updateToolLoopModifiersIndicators` which calls
4. `AppEditor::getPressedKeyAction` which calls
5. `KeyboardShortcuts::getCurrentActionModifiers` which checks to see if any relevant keys are pressed.
6. Since in this case, there is a new modifier key pressed, `Editor::updateToolLoopModifiersIndicators` also calls
7. `DrawingState::notifyToolLoopModifiersChange`, which calls
8. `ToolLoopManager::notifyToolLoopModifiersChange`, which calls
9. `ToolLoopManager::movement` with the same pointer (not c++ pointer, aseprite `tools::Pointer`) as was last used. It calls
10. the tool loop's controller's `movement` method, which checks the tool loop modifiers and sets the angle (assuming it's a `TwoPointsController`, which I guess is what is used for the ellipse tool?). `ToolLoopManager::movement` also calls
11. `ToolLoopManager::doLoopStep` which calls
12. `joinStroke` on the tool loop's intertwine, which for the ellipse tool is `IntertwineAsEllipses` (I guess?), and that calls
13. `draw_rotated_ellipse` using the angle from the loop's controller.

Something like that, anyway.

One approach would be:
1. Expose the `TwoPointsController`'s angle field, which is currently private, to the tool loop or tool loop manager.
2. Check for an optional `angle` argument in `App_useTool` when the tool is an ellipse. If it is present, set the controller angle to that value. We'd have to be careful that the angle is not accidentally overwritten at some point, I'm not sure all the ways that can happen.

This approach seems a bit blunt, and doesn't really support the idea that script writers should have a generic way to apply modifiers as necessary. Maybe a different title for this issue could be "useTool should support tool loop modifiers" but I don't know where I would even start to work on something like that.

This is the first time I've actually looked through aseprite's code base, apologies if I'm missing something obvious or completely off the mark.

Thoughts?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing App_useTool into the ToolLoopManager and TwoPointsController paths described in the issue, then inspect how IntertwineAsEllipses reaches draw_rotated_ellipse. Determine whether the API should expose an ellipse angle or generic tool-loop modifiers, and verify that the requested useTool call preserves the modifier through drawing. Done means scripted ellipse use can produce the rotated effect shown.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.