Skip to content

Commit

Permalink
feat: Bitmap.setImage add crossOrigin setting
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Apr 17, 2019
1 parent 6c2b493 commit 9bf272b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/loader/ImageLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var ImageLoader = Class.create({

var image = new Image();
if(data.crossOrigin){
image.crossOrigin = data.crossOrigin;
image.crossOrigin = "Anonymous";
}

image.onload = function(){
Expand Down
4 changes: 2 additions & 2 deletions src/loader/LoadQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var LoadQueue = Class.create(/** @lends LoadQueue.prototype */{
* <li><b>loader</b> - specified resource loader. If you specify this,we abandon choosing loader inside</li>
* <li><b>noCache</b> - a tag that set on or off to prevent cache,implemented by adding timestamp inside</li>
* <li><b>size</b> - predicted resource size, help calculating loading progress</li>
* <li><b>crossOrigin</b> - Whether cross-domain is needed. eg:crossOrigin='anonymous'</li>
* <li><b>crossOrigin</b> - Whether cross-domain is needed, default is false</li>
* </ul>
* @returns {LoadQueue} 下载队列实例本身。
*/
Expand All @@ -76,7 +76,7 @@ var LoadQueue = Class.create(/** @lends LoadQueue.prototype */{
* <li><b>loader</b> - 指定资源的加载器。默认会根据资源类型来自动选择加载器,若指定loader,则会使用指定的loader来加载资源。</li>
* <li><b>noCache</b> - 指示加载资源时是否增加时间标签以防止缓存。</li>
* <li><b>size</b> - 资源对象的预计大小。可用于预估下载进度。</li>
* <li><b>crossOrigin</b> - 是否需要跨域,例如:crossOrigin='anonymous'</li>
* <li><b>crossOrigin</b> - 是否需要跨域,默认否。</li>
* </ul>
* @returns {LoadQueue} 下载队列实例本身。
*/
Expand Down
20 changes: 12 additions & 8 deletions src/view/Bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
* @augments View
* @param {Object} properties the options of create Instance.It can contains all writable property and Moreover:
* <ul>
* <li><b>image</b> - the image of bitmap which contained。required。</li>
* <li><b>rect</b> - the range of bitmap in the image。option</li>
* <li><b>image</b> - the image of bitmap which contained, required.</li>
* <li><b>rect</b> - the range of bitmap in the image, option</li>
* <li><b>crossOrigin</b> - Whether cross-domain is needed, default is false</li>
* </ul>
* @module hilo/view/Bitmap
* @requires hilo/core/Hilo
Expand All @@ -40,7 +41,8 @@
* @param {Object} properties 创建对象的属性参数。可包含此类所有可写属性。此外还包括:
* <ul>
* <li><b>image</b> - 位图所在的图像image。必需。</li>
* <li><b>rect</b> - 位图在图像image中矩形区域。</li>
* <li><b>rect</b> - 位图在图像image中矩形区域。可选。</li>
* <li><b>crossOrigin</b> - 是否设置crossOrigin。默认否。</li>
* </ul>
* @module hilo/view/Bitmap
* @requires hilo/core/Hilo
Expand Down Expand Up @@ -70,19 +72,21 @@
/**
* @language=en
* set the image。
* @param {Image|String} Image Object or URL。
* @param {Array} rect the range of bitmap in the image。
* @param {Image|String} Image Object or URL.
* @param {Array} rect the range of bitmap in the image, option.
* @param {Boolean} Whether cross-domain is needed, default is false.
* @returns {Bitmap} self。
*/
/**
* @language=zh
* 设置位图的图片。
* @param {Image|String} image 图片对象或地址。
* @param {Array} rect 指定位图在图片image的矩形区域。
* @param {Array} rect 指定位图在图片image的矩形区域。可选。
* @param {Boolean} 是否设置 crossOrigin,默认否。
* @returns {Bitmap} 位图本身。
*/
setImage: function(image, rect){
this.drawable.init({image:image, rect:rect});
setImage: function(image, rect, crossOrigin){
this.drawable.init({image:image, rect:rect, crossOrigin:crossOrigin});
if(rect){
this.width = rect[2];
this.height = rect[3];
Expand Down
2 changes: 1 addition & 1 deletion src/view/Drawable.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var Drawable = Class.create(/** @lends Drawable.prototype */{
//load image dynamically
var img = new Image();
if(properties.crossOrigin){
img.crossOrigin = properties.crossOrigin;
img.crossOrigin = "Anonymous";
}
img.onload = function(){
img.onload = null;
Expand Down

0 comments on commit 9bf272b

Please sign in to comment.