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

3.x: Marbles should have a proper background #6883

Closed
akarnokd opened this issue Jan 27, 2020 · 10 comments · Fixed by #6944
Closed

3.x: Marbles should have a proper background #6883

akarnokd opened this issue Jan 27, 2020 · 10 comments · Fixed by #6944

Comments

@akarnokd
Copy link
Member

The transparent ones look terrible with dark-themed IDEs or non-light background:

image

Only looks fine in Eclipse:

image

Write a program that goes through the images in https://github.com/ReactiveX/RxJava.wiki.git images/rx-operators, checks if the image has transparency, draw it onto a white background then save it as originalName.v3.png (because some of those are linked all around). Find the filename in the source code and replace them.

@akarnokd akarnokd added this to the 3.0 milestone Jan 27, 2020
@akarnokd akarnokd self-assigned this Jan 27, 2020
@akarnokd akarnokd modified the milestones: 3.0, 3.1 Jan 29, 2020
@tomislavhofman
Copy link
Contributor

I'd like to do this if it's fine.

@akarnokd
Copy link
Member Author

akarnokd commented Apr 1, 2020

@tomislavhofman Sure!

@tomislavhofman
Copy link
Contributor

tomislavhofman commented Apr 2, 2020

While we're waiting for my internet to do the heavy lifting

Here are some fun facts:

  • There were 749 images with transparent background ( which now have corresponding .v3.png with white background )

  • RxJava project contains 45 .md files and 1855 .java files

  • A total of 842 occurrences of transparent .pngs has been found across 18 files in total ( 5 located in /docs/ and 13 in /src/ )

    1. First place, Flowable.java and 373 changes
    2. Trailing second, Observable.java with 351 changes
    3. Third place has been taken by Single.java which was updated in 72 places.

Here's a very bare and unsorted log of changes made to RxJava source code https://pastebin.com/qMvUFc1n

  • Images with white background
  • Found and replaced in source code

On a side note, if my 2nd attempt to push the wiki changes onto my fork fails. Would you be okay with me uploading just the updated images somewhere and you can update the wiki yourself? It's a difference between 100ish MB and 1GB.
Screenshot 2020-04-02 at 11 32 53 😶

If that doesn't work for you I'll just try again.

Once the wiki files are updated I'll submit the pull request for links updates.

@akarnokd
Copy link
Member Author

akarnokd commented Apr 2, 2020

You won't be able to push to the wiki or create a PR for the wiki part. Can you upload the files into this issue via attachment(s)?

@tomislavhofman
Copy link
Contributor

Oh, and I thought I was being clever by researching and discovering how to make a PR to github wiki...

I'll attach the files below

@tomislavhofman
Copy link
Contributor

tomislavhofman commented Apr 2, 2020

Okay, I've uploaded all 749 images to a comment in this thread which I haven't posted yet...

How should I approach posting them, I'm a bit confused here, it is a lot of images.

edit: should I strip the image tag and post urls only?

@akarnokd
Copy link
Member Author

akarnokd commented Apr 2, 2020

No no. Zip about 100 images at once and then attach each of them to a comment.

Edit, looks like the limit is 10 MB only.

@akarnokd
Copy link
Member Author

akarnokd commented Apr 2, 2020

How about you upload the code that does the image transformation?

@tomislavhofman
Copy link
Contributor

tomislavhofman commented Apr 2, 2020

    private static void makeNonTransparentCopyOfImages(final List<File> files, final File outputFolder) {
        int index = 0;
        for (final File file : files) {
            if (!file.getName().contains(".png")) {
                continue;
            }
            try {
                BufferedImage image = ImageIO.read(file);
                int width = image.getWidth();
                int height = image.getHeight();
                if (image.getColorModel().hasAlpha()) {
                    BufferedImage background = new BufferedImage(width, height, image.getType());
                    Graphics2D g2 = background.createGraphics();
                    g2.setColor(Color.WHITE);
                    g2.fillRect(0, 0, width, height);
                    BufferedImage combined = new BufferedImage(width, height, image.getType());
                    Graphics g = combined.getGraphics();
                    g.drawImage(background, 0, 0, null);
                    g.drawImage(image, 0, 0, null);
                    ImageIO.write(combined, "PNG", new File(outputFolder, file.getName().replace(".png", ".v3.png")));
                } else {
                    System.out.println("Non transparent image: " + index + " - " + file.getName());
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            index++;
        }
    }

@tomislavhofman
Copy link
Contributor

Created PR (#6944) which should be safe to merge once images have been uploaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants