Skip to content
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

System.Drawing.Color #141

Merged
merged 34 commits into from
Jul 2, 2020
Merged

System.Drawing.Color #141

merged 34 commits into from
Jul 2, 2020

Conversation

charlesroddie
Copy link
Collaborator

@charlesroddie charlesroddie commented Jun 25, 2020

Reduce code by removing a Color structure that duplicates System.Drawing.Color. Presumably this predated netstandard.

@charlesroddie
Copy link
Collaborator Author

charlesroddie commented Jun 25, 2020

@Happypig375 What is the purpose of the NoEnhancedColors setting? If NoEnhancedColors is true, you cannot use #... or 0x... to define Colors. Is there reason for setting NoEnhancedColors to true? If not we can remove this setting and simplify a bit of code.

@Happypig375
Copy link
Collaborator

It's not standard LaTeX. We should follow wpf-math's \color here.

@Happypig375
Copy link
Collaborator

I don't like the name ColouredAtom. This name is inconsistent with all other atom types. I'd rather have it be referred to as Atoms.Color and System.Drawing.Color as Color.

@charlesroddie
Copy link
Collaborator Author

charlesroddie commented Jun 25, 2020

Yes I agree ColoredAtom is too long. As I was editing I could see there is something similar to RequireQualifiedAccess on these so there is duplication in the longer name.

I think Atoms.Colored is better than Atoms.Color.

@Happypig375
Copy link
Collaborator

Colored is fine by me.

@Happypig375 Happypig375 marked this pull request as draft June 25, 2020 13:55
@Happypig375 Happypig375 changed the title [WIP] System.Drawing.Color System.Drawing.Color Jun 25, 2020
@Happypig375
Copy link
Collaborator

Also note that I'm currently refactoring LaTeXParser, see the ParserRefactor branch. So please refrain from large changes across LaTeXParser.

@charlesroddie
Copy link
Collaborator Author

@"\color{#ff3399}{(a_1+a_2)^2}=a_1^2+2a_1a_2+a_2^2"

gives

image

There is a problem in the parser where a ToString() is done on a parsed color object somewhere, before re-parsing it.

I believe I didn't add this problem, and that in master if you adjust .ToString on CSharpMath.Structures.Color it will stop rendering some LaTeX. Will check now.

@charlesroddie
Copy link
Collaborator Author

Confirmed in master
image

@charlesroddie
Copy link
Collaborator Author

Any ideas where the unnecessary ToString -> reparse steps are happening @Happypig375 ?

@Happypig375
Copy link
Collaborator

They happen in the BindableProperties in MathView. There is no easy way to fix this.

@charlesroddie
Copy link
Collaborator Author

They happen in the BindableProperties in MathView. There is no easy way to fix this.

OK it looks like it's using the .LaTeX on a text/math painter in XSharpMath.Xaml/Views.cs line 182. Maybe there is some 2-way binding there, when there should just be a one way binding from string.

@Happypig375
Copy link
Collaborator

Setting LaTeX updates the MathList and setting MathList updates LaTeX. Not sure what is meant by "there should just be a one way binding from string."

@Happypig375
Copy link
Collaborator

Also the property name "Colour" was used just to avoid clashing with the type name "Color". Now that the type name has changed, the property name can change back to "Color" to stay consistent with other "Color"s.

@charlesroddie charlesroddie marked this pull request as ready for review June 30, 2020 11:05
@Happypig375
Copy link
Collaborator

Tests are failing - this PR is still not ready for review.

@charlesroddie
Copy link
Collaborator Author

Tests pass

@charlesroddie
Copy link
Collaborator Author

Except for CSharpMath.Rendering.Tests. The tests involving errors fail because the strings have changed and so the error views change. I could not find how to regenerate the images.

Actually this approach is not good because the output doesn't need to match the images for CSharpMath to be working correctly. As shown in the current failed tests. These tests are more tests of similarity to a previous version than tests of correctness.

An example of an approach that would work is to generate images on two platforms and require approximate equality.

I've commented out the error-test data to get the tests to pass. I didn't delete the data/files because they could be used in a valid consistency test as described above.

@Happypig375
Copy link
Collaborator

I could not find how to regenerate the images.

Delete the reference images and re-run tests a few times until all tests pass.

Actually this approach is not good

Agreed. File size comparisons are not good because that is not how humans compare images. We need a way to compare image similarity. If there are any suggestions, please say.

the output doesn't need to match the images for CSharpMath to be working correctly. As shown in the current failed tests.

Disagreed. These tests ensure that CSharpMath will not suddenly draw nothing. CSharpMath.Rendering.Tests test whether CSharpMath.Rendering and CSharpMath.SkiaSharp can output images correctly.

These tests are more tests of similarity to a previous version than tests of correctness.

Disagreed. There are baseline images that are analogous to expected data of unit tests. You can view the test cases by viewing the baseline images in CSharpMath.Rendering.Tests.

An example of an approach that would work is to generate images on two platforms and require approximate equality.

Disagreed. An error in CSharpMath.Rendering will cause errors in all platforms in CSharpMath.Rendering.Tests. We need baseline images as a result.

I've commented out the error-test data to get the tests to pass.

That is analogous to commenting out unit tests. This is a bad practice.

I didn't delete the data/files because they could be used in a valid consistency test as described above.

You can modify the data in the same way that you would modify expected data of unit tests when the implementation changes.

@Happypig375 Happypig375 requested a review from FoggyFinder July 2, 2020 10:41
@Happypig375 Happypig375 merged commit a3a8920 into master Jul 2, 2020
@Happypig375 Happypig375 deleted the SystemDrawingColor branch July 2, 2020 12:02
@Happypig375 Happypig375 added Resolution/Implemented The described enhancement or housekeeping work has been implemented. Status/5. Awaiting next release This issue has been resolved and is waiting for the next release/prerelease. labels Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution/Implemented The described enhancement or housekeeping work has been implemented. Status/5. Awaiting next release This issue has been resolved and is waiting for the next release/prerelease. Type/Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants