logo
down
shadow

How do I rotate an image in Javascript or CSS


How do I rotate an image in Javascript or CSS

By : scrodaddy
Date : October 18 2020, 11:12 AM
I wish this helpful for you Firefox and the Webkit browsers support a "transform" CSS property ("-webkit-transform", "-moz-transform"). Those can do all sorts of interesting things. There's a very weak IE tool that allows very limited rotation, so it's not really an option for something like a game.
Here's a demo page I made for another Stackoverflow question a few days ago: http://gutfullofbeer.net/compass.html
code :


Share : facebook icon twitter icon
jQuery rotate image (using rotate plugin) rotate +/-90 degrees each click

jQuery rotate image (using rotate plugin) rotate +/-90 degrees each click


By : Philbee
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I am using this jQuery plugin: http://code.google.com/p/jqueryrotate/wiki/Documentation , Something like this?
code :
$("body").on("click", ".theater-wrapper img", function(){

    $(".theater-wrapper .current").rotate(getNextAngle());

});

nextAngle = 0;
function getNextAngle() {
    nextAngle += 90;    
    if(nextAngle >= 360) {
        nextAngle = 0;
    }
    return nextAngle;
}
Rotate image around it's center using easeljs/canvas/javascript while image remains on the starting position

Rotate image around it's center using easeljs/canvas/javascript while image remains on the starting position


By : Timi Idowu
Date : March 29 2020, 07:55 AM
wish of those help Using your supplied fiddle, I have updated the code to the following to fix the jumping around on rotation. You can see it running on the updated fiddle.
code :
var ship;
var canvas;
var stage;
var direction = "up";
var shipHolder;

// add keyboard listener.
window.addEventListener('keydown', whatKey, true);  
// create a new stage and point it at our canvas:
canvas = document.getElementById("mycanvas");
stage = new createjs.Stage(canvas);

createPlayer();

createjs.Ticker.addEventListener("tick", tick);
createjs.Ticker.setFPS(20);


function createPlayer(){
    var img = new Image();
    img.src = "http://i.stack.imgur.com/PXszc.png";

    var shipSize = 20; // 20x20 px is the image
    ship = new createjs.Bitmap(img);

    shipContainer = new createjs.Container();
    shipContainer.addChild(ship);

    // he starts at the bottom center of the canvas
    shipContainer.x = canvas.width / 2;
    shipContainer.y = canvas.height - shipSize;

    // uncomment to see ship position then
    ship.regX = 10;
    ship.regY = 10;
    ship.x = 10;
    ship.y = 10;

    stage.addChild(shipContainer);    
}

function manageDirection(){
    if(direction == "left"){
        ship.rotation = -90;
    }
    else if(direction == "right"){
        ship.rotation = 90;
    }
    else if(direction == "up"){
        ship.rotation = 0;
    }
    else if(direction == "down"){
        ship.rotation = 180;
    }
}    

function tick(event){
    // draw the updates to stage:
    manageDirection();
    stage.update(event);    
}    

function whatKey(event) {
    switch (event.keyCode) {
        // left arrow
        case 37:
            direction = "left";
            break;
            // right arrow
        case 39:
            direction = "right";
            break;
            // down arrow
        case 40:
            direction = "down";
            break;
            // up arrow 
        case 38:
            direction = "up";
            break;
    }
}
JavaScript - Rotate Image to Angle Between Two Values and Re-Position Image Centre

JavaScript - Rotate Image to Angle Between Two Values and Re-Position Image Centre


By : Nathan Brown
Date : March 29 2020, 07:55 AM
like below fixes the issue I am trying to implement a gauge, I have two hardcoded values - a min (0) and max (200) and then a calculated value returned via ajax. , Simply use the following:
code :
// calculate angle based on proportion
var degree = 180 * error_rate / max;

// rotate pointer container but not image
var img = $('.pointer-canvas');
scroll rotate image working only one image with javascript

scroll rotate image working only one image with javascript


By : user3248488
Date : March 29 2020, 07:55 AM
this will help I am trying to make a rotate img width window scroll. But i have one problem. The problem is only one image will rotating. I have created this DEMO from codepen.io , IDs must be unique. Change ID to class and do
code :
$(window).scroll(function() {
  var theta = $(window).scrollTop() / 10 % Math.PI;
  $('.leftgear').css({ transform: 'rotate(' + theta + 'rad)' });
});
  $('.leftgear').each(function(i) {
    $(this).css({ transform: 'rotate(' + (theta+(i*10)) + 'rad)' });
  }); 
How Rotate image with css or javascript

How Rotate image with css or javascript


By : gsr
Date : March 29 2020, 07:55 AM
it helps some times I want to know if there is a way to rotate images without using fotoshop, i want to use css or javascript , Use CSS' rotate, rotateX, rotateY, rotateZ. Little example:
code :
img {
    transform: inherit;
    transition: all 0.3s;
    width: 100px;
}
img:hover {
    transform: rotateX(45deg)
                rotateY(45deg)
                rotateZ(45deg);
}
Related Posts Related Posts :
  • Debug React Microservice Application with webpack and tailor
  • Can get requests placed by <a> tags include data?
  • how to make amChart column with 3 axis vertical
  • Only filter Array for the defined parameters. ignore empty parameters
  • Generating React/Express Routes in Javascript
  • es6 filter an array of objects by an array of filter objects
  • Can we pause a delay in jQuery?
  • Selectors are executed before component is rendered
  • javascript basic collision function for high school project
  • getElementById on page with multiple instances of same component
  • My code doesnt add letters to string in cycle for discord.js
  • Change Color of a selected item in an array
  • cancel all subscriptions in componentWillUnmount
  • Unable to set timezone in Highcharts graph
  • Call function in function event (onChange), from Select created in Leaflet and Vue.js
  • React Hooks - What's happening under the hood?
  • Redux Testing - getState() TypeError: Cannot read property 'startDateIndex' of undefined
  • JavaScript: Re-organize canvas rendering in a functional manner
  • Using Jest and Enzyme, how do I test a function passed in through props?
  • Spacing and size of horizontal bars in a Victory stack?
  • How to detect if a file exists in JavaScript accounting for 404 handler
  • Difference between readFileSync and using promisify on top of readFile with async/await
  • Promise.all() problem using setTimeout(), state not updating
  • Using Array class methods for HTMLCollection DOM traversel in ES6
  • Azure and MicrosoftGraph Api deploy throw "Error: Method Not Allowed"
  • Angular 2 router ngIf dynamic route
  • How to get the checked tree structure values using angular2-tree plugin using angular
  • Grabbing parts of a date in a different timezone with moment
  • Getting a particular attribute from a JSON data
  • Testing React Redux Async Actions with fetch-mock - "Cannot read property 'then' of undefined"
  • good practice to change page without reloading
  • How do I change background color of one frame with another frame?
  • cdk-drop is not a known element
  • Storing AWS credentials in the frontend
  • Round up decimal to the first two significat digits
  • enzyme test contains for container
  • regex non converting character after symbol to upper case
  • React VictoryBar style difficulties
  • Vue call method of another component
  • How do I properly use reportValidity() when I want to show an error bubble for just one input field?
  • A js event for js Chrome extension (work on every tab had loaded a page)
  • How to see if url is mobile only
  • tabulator update column data
  • Entity cannot be found error in Dynamics 365 for Outlook App
  • Split up json-data fetched with axios in to a clickable list-item that redirects to page
  • Change moment date string into proper timezone
  • How is the module exported in Winston package?
  • Javascript toggle array button
  • JavaScript/Angularjs - View a template according to a JSON configuration, multiple ng-repeat
  • Javascript promise then inside a class
  • Using a variable increment to create new variables in Javascript
  • iterate through a html table and get row number for each row in javascript
  • How to design store (state of app) so we change data in store directly without actions, reducers?
  • How do I call 2 or more asynchronous methods in Actions on Google intent fulfilment V2
  • Mapping a different icon depending on property value in React
  • Expanding the width of div after the content exceeds the height of the div
  • React.js pending 4 min before gets response from Express.js backand restful api
  • I have to press a button twice to fill react state from firebase realtime database
  • Simple Class Function Boolean Output
  • Google AdSense "Valuable Inventory: No Content", on a homepage?
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org