Go to file
Damien Elmes 7f6c410ca5
Various changes to I/O handling (#2513)
* Store coordinates as ratios of full size

* Use single definition for cappedCanvasSize()

* Move I/O review code into ts/image-occlusion

A bit simpler when it's all in one place.

* Reduce number precision, and round to whole pixels

>>> n=10000
>>> for i in range(1, int(n)): assert i == round(float("%0.4f" % (i/n))*n)

* Minor typing tweak

So, it turns out that typing is mostly broken in ts/image-occlusion.
We're importing from fabric which is a js file without types, so types
like fabric.Canvas are resolving to any.

I first tried switching to `@types/fabric`, which introduced a slew of
typing errors. Wasted a few hours trying to address them, before deciding
to give up on it, since the types were not complete. Then found fabric
has a 6.0 beta that introduces typing, and spent some time with that, but
ran into some new issues as it still seems to be a work in progress.
I think we're probably best off waiting until it's out and stabilized
before sinking more effort into this.

* Refactor (de)serialization of occlusions

To make the code easier to follow/maintain, cloze deletions are now decoded/
encoded into simple data classes, which can then be converted to Fabric objects
and back. The data objects handle converting from absolute/normal positions, and
producing values suitable for writing to text (eg truncated floats).

Various other changes:

- Polygon points are now stored as 'x,y x2,y2 ...' instead of JSON in cloze
divs, as that makes the handling consistent with reading from cloze deletion
text.
- Fixed the reviewer not showing updated placement when a polygon was moved.
- Disabled rotation controls in the editor, since we don't support rotation during
review.
- Renamed hideInactive to occludeInactive, as it wasn't clear whether the former
meant to hide the occlusions, or keep them (hiding the content). It's stored
as 'oi=1' in the cloze text.

* Increase canvas size limit, and double pixels when required.

* Size canvas based on container size

This results in sharper masks when the intrinsic image size is smaller
than the container, and more legible ones when the container is smaller than
the intrinsic image size.

By using the container instead of the viewport, we account for margins,
and when the pixel ratio is 1x, the canvas size and container size should
match.

* Disable zoom animation on editor load

* Default to rectangle when adding new occlusions

* Allow users to add/update notes directly from mask editing page

* The mask editor needs to work with css pixels, not actual pixels

The canvas and image were being scaled too large, which impacted
performance.
2023-05-31 13:45:12 +10:00
.buildkite Detect incorrect usage of triple slash in TypeScript (#2524) 2023-05-26 12:49:44 +10:00
.cargo Opt in to new sparse index handling 2023-05-29 12:35:08 +10:00
.config Update Rust deps 2023-03-31 14:38:24 +10:00
.github/ISSUE_TEMPLATE Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.vscode.dist Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
build Various changes to I/O handling (#2513) 2023-05-31 13:45:12 +10:00
cargo Update hakari and licenses 2023-05-29 17:54:00 +10:00
docs Mention that checkout path should not include spaces 2023-05-01 15:39:03 +10:00
ftl Update translations 2023-05-29 13:36:07 +10:00
proto Various tweaks to I/O code (#2478) 2023-04-19 15:30:18 +10:00
pylib Improve import messaging when notetype has changed (#2483) 2023-04-28 11:39:18 +10:00
python Update requests for CVE 2023-05-24 16:09:15 +10:00
qt Add add-on installation hooks (#2523) 2023-05-29 19:47:49 +10:00
rslib Various changes to I/O handling (#2513) 2023-05-31 13:45:12 +10:00
sass Fix unreadable bootstrap buttons when hovering 2023-05-09 17:04:12 +10:00
tools Update hakari and licenses 2023-05-29 17:54:00 +10:00
ts Various changes to I/O handling (#2513) 2023-05-31 13:45:12 +10:00
.deny.toml Update Rust deps (#2332) 2023-01-18 22:24:29 +10:00
.dprint.json Update Chrono Crate (#2242) 2022-12-07 17:00:14 +10:00
.eslintrc.js Upgrade Svelte (#2506) 2023-05-18 17:04:58 +10:00
.gitattributes try again to improve GitHub's language stats 2021-01-20 13:20:45 +10:00
.gitignore Rework syncing code, and replace local sync server (#2329) 2023-01-18 12:43:46 +10:00
.gitmodules Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.isort.cfg Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.mypy.ini Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.prettierignore Improved add-on extension API (#1626) 2022-02-03 14:52:11 +10:00
.prettierrc Mathjax editor improvements (#1502) 2021-11-23 10:27:32 +10:00
.pylintrc Add ability to restore a notetype to its original configuration (#2472) 2023-04-18 14:07:51 +10:00
.rustfmt-empty.toml Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
.rustfmt.toml Move ascii_percent_encoding into a separate repo 2023-04-12 08:45:23 +10:00
.version Bump version 2023-05-24 16:07:43 +10:00
Cargo.lock Update hakari and licenses 2023-05-29 17:54:00 +10:00
Cargo.toml Detect incorrect usage of triple slash in TypeScript (#2524) 2023-05-26 12:49:44 +10:00
CONTRIBUTORS Making phrasing more clear in dialog which lets user choose a deck to display options for. (#2522) 2023-05-26 12:50:38 +10:00
LICENSE move aqt_data into source folder; implement wheel building 2020-11-04 12:14:03 +10:00
ninja Add env var to enable sourcemaps 2022-12-04 11:37:16 +10:00
package.json Update to the latest TypeScript version 2023-04-12 16:42:28 +10:00
pkgkey.asc
README.md fix build badge 2021-06-24 09:21:56 +10:00
run Move away from Bazel (#2202) 2022-11-27 15:24:20 +10:00
run.bat Automatically fetch win32 audio tools in .\run.bat 2023-05-11 09:10:22 +10:00
rust-toolchain.toml Bump Rust version 2023-03-31 14:11:33 +10:00
SECURITY.md add SECURITY.md 2021-09-22 22:55:19 +10:00
yarn.lock Upgrade Svelte (#2506) 2023-05-18 17:04:58 +10:00

Anki

Build status

This repo contains the source code for the computer version of Anki.

If you'd like to try development builds of Anki but don't feel comfortable building the code, please see https://betas.ankiweb.net/

For more information on building, please see Development.