Sketch: Resize symbol with shadow - sketchapp

Sketch v42.
I have simple box symbol with shadow(x:10, y:10).
when I resize symbol, shadow is not resized.
How I can implement resize(include shadows) on the symbol.

The shadow defined in your symbol will always be "10px 10px 10px 0" that's it won't resize.
One solution is to create another rectangle, that will remplace your shadow propertie.
Create a clone rectangle (Ctrl + c / Ctrl + v)
Add 10 to the X and Y position of the clone
Change the background color, add a gradient black / transparent in order to make it look like a shadow
🎉 When you will resize your symbol, this false shadow will resize too.

Related

How to draw a round rect border

I have been trying to draw a round rectangle with a shadow, looked into FloatingActionButton and tried `RoundBorder' like this:
Label labelXXX = new Label("XXX");
labelXXX.getAllStyles().setBorder(RoundBorder.create().color(ColorUtil.WHITE).shadowY(0.0f).shadowOpacity(127));
But the resulting Border looks wrong.
According to the Javadoc of com.codename1.ui.plaf.RoundBorder.shadowY(float)I expected the shadow to be located at the top of the label. Also I expected the round border to fill the labels background and the shadow to be outside of the border.
What do I need to do to create a round rect border that fills the component space and has a shadow outside the component space?
RoundBorder != RoundRectBorder. If you mean to use the latter it's a different class.
Notice that RoundBorder has a rectangle mode which you can activate using a method with the same name that will produce that result.
The shadow can be at the top when you set the Y to 1. Maybe the javadoc isn't clear. This is meant as a directional shadow so the light source is above hence the shadow would be below.

Resizing images to cover % of div by surface area

I'm working on an Ionic app. I have a two column layout of squares, for an example let's say they're 100x100. I'd like to rescale and then center (horizontally and vertically) images within those squares.
The images to put in them, however, do not have identical aspect ratios. I'd like to resize images to cover the same surface area, regardless of dimensions.
Again, for example, let's say that I want each image to cover 25% of my squares in the grid. If I have a 1000x1000 image, it would be resized to 50x50 to cover 25% of the area within a square. If I had a 500x250 image, it would be resized to ~70x35.
Mathematically I understand at least one way how to do this: image dimension * sqrt((image width x image height) / (0.25)(div width x div height)). It's in code with Angular, however, that I'm struggling.
Any advice?
I would try to use CSS if possible. It will be much lighter for the browser to render this and much easier for you to implement.
To do this, create boxes in your template and each box will have an image as a background. You can set that using ng-style attribute on the box.
In your CSS you could do something like this:
.image-box {
width: 50px;
height: 50px;
background-size: cover;
}

Angular svg icon size

I'm making an angular js application and I'm using the icons found https://materialdesignicons.com/
I'm having trouble creating large icons in my project. I'm currently assigning the icons like so.
app.config(function($mdIconProvider) {
$mdIconProvider
.defaultIconSet('assets/icon/materialdesignicons.svg')
.iconSet(['large'], 'assets/icon/materialdesignicons.svg');
});
I know the default size is 24px, but if I put in a number like 48, the image shrinks instead of gets larger.
What should I put in instead of large?
If your icon svg element has a viewBox attribute, it won't be overwritten by the $mdIconProvider size attribute.
The size parameter defines the viewBox height and width. viewBox only affects the coordinate system of an SVG element. It should match the dimension of your icon; if they don't match, md-icon might show a zoomed in/out view of the icon.
However, the actual size of a md-icon element will be defined by its height and width (defined with css); the SVG element will scale up and down inside the md-icon.
viewBox is a requirement for a svg element to scale. It sets which portion of its grid to show and how the element in the svg element should scale with it. it just doesn't decide the actual size of the icon which grow with md-iconelement size.
If viewBox is not set, the svg elements will not scale (that's the
jQuery bug); one unite will be 1px regardless of the svg element
size.
If you set the size to something smaller than the svg grid (e.g. "0 0
12 12" for a 24x24 grid), you will zoom onto the top left corner of
the icon.
If you set the size to something bigger than the grid (e.g. "0 0 48
48" for a 24 x 24 grid), you will zoom out with the the icon placed
in the top left corner of the svg element.
You can find lot more details here.
I managed to figure out the problem. The icon was being used as a button, but I had the class md-icon-button for the button in addition to the icon. Removing the class from the button fixed the issue.

How to maintain scroll position on window resize while using scrollmagic

I have a fixed container of 100vh x 100vw that contains 6 absolutely positioned divs that are 100vh x 100vw.
I use a dummy element that is positioned relative w/ 6 divs that are 100vh to trigger each scene.
When I resize the window, the scene's animation moves forward and backward in time. Is there a way to prevent that from happening?
The issue is that when you resize the window, the position of the scroll bar remains fixed at an absolute number of pixels. However, because your content is based on view height, the height of the document changes dynamically as you resize the window. Thus, the window scroll position as a percentage of the document body height is also changing, and this is what ScrollMagic bases progress on.
To illustrate with simplified math:
A) Given a window height of 1000px, your document height will be 6vh * 1000px = 6000px tall. If your window scroll position is 1200px, you'll be 20% of the way through the overall ScrollMagic timeline.
B) If you resize the browser to 800px tall, that changes the document height to 6hv * 800px = 4800px tall. However the window scroll position will remain at 1200px, which is now 25% of the way through the ScrollMagic timeline.
The simplest solution is probably to keep your document a fixed height.

Layers issue using Z-Index

I've 2 controls one on top of another: border over slider. on border user can mark a segment to appear in different color on slider.
Because the border is written after slider in xaml, it appear on top of the slider. and that's ok.
My problem is, the Thumb of slider also appears under the border.
How can I set the Thumb element (belong to slider control and inside it) to appear on top of all, and also the border will appear on top of the slider?
I tried use zIndex but without success. Any idea?
In CSS:
Make sure your elements are positioned absolutely or relatively. z-index doesn't really have a play in layering unless the elements are positioned absolutely or relatively. You should then be able to set one with:
z-index: 1;
and the other with:
z-index: 2;
and get the desired result.
In WPF:
Use the syntax specified here
Here's an example:
Make sure both of your elements are in the same parent, otherwise they will be displayed in the order in which they were loaded.

Resources