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

Add antialiased, draw outline and line color/width properties to ColorRect #92023

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented May 16, 2024

This exposes recently-added CanvasItem functionality to the ColorRect node, so that custom drawing methods don't need to be called if you want to benefit from antialiasing or non-filled rects.

The outline is drawn on top of the background, which can also now be disabled.

A similar approach could be used to expose functionality such as drawing circles and regular polygons, although this may make more sense as an extension of the Polygon2D node instead (since ColorRect is all about rectangles).

Testing project: test_color_rect.zip

Preview

Screenshot_20240516_185707

@Calinou Calinou added this to the 4.x milestone May 16, 2024
@Calinou Calinou requested review from a team as code owners May 16, 2024 17:06
@Calinou Calinou force-pushed the colorrect-add-outline-antialiasing branch from a0fc59f to f783013 Compare May 16, 2024 17:08
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to feel about several things:

  • Back in 4.0 alpha, a PR was closed which pretty much would've done this (see Add filled, border_width, editor_only properties to ColorRect #65549 (comment) for reasoning). Years have passed and opinions may have changed, but have they, and why?
  • I don't think the new draw_background and draw_outline are necessary. On the surface, the same effect can be achieved by setting them to a fully transparent Color, which is pretty trivial to do both in the editor and in code.
    • I've never seen anyone request draw_background, but I may be completely mistaken.
  • "Outline" VS. "line", I am not sure which is true here.
    "Outline" implies it's being drawn outside of the edges, but I assume that the line is actually drawn covering the edges and expanding both inside and outside.
  • Because antialiased and negative line_width are undesirable together, and I can easily see an user pressing buttons until something looks nice, a configuration warning could be nice.
  • All the new documentation descriptions are welcome of course, but they're a bit rough. One thing at the time.

</brief_description>
<description>
Displays a rectangle filled with a solid [member color]. If you need to display the border alone, consider using a [Panel] instead.
Displays a rectangle filled with a solid [member color]. See also [ReferenceRect] for an alternative designed for UI debugging.
[b]Tip:[/b] By having a [ColorRect] span the entire viewport, it can be used to create 2D post-processing shaders using a shader of type [code]canvas_item[/code] on the node.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

It makes sense for this context type to exist but at the same time, it is rarely if ever used by the class reference, so I wonder if it's worth setting a precedent for it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find most class descriptions to be pretty short already, so it doesn't hurt much to add this kind of information.

doc/classes/ColorRect.xml Outdated Show resolved Hide resolved
doc/classes/ColorRect.xml Outdated Show resolved Hide resolved
doc/classes/ColorRect.xml Show resolved Hide resolved
doc/classes/ColorRect.xml Outdated Show resolved Hide resolved
doc/classes/ColorRect.xml Outdated Show resolved Hide resolved
…rRect

This exposes recently-added CanvasItem functionality to the ColorRect node,
so that custom drawing methods don't need to be called if you want to benefit
from antialiasing or non-filled rects.

The outline is drawn on top of the background, which can also now be disabled.
@Calinou Calinou force-pushed the colorrect-add-outline-antialiasing branch from f783013 to 0c239bd Compare June 29, 2024 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Glitching happens when the camera moves continuously, on sprites or ColorRects with hard edges
2 participants