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

Feature/custom themes #107

Merged
merged 4 commits into from
Jun 26, 2024
Merged

Feature/custom themes #107

merged 4 commits into from
Jun 26, 2024

Conversation

Rdeisenroth
Copy link
Member

@Rdeisenroth Rdeisenroth commented Jun 18, 2024

This PR allows to set custom color palettes.

Default Color Profile:
karel_0000
Custom Profile, set with

World.getGlobalWorld().getGuiPanel().setColorProfile(
    ColorProfile.DEFAULT.toBuilder()
        .backgroundColorDark(Color.red)
        .backgroundColorLight(Color.red)
        .fieldColorDark(Color.BLUE)
        .fieldColorLight(Color.BLUE)
        .innerBorderColorLight(Color.PINK)
        .InnerBorderColorDark(Color.PINK)
        .build()
);

karel_0001

This PR is subject to change due to the inclusion of Lombok.

@Rdeisenroth Rdeisenroth added the enhancement New feature or request label Jun 18, 2024
@Rdeisenroth
Copy link
Member Author

Now also supports custom field color patterns:

World.setSize(7, 6);
World.setDelay(10);
World.setVisible(true);
//noinspection UnstableApiUsage
World.getGlobalWorld().getGuiPanel().setColorProfile(
    ColorProfile.DEFAULT.toBuilder()
        .customFieldColorPattern(
            (cp, p) -> (p.x + p.y) % 2 == 0 ? cp.fieldColorLight() : cp.fieldColorDark()
        )
        .build()
);

karel_0000

One downside to the current approch is that the gui panel needs to be visible before we change the color theme, but this works for now.

@Rdeisenroth Rdeisenroth merged commit e83da94 into master Jun 26, 2024
1 check passed
@Rdeisenroth Rdeisenroth deleted the feature/custom-themes branch June 26, 2024 16:54
@Rdeisenroth Rdeisenroth linked an issue Jun 26, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Theme Logic
1 participant