Comments (10)
@bryphe @OhadRau sounds like a great suggestion to make things less error prone, I can tweak what I'm working on to use the BoxShadow.make
version 👍
from revery.
I'll have a look at this @bryphe, any tips?
from revery.
Awesome! Really appreciate the help @Akin909
I wrote up some thoughts, but it is pretty general. Let me know if you have questions on any of the specifics 👍
from revery.
@bryphe re. setting the uWorld
for the shadow does that mean creating a similar function like getWorldTransform
in Node.re
?
from revery.
@bryphe re. setting the uWorld for the shadow does that mean creating a similar function like getWorldTransform in Node.re ?
Essentially we'd have to do something like this:
let shadowTransform = Mat4.create();
Mat4.fromTranslation(shadowTransform, Vec3.create(shadowOffsetX, shadowOffsetY));
let worldShadowTransform = Mat4.create();
worldShadowTransform = Mat4.multiply(worldShadowTransform, _this#getWorldTransform(), shadowTransform);
And then we'd set uWorld
to do that. The worldTransform
is all of the parent transforms applied (any animations, offsets, etc), and then the shadowTransform
is just the transform we need for the shadow. Essentially what this is saying is 'First, move my shadow quad based on the shadowOffsetX, shadowOffsetY. Then, apply each parent transform in turn'. Parent transforms might include rotations, scales, etc - they would all get applied in this case.
Hope that helps! Reading through the transforms section here might help too
from revery.
@bryphe thanks that helped a lot 👍,got another question now I've actually drawn the shadow, I'm not sure I followed the strategy you suggested about using more quads with lessening opacity to draw the blur?
from revery.
What are your thoughts on named parameters for the BoxShadow? Right now I think it's a little confusing if you don't already know the order of arguments for BoxShadow. I think it would benefit to either have a record/object represent the shadow's parameters or a labelled function that could optionally be used to allow for named/out-of-order parameters.
E.g. of ways we can do this:
~boxShadow={"xOffset": 1, "yOffset": 2, "blurRadius": 3, "spreadRadius": 4, "color": Colors.red}
~boxShadow=BoxShadow.{xOffset: 1, yOffset: 2, blurRadius: 3, spreadRadius: 4, color: Colors.red}
~boxShadow=BoxShadow.make(~xOffset=1, ~yOffset=2, ~blurRadius=3, ~spreadRadius=4, ~color=Colors.red)
~boxShadow=BoxShadow({"xOffset": 1, "yOffset": 2, "blurRadius": 3, "spreadRadius": 4, "color": Colors.red})
If we use an object here or if we use the .make function, we can get default values easily which is a big plus. Alternatively, for the record we could do something like BoxShadow.{...default, xOffset: 1, yOffset: 2}
. Ideally the whole library would follow this same pattern, so it might be worth turning this into its own issue where we can further discuss the pros/cons of each of these.
from revery.
@OhadRau - I'd be open to it, and I think it's a great way to 'use the language'. I never remember the order of those parameters, have to look it up every time 😄
The BoxShadow.make
seems consistent with how we use Style's at least.
@Akin909 - what do you think?
from revery.
@bryphe thanks that helped a lot 👍,got another question now I've actually drawn the shadow, I'm not sure I followed the strategy you suggested about using more quads with lessening opacity to draw the blur?
Sweet I just pulled the branch and saw the shadow coming through! 😍
I actually don't think we'll actually need more quads with this strategy, if we handle the gradients all in the shader with that 'cutoff'. Seems like it'd all be doable in the pixel shader - just need to handle the other directions!
from revery.
Implemented with #107 - thank you @Akin909 !
from revery.
Related Issues (20)
- Ubuntu 20.10: revery-ui/esy-skia build failed HOT 3
- Ubuntu 18.10 / 19.04: @opam/ocamlfind@opam:1.8.1 build failed HOT 5
- esy '@examples' run output has no text (Revery.FontCache: Error loading typeface (skia)) HOT 4
- Uncaught Division_by_zero crash on window resize. (maxHeight vs flexGrow ?) HOT 1
- Revery roadmap in face of Reason->Rescript rebrand HOT 2
- Having problem with building revery-quick-start project on Mac HOT 7
- MacOS: Allow selective modifier key mapping
- esy install failing on Windows. HOT 3
- Build Revery is presenting failure in shell.c HOT 2
- ScrollView does not work if children are added after initial mount
- CI: esy-skia won't build on Linux HOT 1
- createWindow with visible=false does not create a hidden window HOT 3
- Update the build guide for Fedora HOT 4
- SVG drawing mangled if OS locale does use a different floating point presentation HOT 4
- Quickstart build step error HOT 1
- Windows10 esy is installed but revery-ui can not be installed
- Build revery with esy on mac failed HOT 9
- Can't build on Fedora 35 due to glibc bug HOT 4
- OCaml <=14.12 doesn't support glibc>=2.34 HOT 9
- Support for FreeBSD HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from revery.