-
Notifications
You must be signed in to change notification settings - Fork 5
template changes #15
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
base: master
Are you sure you want to change the base?
template changes #15
Conversation
| } | ||
|
|
||
| /// <summary> | ||
| /// Calculates the absolute Difference from two equal-sized images with equal channel count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// Calculates the absolute Difference from two equal-sized images with equal channel count | |
| /// Calculates the absolute difference |a - b| of two equal-sized images with equal channel count |
| /// <summary> | ||
| /// Returns a image from the list images | ||
| /// </summary> | ||
| /// <param name="index"></param> | ||
| /// <returns></returns> | ||
| public (string Name, Image Image, DataType TargetType, InitialTMO TMOOverride) GetImage(int index) { | ||
| return images[index]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the long tuple, it would be better to define a struct that contains name, image, etc and return that here.
Instead or in addition to GetImage this could be an indexer.
Sth like
public struct ImageEntry
{
public string Name;
// ...
}
public ImageEntry this[int index] => images[index];| /// <summary> | ||
| /// Sets the key of this flipbook to keep track on the react side of all flipbooks | ||
| /// Same thing as a group name but this key can decide which flipbook of a group fired a listener to the c# side | ||
| /// </summary> | ||
| /// <param name="key">Key for the dictionary on React side</param> | ||
| public FlipBook SetKey(int[] key) { | ||
| this.key = key; | ||
| return this; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear what this does. Since this is public API, we'll need to define what the purpose of the key is and why it is an array of integers.
Does it need a specific convention? -- Define
Is it arbitrary and up to the user? -- Why the int array instead of sth more intuitive like a string?
| if (String.IsNullOrEmpty(this.containerId)) | ||
| this.containerId = id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you only store it the first time?
Seems like this could yield confusing behavior if the same flip book is generated multiple times.
|
|
||
| // string json = $$""" | ||
| // { | ||
| // "width": {}, | ||
| // "height": {}, | ||
| // "containerId": "{}", | ||
| // "initialZoom": {}, | ||
| // "initialTMO": {}, | ||
| // "initialTMOOverrides": [ | ||
| // {} | ||
| // ], | ||
| // "names": [{{string.Join(',', nameStrs.Select(n => $"\"{n}\""))}}], | ||
| // "dataUrls": [{{string.Join(',', dataStrs.Select(n => $"\"{n}\""))}}], | ||
| // "types": [{{string.Join(',', typeStrs.Select(n => $"\"{n}\""))}}], | ||
| // "colorTheme": "{}", | ||
| // "groupName": "{{groupName}}", | ||
| // "hideTools": {} | ||
| // } | ||
| // """; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // string json = $$""" | |
| // { | |
| // "width": {}, | |
| // "height": {}, | |
| // "containerId": "{}", | |
| // "initialZoom": {}, | |
| // "initialTMO": {}, | |
| // "initialTMOOverrides": [ | |
| // {} | |
| // ], | |
| // "names": [{{string.Join(',', nameStrs.Select(n => $"\"{n}\""))}}], | |
| // "dataUrls": [{{string.Join(',', dataStrs.Select(n => $"\"{n}\""))}}], | |
| // "types": [{{string.Join(',', typeStrs.Select(n => $"\"{n}\""))}}], | |
| // "colorTheme": "{}", | |
| // "groupName": "{{groupName}}", | |
| // "hideTools": {} | |
| // } | |
| // """; |
| var relX = event.nativeEvent.offsetX;: nativeEvent. | ||
| var relY = event.nativeEvent.offsetY;: nativeEvent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened here?
| if (this.props.onWheel) | ||
| { | ||
| this.props.onWheel(event.deltaY); | ||
| } | ||
|
|
||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not tested, but sounds like quite awkward UX to have ALT as a means to override the zoom behavior but also then forward this wheel event in the flip book context?
| let work: Promise<Float32Array | HTMLImageElement>[] = []; | ||
| for (let i = 0; i < data.dataUrls.length; ++i) { | ||
| let loadFn; | ||
| switch (data.types[i]) { | ||
| case ImageType.Single: loadFn = readFloat; break; | ||
| case ImageType.Half: loadFn = readHalf; break; | ||
| case ImageType.Rgbe: loadFn = readRGBE; break; | ||
| case ImageType.Ldr: loadFn = readLDR; break; | ||
| case ImageType.Float32Array: loadFn = (data: Float32Array) => data; break; | ||
| default: console.error(`unsupported type: ${data.types[i]}`); | ||
| } | ||
| work.push(loadFn(data.dataUrls[i])); | ||
| } | ||
| let images = await Promise.all(work); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code duplication should be eliminated
| const book = ref.current; | ||
|
|
||
| if(!book) | ||
| continue; | ||
|
|
||
| const tms = book.props.toneMappers; | ||
| tms[book.state.selectedIdx].setPixels(images[0] as (Float32Array<ArrayBufferLike>)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you safely assume f32 data here?
| tms[book.state.selectedIdx].setPixels(images[0] as (Float32Array<ArrayBufferLike>)); | ||
| } | ||
|
|
||
| // flipBook.imageContainer.current.props.rawPixels[flipBook.state.selectedIdx] = images[0] as (Float32Array<ArrayBufferLike>); //TODO: maybe it doesnt work like that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
No description provided.