html5星空效果图,HTML5 canvas炫酷星空背景特效

jquery-warpdrive-plugin是一款可以制作基于HTML5 canvas的炫酷星空背景特效的jquery插件。这个星空背景特效可通过配置参数进行灵活的配置,可用鼠标进行互动。

使用方法

在页面中引入jquery和jquery.warpdrive.min.js文件。

HTML结构

使用空的一个

元素来作为星空背景的容器。

初始化插件

在页面DOM元素加载完毕之后,可以通过纯js的方法来初始化该星空背景插件,或将它作为一个jquery插件来使用。

作为jquery插件来使用。

$( '#holder' ).warpDrive();

通过js方法来使用。

var warpdrive = new WarpDrive( document.getElementById( 'holder' ) );

配置参数

该html5星空背景特效插件的可用配置参数如下:

var settings = {

width: 480,/*width*/

height: 480,/*height*/

autoResize: false,/*enable/disable autoResize*/

autoResizeMinWidth: null,/*set autoResize min width*/

autoResizeMaxWidth: null,/*set autoResize max width*/

autoResizeMinHeight: null,/*set autoResize min height*/

autoResizeMaxHeight: null,/*set autoResize max height*/

addMouseControls: true,/*enable/disable mouse controls*/

addTouchControls: true,/*enable/disable touch controls*/

hideContextMenu: true,/*enable/disable canvas context menu*/

starCount: 6666,/*count of active/moving stars*/

starBgCount: 2222,/*count of inactive/background stars*/

starBgColor: { r:255, g:255, b:255 },/*background stars color*/

starBgColorRangeMin: 10,/*background stars color range min of starBgColor*/

starBgColorRangeMax: 40,/*background stars color range max of starBgColor*/

starColor: { r:255, g:255, b:255 },/*stars color*/

starColorRangeMin: 10,/*stars color range min of starBgColor*/

starColorRangeMax: 100,/*stars color range max of starBgColor*/

starfieldBackgroundColor: { r:0, g:0, b:0 },/*background color*/

starDirection: 1,/*stars moving in which direction*/

starSpeed: 20,/*stars moving speed*/

starSpeedMax: 200,/*stars moving speed max*/

starSpeedAnimationDuration: 2,/*time in seconds from starSpeed to starSpeedMax*/

starFov: 300,/*field of view*/

starFovMin: 200,/*field of view min*/

starFovAnimationDuration: 2,/*time in seconds from starFov to starFovMin*/

starRotationPermission: true,/*enable/disable rotation*/

starRotationDirection: 1,/*rotation direction*/

starRotationSpeed: 0.0,/*rotation speed*/

starRotationSpeedMax: 1.0,/*rotation speed max*/

starRotationAnimationDuration: 2,/*time in seconds from starRotationSpeed to starRotationSpeedMax*/

starWarpLineLength: 2.0,/*line length*/

starWarpTunnelDiameter: 100,/*tunnel diameter*/

starFollowMouseSensitivity: 0.025,/*mouse follow sensitivity*/

starFollowMouseXAxis: true,/*enable/disable mouse follow x axis*/

starFollowMouseYAxis: true/*enable/disable mouse follow y axis*/

};

以jquery插件的方式来调用配置参数:

$( '#holder' ).warpDrive( settings );

通过纯js的方法来调用配置参数:

var warpdrive = new WarpDrive( document.getElementById( 'holder' ), settings );

方法

该html5星空背景特效插件有两个可用的方法用于暂停和继续播放星空动画。

jquery:

$( '#holder' ).warpDrive( 'pause' );

$( '#holder' ).warpDrive( 'unpause' );

js:

warpdrive.pause();

warpdrive.unpause();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值