Skip to content

Instantly share code, notes, and snippets.

@hrkd
Created March 3, 2014 10:37
Show Gist options
  • Save hrkd/9322399 to your computer and use it in GitHub Desktop.
Save hrkd/9322399 to your computer and use it in GitHub Desktop.
photoshopの選択範囲から、htmlのmapタグ、areaタグを生成するjsx
// JavaScript Document
var x1 = activeDocument.selection.bounds[0];
var y1 = activeDocument.selection.bounds[1];
var x2 = activeDocument.selection.bounds[2];
var y2 = activeDocument.selection.bounds[3];
var tmp = x1.toString() + y1.toString() + x2.toString() + y2.toString();
var rect = tmp.split(' px');
prompt('mapタグの生成が完了しました。(座標の始点はスライスではなく、カンバスです。)', '<img src="sample.gif" usemap="#Map" alt="">\n<map name="Map">\n<area href="#" shape="rect" alt="" coords="'+rect[0]+','+rect[1]+','+rect[2]+','+rect[3]+'">\n</map>');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment