HOW TO CREATE V-SHAPED LINE / ELEMENT inspired by bottom of clip path - element

at the top of my web there is a polygon shaped photo, covering whole width of the page. I would like to add a V-shaped line under it, the shape should copy the bottom shape/part of the clip-path polygon and cover whole width of the page. Could you please advise how to do that?
img {width: 100%;clip-path: polygon(0 0, 100% 0, 100% 74%, 50% 100%, 0 74%);}
I tried to do it with two rotated single lines, however there is a gap on the left and right, and also between the lines (in the center)- even thought there is no margin/padding anywhere. Thank you for your help.
img {width: 100%;clip-path: polygon(0 0, 100% 0, 100% 74%, 50% 100%, 0 74%);}

Related

Adjusting jssor slider size

I need to adjust the width and height to the width and height of my div which is width:250px height 170:px. I am using jssor slider and it keep giving me a full stretched width img Please kindly help me with this. this is the code below.
jssor_slider1_starter('slider1_container');
Please use $FillMode option.
var options = {
...
$FillMode: 2, //[Optional] The way to fill image in slide, 0 stretch, 1 contain (keep aspect ratio and put all inside slide), 2 cover (keep aspect ratio and cover whole slide), 4 actual size, 5 contain for large image, actual size for small image, default value is 0
...
};
Reference: http://www.jssor.com/development/reference-options.html

Hide UI/Image partially in Unity 5

Does Unity 5 support partial hiding of a UI/Image?
For example, the UI/Image I have in my scene has 100 width and 100 height.
At time = 0, the UI/Image is hidden. When time = 5, the UI/Image only shows the first 50 pixels. When time = 10, the UI/Image is fully drawn.
The answer to the question is in this link
Set the image type to Filled
Set the fill method to horizontal
Set the fill origin to left
From the script, update the fill amount from 0 to 1 over the timespan
On first thought, I can come up with two workarounds for this.
If the background of the image-in-question is a solid color, you can use another image with the same color as background that covers the actual image, so that it looks like the actual image is partially revealed. Then, just reduce the length of this covering image over time to achieve a revealing effect using Coroutines.
You make multiple image files with alpha channels and change the textures of the UI/Image over time. Each image will act like an iteration of revealing effect. Say you have 11 images, the 6th image will have first half revealed, and second half as alpha=0. In this case, if you want smoothness, you will need a higher number of images.

iTextSharp - Scaling and positioning page

I am reading an existing PDF file into a new PDF file, and scaling the first page based on the page dimensions. The page gets scaled to 90-95% in order to make room for some footer text. The problem I have is that the resulting scaled page leaves white space at the top of the page, NOT the bottom. Is there a way to control the results so that they start in the top left of the page and not the bottom left?
Here's my code that adds the scaled page:
cb.AddTemplate(importedPage, scaleSize, 0, 0, scaleSize, 5, 20);
Object "cb" is a PDFContentByte class, while "scaleSize" is a float set to .9 or .95. The scaling works great, but the positioning is an issue. Thanks!
figured it out: the value of "20" for the final parameter was incorrect. A value of 100 is far more suitable for my purposes, and now I understand far better the coordinate system in PDF/iText. For those interested, the 0, 0 point for a PDF document is the lower left corner.

square Facebook pictures

Using Graph API I can get small, large, medium pictures. Or I can get small square picture.
But how can I get large square picture? Is there any service I can use?
Simple, I just found this out.
Example,
https://graph.facebook.com/friends_Id/picture?width=200&height=200
tada~
Oddly enough, Facebook itself doesn't use a bigger square image even though they show a bigger squared profile picture on the new timeline pictures. If you take a closer look they take a larger rectangular image and reposition it inside an HTML element as Michael proposed above.
I would expect that at some point the positioning data they use for this will be released via the API but I am not aware of that data being available yet. I've had times where this would have been helpful also and have thus far either just centered the image or used the top portion. Not ideal though since FB already allows for and tracks custom positioning of the most important "square" of the image via their "icon" creator.
There is no way to do this officially, here's a silly hack. The following code will make sure the image is no wider/taller than 120 pixels. If it is, then the image will overflow outside the element:
<div style="width: 120px; height: 120px; overflow: hidden; display: inline-block;">
<img src="{$image}" align="absmiddle" width=120 style="min-width: 120px; min-height: 120px;" />
</div>
You can specify the picture size you want with the type argument, which should be one of square (50x50), small (50 pixels wide, variable height), and large (about 200 pixels wide, variable height).
From the Graph API Reference. Those are the only three sizes available. You can use a bigger version of the 50x50 image but it'll obviously look dithered.
Nowadays Graph actually could return you square image of any size. They cache most common sizes (like 100x100, 128x128) and return the closest size by the following request (hover to see)
As the other answers already stated, in facebook the square pictures are only in 50x50 resolution.
A simple CSS hack does the trick though:
Query the large image, wrap the img-tag with a div and apply this CSS to the div:
img#facebook_img {
width: YOUR_WIDTH;
}
div#wrapper {
height: YOUR_HEIGHT;
overflow: hidden;
}
If YOUR_WIDTH and YOUR_HEIGHT are the same you get your square image and the ratio is preserved.
None of the answers worked perfectly for me, having come across profile pictures of various dimensions (some with a greater height than expected, some with a smaller height) which ended up either stretched or non-centered.
In the end I used a div element instead of an img and set the image through a background-image style attribute rather than through its src attribute.
CSS file:
.profile-pic {
background-repeat: no-repeat;
background-position: center;
background-size: cover;
height: 120px;
width: 120px;
border: solid 1px #ddd;
}
HTML:
<div style="background-image:url(https://graph.facebook.com/123/picture?width=120&height=120);" class="profile-pic"></div>
Replace 120px in the above (occurs twice in the CSS and twice in the HTML fragment) with your desired dimensions.

Positioning stretched UIImages correctly

I am creating a UISegmentedControl replacement so that it works with your own custom images. Because the separators need different colors on both sides I decided to give the middle item the two borders.
Now to display the UISegmentedControl replacement, I calculate the available width for one item (frame.size.width / numberOfItems). Then I create a UIButton with a custom background image (the stretchable middle segment image). The next thing is to position everything. Because the 1px separators need to be visible when you select an item, I give every item a 1px larger frame than it actually should have. So the next item overlaps 1px to the left.
segmentRect = CGRectMake(indexOfObject * (self.frame.size.width / numberOfSegments), 0, (self.frame.size.width / numberOfSegments) + 1, self.frame.size.height);
Using this result I get a nearly perfect custom UISegmentedControl (retina):
Now things look pretty ok, but it all changes when adding more/less segments. This was a 300px wide control by the way, so each segment gets 25px of space. If I change that number to let's say 13, this shows up:
Notice the slightly different border between the '3' and '4'. (Easier to spot on non-retina actually because of pixel doubling) I think this is caused by the not so nice amount of space each segment gets. (300 / 13 =
23,0769) One should think that the stretchable image would accommodate for this, no? The separators are exactly 1px in width and I change the frame by 1px, so the two separators should be placed exactly on top of each other, which is definitely not the case here.
Does anyone have an explanation why this happens and more important a way to fix this?
All coordinates are floats (CGFloat's, actually) by default, so if you're handing the system non-integer coordinates it will try its best to draw between pixels, using anti-aliasing. The weird 3/4 border is probably due to this.
One solution is to give all your segments integer-sized widths. This may sound a bit nasty, since they might not all be the same width in order to fill up the space (i.e. if the overall width is not divisible by the number of segments), but code like the following shows how this can be done without too much trouble:
int totalWidth = self.frame.size.width;
float dx = (float)totalWidth / numSegments;
float lastX = 0.0;
for (int i = 0; i < numSegments; ++i) {
int thisWidth = round(lastX + dx) - round(lastX);
CGRect segmentFrame = CGRectMake(round(lastX), 0, thisWidth, height);
/* do what you will with segmentFrame */
lastX += dx;
}
I personally like this technique because it automatically evenly distributes the widths that are slightly larger than the others (all the widths will be within 1 pixel of each other).
This code is not including your 1-pixel overlaps, but that is easy to add.
Another benefit is that if your UILabel's or UIImageView's also have integer coordinates (in the coordinate system of the entire screen), they tend to look more crisp.
Yea, my guess is that UIView subclasses don't like uneven frame sizes. I've come across this so many times. What if you try making your segmented view 325px wide? If it fixes the glitch, then you've got your answer :)
I am not sure of the answer, I think it has to be with antialiasing. (Which is something we cannot change in this case).
An approach could be something like:
int x = width%numberOfButtons;
if(x == 0){
//do as now
}else{
//make the first x buttons 1px bigger
}
I managed to come up with something myself. I floor the width of each segment, so the middle buttons will look ok. Then I divide the unused space between the first and last button. (again a rounded value for the first)