如何将JQuery JCrop置于图片的中心 [英] How to center JQuery JCrop in the center of the picture

查看:91
本文介绍了如何将JQuery JCrop置于图片的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在图片的中心开始JCrop选择。有办法吗?

I want to start JCrop selection in the center of the picture. Is there a way to do it?

有选项还是什么?它没有在手册中指定。

Is there a option or something? It's not specified in the manual.

我们必须手动计算吗?

推荐答案

万一你无法弄清楚如何在中心设置选择:

In case you are not able to figure out how to set the selection in the centre :

检查设置选项 http://deepliquid.com/content/Jcrop_Manual.html#Setting_Options

这样的事情(取自API参考):

Something like this (taken from the API ref) :

<script language="Javascript">

    jQuery(function($) {
        $('#target').Jcrop({
            onSelect:    showCoords,
            bgColor:     'black',
            bgOpacity:   .4,
            setSelect:   [ x, y, x1, y1 ],
            aspectRatio: 16 / 9
        });
    });

</script>

如果 w是宽度 h是所需选择的高度 W是图像的宽度 H是图像的高度,坐标为

x = W/2 - w/2
y = H/2 - h/2
x1 = x + w
y1 = y + h

(我希望我的数学是正确的:)

(I hope my math is right :)

这篇关于如何将JQuery JCrop置于图片的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆