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

Effects like a Blur\Shadows #1501

Closed
vertexpipeline opened this issue Apr 15, 2018 · 9 comments
Closed

Effects like a Blur\Shadows #1501

vertexpipeline opened this issue Apr 15, 2018 · 9 comments

Comments

@vertexpipeline
Copy link

vertexpipeline commented Apr 15, 2018

I want to make a card in Material Design that implies shadow effect. Are there any capabilities to do it?
image
WPF has a Effect Parameter, does Avalonia has something similar?

@danwalmsley
Copy link
Member

No built in effects yet, perhaps it might be possible with some kind of border and a gradient brush. Would be nice to get support for this though.

@vertexpipeline
Copy link
Author

How I understood, rendering API doesn't support shaders like in WPF?

@Sorien
Copy link
Contributor

Sorien commented Apr 15, 2018

You don't need shader support, there is shadow effect build in d2d https://msdn.microsoft.com/en-us/library/windows/desktop/hh706334(v=vs.85).aspx and skia https://developer.xamarin.com/api/member/SkiaSharp.SKImageFilter.CreateDropShadow/ but its not implemented in avalonia

#124

@vertexpipeline
Copy link
Author

Thanks, I'll try to implement this feature where I can

@Sorien Sorien mentioned this issue Jun 13, 2018
3 tasks
@maxkatz6
Copy link
Member

maxkatz6 commented Oct 1, 2020

Just for case, there is BoxShadow in Avalonia 0.10+
#3871

Although there still no convenient in-app blur.

@balthild
Copy link

balthild commented Jan 7, 2021

In Avalonia v0.10.0-rc1, If I wrap BoxShadow value into multiple lines, for example,

                    <Setter Property="BoxShadow">
                        <Setter.Value>
                            inset -1 0 1 -1 #10000000,
                            inset -2 0 2 -2 #20000000,
                            inset -6 0 6 -6 #16000000,
                            inset -16 0 16 -16 #16000000
                        </Setter.Value>
                    </Setter>

then the view cannot load (but don't throw any exceptions). Is this intended?

@maxkatz6
Copy link
Member

maxkatz6 commented Jan 7, 2021

but don't throw any exceptions

It throws:
System.FormatException: 'One of the identified items was in an invalid format.'
Avalonia.Media.BoxShadow.Parse(string)
Avalonia.Media.BoxShadows.Parse(string)

It can't parse '\n' separator.
Following code works fine:

<Setter Property="BoxShadow">
    <Setter.Value>
        inset -1 0 1 -1 #10000000, inset -2 0 2 -2 #20000000, inset -6 0 6 -6 #16000000, inset -16 0 16 -16 #16000000
    </Setter.Value>
</Setter>

I am not sure if it is expected by CSS specs or should be filled a bug for that.

@balthild
Copy link

balthild commented Jan 7, 2021

Oh, sorry... Didn't noticed that the exception is caught internally.

In CSS, newlines are allowed between tokens for all property, but not inside quoted values. Sometimes newlines are useful for keeping code tidy. The following code is valid in Chrome and Firefox:

.ugly-syntax {
  box-shadow: 10px  
      5px         5px
   blue,
-10px -10px 4px
   red;
font-family: Segoe
                UI, sans-serif;
}

and this does not:

.invalid-syntax {
font-family: "Segoe
                UI", sans-serif;
}

@maxkatz6
Copy link
Member

maxkatz6 commented Jun 22, 2023

We have BoxShadow for a while and now we have effects Effect="blur(10)" syntax in 11.0

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.

6 participants