填充一个矩形,充满膨胀圆而不越过边界(波纹)
我有一个控制表面(我的自定义对照)和一个小于整个表面的矩形。现在,我需要在此矩形内绘制一个圆(Fillellipse),并且圆圈不得透支矩形边界。
我从Angular中知道了一个按钮: https://material.angular.io/components/button-togglegle/overview 并想创造出这样的波纹: https://material.agluarl.io/components/components/ripple/ripple/explass
完美的。我想制作这样的动画。填充的进度不是问题,而是我不使用我的按钮中使用的“子控制按钮”的事实,因此没有“真实”边界,我在绘制我的点击按钮的边界方面而挣扎。
不,我不会使用子按钮作为控件来放入我的条带。我不希望控制控制控制。我正在绘制按钮,并将矩形用作我的事件的“地址”,例如悬停/单击/点击等。
这是我的buttonstrip的一个示例(一个月悬停)。点击一天。
每个按钮(在列表或字典中)都有其自己的矩形,该矩形是预算的:
Dim InnerWidth As Integer = If(_IOSwitchVisible = True,
(Me.Width - _IOSwitchWidth) \ Buttons.Count,
Me.Width \ Buttons.Count)
If InnerWidth = 0 Then Return
For Each b In Buttons.Values
b.Rect = New Rectangle(CurrLeft, 0, InnerWidth, Me.Height)
VerticalLinePos.Add(CurrLeft)
CurrLeft += InnerWidth
Next
这只是代码的一部分。 这是我如何绘制单击按钮(是否悬停)的片段,
'Clicked
For Each btn In Buttons.Values.ToList.Where(Function(x) x.Clicked = True)
If _HoveredElement IsNot Nothing AndAlso _HoveredElement.Rect = btn.Rect Then
'If the button is already clicked
e.Graphics.FillRectangle(New SolidBrush(ClickedHoveredColor), btn.Rect)
Else
'Otherwise draw clicked color
e.Graphics.FillRectangle(New SolidBrush(ClickedColor), btn.Rect)
End If
Next
有人想知道如何用一个圆圈填充其中一个按钮,该按钮必须不得透支到其邻居按钮上?
编辑:一旦我(或您)发现了如何,我将包括一个循环以使圆圈充气以使填充进度动画。
I have a control surface (my custom control) and a drawed rectangular smaller than the whole surface. Now I need to draw a circle (FillEllipse) within this rectangular and the circle must not overdraw the rectangular borders.
I made a ButtonStrip like this one know from Angular:
https://material.angular.io/components/button-toggle/overview
And want to create such ripples:
https://material.angular.io/components/ripple/examples
It is almost perfect. I would like to make such an animation. The filling progress is not a problem, but the fact, that I dont use kinda "child control buttons" in my ButtonStrip and therefore no "real" borders, I struggle with the not"over"drawing the borders of my clicked button.
And no, I will not use child buttons as controls to put into my strip. I dont want this control in control control. I am drawing the buttons and use the rectangulars as "address" for my events like Hover/Click/Clicked etc.
Here is an example of my ButtonStrip (Month is hovered). Day is clicked.
Every Button (in a List or Dictionary) has its own rectangular which is pre calculated:
Dim InnerWidth As Integer = If(_IOSwitchVisible = True,
(Me.Width - _IOSwitchWidth) \ Buttons.Count,
Me.Width \ Buttons.Count)
If InnerWidth = 0 Then Return
For Each b In Buttons.Values
b.Rect = New Rectangle(CurrLeft, 0, InnerWidth, Me.Height)
VerticalLinePos.Add(CurrLeft)
CurrLeft += InnerWidth
Next
This is only a part of the code.
And here is a snippet how I draw a clicked button (either hovered or not)
'Clicked
For Each btn In Buttons.Values.ToList.Where(Function(x) x.Clicked = True)
If _HoveredElement IsNot Nothing AndAlso _HoveredElement.Rect = btn.Rect Then
'If the button is already clicked
e.Graphics.FillRectangle(New SolidBrush(ClickedHoveredColor), btn.Rect)
Else
'Otherwise draw clicked color
e.Graphics.FillRectangle(New SolidBrush(ClickedColor), btn.Rect)
End If
Next
Does someone got an idea how to fill one of these buttons with a circle which must not overdraw to its neighbour buttons?
Edit: As soon as I (or you) found out how, I will include a loop to inflate the circle to animate a filling progress.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多亏了Jimi,我得到了他的剪辑提示:

(黄色圆圈来自ScreentOgif)
Thanks to Jimi I got it working with his Clip hint:

(The yellow circle is from ScreenToGif)