Jump to content

İmage Mapping


akorukmez
 Share

Recommended Posts

You can paint your image on a canvas and use getImageData to get the single pixels, for examle:

var can = document.getElementById("canvas");var con = can.getContext("2d");con.drawImage("map.png", 0, 0);var data = con.getImageData(0, 0, 20, 20);r = data.data[0];//value of red in first pixel (between 0 and 255)g = data.data[1];//value of green in first pixelb = data.data[2];//value of blue in first pixelalpha = data.data[3];//transparent of first pixel

so with a for-loop you can read all pixels of your map and convert them to an object in your world or whatever you want

Link to comment
Share on other sites

 

You can paint your image on a canvas and use getImageData to get the single pixels, for examle:

var can = document.getElementById("canvas");var con = can.getContext("2d");con.drawImage("map.png", 0, 0);var data = con.getImageData(0, 0, 20, 20);r = data.data[0];//value of red in first pixel (between 0 and 255)g = data.data[1];//value of green in first pixelb = data.data[2];//value of blue in first pixelalpha = data.data[3];//transparent of first pixel

so with a for-loop you can read all pixels of your map and convert them to an object in your world or whatever you want

 

Thank you very much.ı'm thankful

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...