Anki/proto/anki/image_occlusion.proto
Aristotelis c828a2eb6f
Add APIs for IO card rendering (#2739)
* Refactor: Add index to shapes package

* Add shape draw callback API to setupImageCloze

* Expose IO drawing API, switch away from image cloze naming

We currently use "image occlusion" in most places, but some references to "image cloze" still remain. For consistency's sake and to make it easier to quickly find IO-related code, this commit replaces all remaining references to "image cloze", only maintaining those required for backwards compatibility with existing note types.

* Add cloze ordinal to shapes

* Do not mutate original shapes during (de)normalization

Mutating shapes would be a recipe for trouble when combined with IO API use by external consumers.

(makeNormal(makeAbsolute(makeNormal())) is not idempotent,
and keeping track of the original state would introduce
additional complexity with no discernible performance benefit
or otherwise.)

* Tweak IO API, allowing modifications to ShapeProperties

* Tweak drawShape parameters

* Switch method order

For consistency with previous implementation

* Run Rust formatters

* Simplify position (de)normalization

---------

Co-authored-by: Glutanimate <glutanimate@users.noreply.github.com>
2023-10-20 09:36:46 +10:00

102 lines
2.5 KiB
Protocol Buffer

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
syntax = "proto3";
option java_multiple_files = true;
package anki.image_occlusion;
import "anki/collection.proto";
import "anki/generic.proto";
service ImageOcclusionService {
rpc GetImageForOcclusion(GetImageForOcclusionRequest)
returns (GetImageForOcclusionResponse);
rpc GetImageOcclusionNote(GetImageOcclusionNoteRequest)
returns (GetImageOcclusionNoteResponse);
rpc GetImageOcclusionFields(GetImageOcclusionFieldsRequest)
returns (GetImageOcclusionFieldsResponse);
// Adds an I/O notetype if none exists in the collection.
rpc AddImageOcclusionNotetype(generic.Empty) returns (collection.OpChanges);
// These two are used by the standalone I/O page, but not used when using
// I/O inside Anki's editor
rpc AddImageOcclusionNote(AddImageOcclusionNoteRequest)
returns (collection.OpChanges);
rpc UpdateImageOcclusionNote(UpdateImageOcclusionNoteRequest)
returns (collection.OpChanges);
}
// Implicitly includes any of the above methods that are not listed in the
// backend service.
service BackendImageOcclusionService {}
message GetImageForOcclusionRequest {
string path = 1;
}
message GetImageForOcclusionResponse {
bytes data = 1;
string name = 2;
}
message AddImageOcclusionNoteRequest {
string image_path = 1;
string occlusions = 2;
string header = 3;
string back_extra = 4;
repeated string tags = 5;
int64 notetype_id = 6;
}
message GetImageOcclusionNoteRequest {
int64 note_id = 1;
}
message GetImageOcclusionNoteResponse {
message ImageOcclusionProperty {
string name = 1;
string value = 2;
}
message ImageOcclusion {
string shape = 1;
repeated ImageOcclusionProperty properties = 2;
}
message ImageOcclusionNote {
bytes image_data = 1;
repeated ImageOcclusion occlusions = 2;
string header = 3;
string back_extra = 4;
repeated string tags = 5;
}
oneof value {
ImageOcclusionNote note = 1;
string error = 2;
}
}
message UpdateImageOcclusionNoteRequest {
int64 note_id = 1;
string occlusions = 2;
string header = 3;
string back_extra = 4;
repeated string tags = 5;
}
message GetImageOcclusionFieldsRequest {
int64 notetype_id = 1;
}
message GetImageOcclusionFieldsResponse {
ImageOcclusionFieldIndexes fields = 1;
}
message ImageOcclusionFieldIndexes {
uint32 occlusions = 1;
uint32 image = 2;
uint32 header = 3;
uint32 back_extra = 4;
}