How can I maintain the size of image as a background of droppable? I don't know the size of image so when I set the droppable background to an image it either crops to fit the designated area or multiplies to fit it? How can I make it to fit the area by streching while maintaining the aspect ratio?
Since I already define the size of droppable in my style, I don't want to change the size of my droppable to fit the image. Rather, I want the image to be loaded to be completely contained with proper aspect ratio to the droppable meaning without being cropped or multiplied. Can this be done through jquery or javascript?
Two possible solutions:
The first is PHP GD's imagesx() and imagesy(). That is using PHP, sure, but if you can use PHP, it can be good as then you'll perhaps learns some PHP GD too. :)
Otherwise, you could use the solution to this question.
Related
Can you make your canvas resize to the page width using the style in the html of the canvas id?
And then in your js for the canvas just resize listeners based on the size of the canvas at the current time?
I have many of my variables and listeners hardcoded just wondering what is the fastest method of solving this :)
Firstly, a good starting thing would be not to take the entire page width, but a divcontainer. That way if you end up putting your app in a website or anything, your code will adapt to any container. If you want it to be the full page, this container can just be a 100% width/height absolute with no padding/margin.
Please also note that there are two sizes for a canvas :
The HTML size, which is the size you will draw on "programmatically"
The CSS size, which is the size it will be displayed, independently of the other size (and it will resize it, causing potential distortions)
Based on that, you can know an element's screen width using jquery $("#myID").width() or height(), which applies to the canvas too. Based on this you can set whatever size you want in html and/or css :
$("#myCanvas").width = 400; // The size you will draw on
$("#myCanvas").css('width', '800'); // The size it will be displayed (2x scale in X in that case)
Then for resizing you have multiple solutions :
CSS full stretching : You use your canvas with whatever size you'd like to code in, and then resize it in CSS to use the full page width, that is basically putting the css at 100% width / height
CSS stretching with aspect ratio : My prefered solution, which consists of resizing the canvas in CSS, but by keeping the original application's aspect ratio (and putting black borders on the rest of the screen, like in large-screen movies)
Pure canvas resizing : This method won't destroy graphics, but it has the big cost of making you think all your drawing with any size possible. Instead of having a fixed size canvas that is resized by the browser, you will have to multiply all your drawing sizes and positions according to the screen size, which can end up being very boring, and problematic if not thought soon in the development.
As an exemple here is my canvas manager, with CSS aspect ratio resizing. It is not documented and may not suit your need, but it can give you some ideas
Folks,I am working on an image component for my application and it involves image cropping and resizing.The issue we are facing is we are able to crop the image keeping the aspect ratio constant initially,but in our case the user can again resize the cropped image and here comes the problem.If we try to resize the cropped image we also get the portion of the image which is not present in the cropping area.For reference I add this link.We want to have a somewhat similar functionality.But the problem is we are not able to get the logic right.Once we crop a portion we get the height,width of that image.We have the original aspect ratio,but how can we now calculate the images new height,width when theuser resizes the cropped portion?The actual image is present and we do not crop it actually,but virtually for showing it to the user.We are using javascript/jquery for achieving this.No specific library but just the logic of aspect ratio till now
This is the actual picture.
This is the cropping area selected.And this would be the cropped area.
This is the resized image after cropping.The image resizes only for the cropped portion and not the entire one,whereas its actually present there.
Just from playing with your application the error that is generated would be similar to an error that would be created if you asked for a CSS property with Jquery after selecting multiple elements. A function can only return a singl result, so you still only obtain the property for the first matched element. Although I can not be sure because your code is 8000 lines long with no comments
Can someone tell me how I can present my users with a triangle over the background image. I want to make a triangular UI. For that I'm masking two images(one background.jpg and masking image, triangle.png). I'm using this new image in my a div's background. I have accomplished this using MaskImage.
But the problem is that the size of my background image changes but the size of triangle.png is fixed. I have also tried using linear-gradient, css property. but it is not working in IE. So is there any plugin which mask two images irrespective of there sizes. or any other optimal way to achieve my goal.
Thanks in advance :)
You should be able to overlay two masking triangles using :before and :after in CSS and create triangles using uneven border properties like http://css-tricks.com/snippets/css/css-triangle/.
Edit: http://jsfiddle.net/A9Zbj/11/ (Yay!)
I'd like to use a custom image as my cursor over a certain div but change its size dynamically . I would need a wide range of sizes so having a bunch of different images for each size would be a bear. Is there an easy way so scale the image the is associated with the cursor using javascript?
with the height and weight set in the CSS, you can easily just scale the image with jquery/javascript. just use an onMouseOver event and set the css. Here's a little more info: http://www.ajaxblender.com/howto-create-custom-image-cursors.html
Trying to find out if it's possible to 'shrink' an animated gif. Not in file size but in regard to the dimensions of the image.
If not, is there any way to catch the animation with jquery/javascript so I can shrink the size my moving the image out of view with css?
Or alternately after there any libraries out there for simple image manipulation type stuff for HTML5 Canvas?
EDIT:
The first mock up of the image is at http://swmohappening.info/. It's essentially a website that I'm doing to help out a local youth group retreat.
I'm wanting to shrink the portion of the letters that run-on so it's a more manageable banner to leave on the page. I do need to maintain the dimensions of the center/main section of the image.
Take a look at the animate function in jQuery - you can change the size of an image and specify the time that takes too.
As what I've read makes it seem as though the jquery animate will simply change the dimensions of an image (which isn't what is needed at the moment). I think I'll most likely end up using animate to move the image out of view to 'shrink' it that way...