標籤:style blog http io color ar 使用 java sp
首頁:http://deepliquid.com/content/Jcrop.html
官方:http://deepliquid.com/content/Jcrop_Download.html
下載包中除了 CSS 檔案夾和 js 檔案夾外還提供了幾款 demo:
1. non-image.html 不包含映像的任意 div 的剪裁方式:
2.styling.html
提供了 3 種可以選擇的遮罩色、透明度和選區邊框樣式 jcrop-light ( bgcolor:#fff opacity:0.5 ) , jcrop-dark ( bgcolor:#000 opacity:0.4 ) , normal ( bgcolor:#000 opacity:0.6 )
3.tutorial1.html
Jcrop 的預設設定:
原圖的 html 部分為:
<img src="demo_files/sago.jpg" id="target" alt="[Jcrop Example]" />
此時在 js 中使用:
<script type="text/javascript"> jQuery(function($){ // How easy is this?? $(‘#target‘).Jcrop(); });</script>
就可以顯示預設的最簡單的 demo 的效果。
4. tutorial2.html
顯示左上、右下座標值和選區寬高值
5.tutorial3.html
固定選區長寬比並顯示預覽圖
預覽圖的顯示機制和 imgAreaSelect 類似,見 line:42
function updatePreview(c) { if (parseInt(c.w) > 0) { var rx = xsize / c.w; var ry = ysize / c.h; $pimg.css({ width: Math.round(rx * boundx) + ‘px‘, height: Math.round(ry * boundy) + ‘px‘, marginLeft: ‘-‘ + Math.round(rx * c.x) + ‘px‘, marginTop: ‘-‘ + Math.round(ry * c.y) + ‘px‘ }); } };
參數 c 是選區,c.w 代表選區的寬,c.h 代表選區的高;xsize 和 ysize 分別是預覽視窗的寬和高;縮放比為 rx 與 ry 分別等於預覽視窗的寬和高除以選區的寬和高;boundx 是原圖的寬,boundy 是原圖的高,見 jquery_Jcrop.js line:328:
var boundx = $img.width(), boundy = $img.height(),
最後呈現在預覽視窗中預覽圖的寬度等於縮放比乘以原圖的寬高,這個處理和 imgAreaSelect 外掛程式時一致的。
如果要改變選區的寬高比,只需在 demo html 中改變 line:91 #preview-pane .preview-container 的寬度和高度即改變預覽視窗的寬度和高度,同時選區的寬高比也隨著預覽視窗的改變發生改變並和預覽視窗寬高比一致。
圖示預覽圖的寬度和高度為:
#preview-pane .preview-container { width: 250px; height: 170px; overflow: hidden;}
修改為:
#preview-pane .preview-container { width: 220px; height: 220px; overflow: hidden;}
6.tutorial4.html
帶有各種動畫和過渡的選區變換、背景透明度和背景顏色的過渡轉變,很炫
7.tutorial5.html API Demo
demo 檔案夾中還提供了 crop.php,把選取的圖片真正剪裁出來。
更多內容:官方文檔
中文文檔
jQuery 圖片剪裁外掛程式初探之 Jcrop