- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试从源 http://dougtesting.net/home 获取 winwheel ,我设置了所有内容并在 chrome 和 IE 9+ 上正常工作,但我需要让它在 IE 8 上工作。经过一番调查,我发现需要插入 excanvas.js 才能让 Canvas 在 IE 8 上工作,但它并没有解决我的问题仍然是 IE 8 显示错误“当前浏览器不支持 Canvas ”。
我的 HTML 代码:
<html>
<head>
<title>Wheel</title>
<link rel="stylesheet" href="main.css" type="text/css" />
<script type="text/javascript" src="excanvas.js"></script>
<script type="text/javascript" src="Winwheel.js"></script>
<script src="TweenMax.min.js"></script>
</head>
<body>
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div class="power_controls">
<br />
<br />
<table class="power" cellpadding="10" cellspacing="0">
<tr>
<th align="center">Power</th>
</tr>
<tr>
<td width="78" align="center" id="pw3" onClick="powerSelected(3);">High</td>
</tr>
<tr>
<td align="center" id="pw2" onClick="powerSelected(2);">Med</td>
</tr>
<tr>
<td align="center" id="pw1" onClick="powerSelected(1);">Low</td>
</tr>
</table>
<br />
<img id="spin_button" src="spin_off.png" alt="Spin" onClick="startSpin();" />
</div>
</td>
<td width="421" height="564" class="the_wheel" align="center" valign="center">
<canvas id="canvas" width="420" height="420">
<p style="{color: white}" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
</canvas>
</td>
</tr>
</table>
<script>
// Create new wheel object specifying the parameters at creation time.
var theWheel = new Winwheel({
'numSegments' : 20, // Specify number of segments.
'outerRadius' : 160, // Set outer radius so wheel fits inside the background.
'drawText' : false, // Code drawn text can be used with segment images.
'textFontSize' : 16,
'textOrientation' : 'curved',
'textAlignment' : 'inner',
'textMargin' : '90',
'textFontFamily' : 'monospace',
'textStrokeStyle' : 'black',
'textLineWidth' : 3,
'textFillStyle' : 'white',
'drawMode' : 'segmentImage', // Must be segmentImage to draw wheel using one image per segemnt.
'segments' : // Define segments including image and text.
[
{'image' : '1.png', 'text' : '379013000'},
{'image' : '2.png', 'text' : '379067000'},
{'image' : '3.png', 'text' : '379021000'},
{'image' : '4.png', 'text' : 'LOST'},
{'image' : '5.png', 'text' : '800041000'},
{'image' : '6.png', 'text' : '389081000'},
{'image' : '7.png', 'text' : '508056000'},
{'image' : '8.png', 'text' : 'EARN'},
{'image' : '9.png', 'text' : '389020000'},
{'image' : '10.png', 'text' : 'TURN'},
{'image' : '11.png', 'text' : '800042000'},
{'image' : '12.png', 'text' : '389020000'},
{'image' : '13.png', 'text' : '379068000'},
{'image' : '14.png', 'text' : 'EARN'},
{'image' : '15.png', 'text' : 'LOST'},
{'image' : '16.png', 'text' : '389081000'},
{'image' : '17.png', 'text' : '370180000'},
{'image' : '18.png', 'text' : '700002000'},
{'image' : '19.png', 'text' : '379067000'},
{'image' : '20.png', 'text' : '800044000'},
],
'animation' : // Specify the animation to use.
{
'type' : 'spinToStop',
'duration' : 5, // Duration in seconds.
'spins' : 8, // Number of complete spins.
'callbackFinished' : 'alertPrize()'
}
});
// Vars used by the code in this page to do power controls.
var wheelPower = 0;
var wheelSpinning = false;
// -------------------------------------------------------
// Function to handle the onClick on the power buttons.
// -------------------------------------------------------
function powerSelected(powerLevel)
{
// Ensure that power can't be changed while wheel is spinning.
if (wheelSpinning == false)
{
// Reset all to grey incase this is not the first time the user has selected the power.
document.getElementById('pw1').className = "";
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
// Now light up all cells below-and-including the one selected by changing the class.
if (powerLevel >= 1)
{
document.getElementById('pw1').className = "pw1";
}
if (powerLevel >= 2)
{
document.getElementById('pw2').className = "pw2";
}
if (powerLevel >= 3)
{
document.getElementById('pw3').className = "pw3";
}
// Set wheelPower var used when spin button is clicked.
wheelPower = powerLevel;
// Light up the spin button by changing it's source image and adding a clickable class to it.
document.getElementById('spin_button').src = "spin_on.png";
document.getElementById('spin_button').className = "clickable";
}
}
// -------------------------------------------------------
// Click handler for spin button.
// -------------------------------------------------------
function startSpin()
{
// Ensure that spinning can't be clicked again while already running.
if (wheelSpinning == false)
{
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
// to rotate with the duration of the animation the quicker the wheel spins.
if (wheelPower == 1)
{
theWheel.animation.spins = 3;
}
else if (wheelPower == 2)
{
theWheel.animation.spins = 8;
}
else if (wheelPower == 3)
{
theWheel.animation.spins = 15;
}
// Disable the spin button so can't click again while wheel is spinning.
document.getElementById('spin_button').src = "spin_off.png";
document.getElementById('spin_button').className = "";
// Begin the spin animation by calling startAnimation on the wheel object.
theWheel.startAnimation();
// Set to true so that power can't be changed and spin button re-enabled during
// the current animation. The user will have to reset before spinning again.
wheelSpinning = true;
}
}
// -------------------------------------------------------
// Function for reset button.
// -------------------------------------------------------
function resetWheel()
{
theWheel.stopAnimation(false); // Stop the animation, false as param so does not call callback function.
theWheel.rotationAngle = 0; // Re-set the wheel angle to 0 degrees.
theWheel.draw(); // Call draw to render changes to the wheel.
document.getElementById('pw1').className = ""; // Remove all colours from the power level indicators.
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
wheelSpinning = false; // Reset to false to power buttons and spin can be clicked again.
}
// -------------------------------------------------------
// Called when the spin animation has finished by the callback feature of the wheel because I specified callback in the parameters.
// -------------------------------------------------------
function alertPrize()
{
// Get the segment indicated by the pointer on the wheel background which is at 0 degrees.
var winningSegment = theWheel.getIndicatedSegment();
// Do basic alert of the segment text. You would probably want to do something more interesting with this information.
switch(winningSegment.text)
{
case "LOST": // lost 1k np
break;
case "EARN": // earn 1k np
break;
case "TURN": // do nothing
break;
default: // give item
}
}
</script>
</body>
</html>
错误显示:
http://screencast.com/t/23WeMNBXOH8N
在我看来,wheelwin 没有读取新 Canvas 。我该如何修复它?
提前致谢
最佳答案
我通过插入修复了它
<!--[if lte IE 8]><script type="text/javascript" src="themes/default/js/excanvas.js"></script><![endif]-->
完成后, Canvas 在 Internet Explorer 8 中正常工作。
下载链接:
https://github.com/arv/ExplorerCanvas/blob/master/excanvas.js
完整代码示例:
<!DOCTYPE html>
<html>
<head>
<title>Wheel</title>
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<link rel="stylesheet" href="themes/default/wheel.css" type="text/css" />
<!--[if lte IE 8]><script type="text/javascript" src="themes/default/js/excanvas.js"></script><![endif]-->
<script type="text/javascript" src="themes/default/js/Winwheel.js"></script>
<script src="themes/default/js/TweenMax.min.js"></script>
</head>
<body onload="initWinwheel();" oncontextmenu="return false" onselectstart="return false" ondragstart="return false" scroll="no">
<div align="center">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<div class="power_controls">
<br />
<br />
<table class="power" cellpadding="10" cellspacing="0">
<tr>
<th align="center">Power</th>
</tr>
<tr>
<td width="78" align="center" id="pw3" onClick="powerSelected(3);">High</td>
</tr>
<tr>
<td align="center" id="pw2" onClick="powerSelected(2);">Med</td>
</tr>
<tr>
<td align="center" id="pw1" onClick="powerSelected(1);">Low</td>
</tr>
</table>
<br />
<img id="spin_button" src="themes/default/images/wheel/spin_off.png" alt="Spin" onClick="startSpin();" />
</div>
</td>
<td width="421" height="564" class="the_wheel" align="center" valign="center">
<canvas id="canvas" width="420" height="420">
<p style="{color: white}" align="center">Sorry, your browser doesn't support canvas. Please try another.</p>
</canvas>
</td>
</tr>
</table>
<script>
var theWheel;
function initWinwheel() {
// Create new wheel object specifying the parameters at creation time.
theWheel = new Winwheel({
'numSegments' : 20, // Specify number of segments.
'outerRadius' : 160, // Set outer radius so wheel fits inside the background.
'drawText' : false, // Code drawn text can be used with segment images.
'textFontSize' : 16,
'textOrientation' : 'curved',
'textAlignment' : 'inner',
'textMargin' : '90',
'textFontFamily' : 'monospace',
'textStrokeStyle' : 'black',
'textLineWidth' : 3,
'textFillStyle' : 'white',
'drawMode' : 'segmentImage', // Must be segmentImage to draw wheel using one image per segemnt.
'segments' : // Define segments including image and text.
[
{'image' : 'themes/default/images/wheel/1.png', 'text' : '379013000'},
{'image' : 'themes/default/images/wheel/2.png', 'text' : '379067000'},
{'image' : 'themes/default/images/wheel/3.png', 'text' : '379021000'},
{'image' : 'themes/default/images/wheel/4.png', 'text' : 'LOST'},
{'image' : 'themes/default/images/wheel/5.png', 'text' : '800041000'},
{'image' : 'themes/default/images/wheel/6.png', 'text' : '389081000'},
{'image' : 'themes/default/images/wheel/7.png', 'text' : '508056000'},
{'image' : 'themes/default/images/wheel/8.png', 'text' : 'EARN'},
{'image' : 'themes/default/images/wheel/9.png', 'text' : '389020000'},
{'image' : 'themes/default/images/wheel/10.png', 'text' : 'TURN'},
{'image' : 'themes/default/images/wheel/11.png', 'text' : '800042000'},
{'image' : 'themes/default/images/wheel/12.png', 'text' : '389020000'},
{'image' : 'themes/default/images/wheel/13.png', 'text' : '379068000'},
{'image' : 'themes/default/images/wheel/14.png', 'text' : 'EARN'},
{'image' : 'themes/default/images/wheel/15.png', 'text' : 'LOST'},
{'image' : 'themes/default/images/wheel/16.png', 'text' : '389081000'},
{'image' : 'themes/default/images/wheel/17.png', 'text' : '370180000'},
{'image' : 'themes/default/images/wheel/18.png', 'text' : '700002000'},
{'image' : 'themes/default/images/wheel/19.png', 'text' : '379067000'},
{'image' : 'themes/default/images/wheel/20.png', 'text' : '800044000'},
],
'animation' : // Specify the animation to use.
{
'type' : 'spinToStop',
'duration' : 5, // Duration in seconds.
'spins' : 5, // Number of complete spins.
'callbackFinished' : 'alertPrize()'
}
});
}
// Vars used by the code in this page to do power controls.
var wheelPower = 0;
var wheelSpinning = false;
// -------------------------------------------------------
// Function to handle the onClick on the power buttons.
// -------------------------------------------------------
function powerSelected(powerLevel)
{
// Ensure that power can't be changed while wheel is spinning.
if (wheelSpinning == false)
{
// Reset all to grey incase this is not the first time the user has selected the power.
document.getElementById('pw1').className = "";
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
// Now light up all cells below-and-including the one selected by changing the class.
if (powerLevel >= 1)
{
document.getElementById('pw1').className = "pw1";
}
if (powerLevel >= 2)
{
document.getElementById('pw2').className = "pw2";
}
if (powerLevel >= 3)
{
document.getElementById('pw3').className = "pw3";
}
// Set wheelPower var used when spin button is clicked.
wheelPower = powerLevel;
// Light up the spin button by changing it's source image and adding a clickable class to it.
document.getElementById('spin_button').src = "themes/default/images/wheel/spin_on.png";
document.getElementById('spin_button').className = "clickable";
}
}
// -------------------------------------------------------
// Click handler for spin button.
// -------------------------------------------------------
function startSpin()
{
// Ensure that spinning can't be clicked again while already running.
if (wheelSpinning == false)
{
// Based on the power level selected adjust the number of spins for the wheel, the more times is has
// to rotate with the duration of the animation the quicker the wheel spins.
if (wheelPower == 1)
{
theWheel.animation.spins = 3;
}
else if (wheelPower == 2)
{
theWheel.animation.spins = 8;
}
else if (wheelPower == 3)
{
theWheel.animation.spins = 15;
}
// Disable the spin button so can't click again while wheel is spinning.
document.getElementById('spin_button').src = "themes/default/images/wheel/spin_off.png";
document.getElementById('spin_button').className = "";
// Begin the spin animation by calling startAnimation on the wheel object.
theWheel.startAnimation();
// Set to true so that power can't be changed and spin button re-enabled during
// the current animation. The user will have to reset before spinning again.
wheelSpinning = true;
//sendCmd2("EMPTY","-1", readCookie("CHAR"));
}
}
// -------------------------------------------------------
// Function for reset button.
// -------------------------------------------------------
function resetWheel()
{
theWheel.stopAnimation(false); // Stop the animation, false as param so does not call callback function.
theWheel.rotationAngle = 0; // Re-set the wheel angle to 0 degrees.
theWheel.draw(); // Call draw to render changes to the wheel.
document.getElementById('pw1').className = ""; // Remove all colours from the power level indicators.
document.getElementById('pw2').className = "";
document.getElementById('pw3').className = "";
wheelSpinning = false; // Reset to false to power buttons and spin can be clicked again.
}
// -------------------------------------------------------
// Called when the spin animation has finished by the callback feature of the wheel because I specified callback in the parameters.
// -------------------------------------------------------
function alertPrize()
{
// Get the segment indicated by the pointer on the wheel background which is at 0 degrees.
var winningSegment = theWheel.getIndicatedSegment();
if(winningSegment.text == "")
return;
// Do basic alert of the segment text. You would probably want to do something more interesting with this information.
switch(winningSegment.text)
{
case "LOST": // lost 1k np
sendCmd("+np_give","-1000", readCookie("CHAR"));
break;
case "EARN": // earn 1k np
sendCmd("+np_give","1000", readCookie("CHAR"));
break;
case "TURN": // do nothing
sendCmd("EMPTY","0", readCookie("CHAR"));
break;
default: // give item
sendCmd("+give_item",winningSegment.text, readCookie("CHAR"));
}
winningSegment.text = "";
}
function sendCmd(command, giveitem,character)
{
$.ajax({ url: 'https://titan.maxko.org/?page=async',
data: {cmd: command, item: giveitem, chars: character},
type: 'post',
success: function(output) {
//alert(output);
}
});
}
// Cookies
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
var expires = "; expires=" + date.toGMTString();
}
else var expires = "";
document.cookie = name + "=" + value + expires + "; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name, "", -1);
}
</script>
</body>
</html>
关于javascript - Winwheel IE 8 Canvas ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40518654/
我可以使用两种方法添加一个 child ,一种是 Canvas.AddVisualChild(Visual); Canvas.AddLogicalChild(Visual); 我在视觉对象的 Draw
在过去的几周里,我一直在尝试各种方法,试图找到将 BDD 用于依赖于 HTML5 Canvas 元素以及用户与之交互的 Web 应用程序的最佳方法。 我一直在使用 Jasmine 和 Cucumber
我正在尝试完成撤消/重做。我正在使用loadFromJSON(...)从我存储在数组中的 Canvas 状态重新构建 Canvas 。基本上,我的想法是破坏现有的 Canvas 并重新构建 Canva
我正在尝试在 Canvas 上设置简单的放大/缩小功能。我正在使用 KineticJS 处理触摸事件并在 Canvas 中绘图,但无法实现缩放。 KinteicJS 有一个类似的例子,但它们总是在中心
我正在使用 processing.js 在 javascript 中开发一个画笔应用程序 它正在使用 Canvas 对象。我想在 Canvas 的背景中保留一个图像。在前景中画一些东西。在保存时,我只
您好,我想为 discord.js Bot 安装 Canvas 。 当我尝试使用以下命令安装 Canvas 时npm install canvas我收到以下错误: pi@server:~/Bots/D
我正在尝试使用 Canvas 和动力学的组合来构建填充图案,但在尝试获得连续线时遇到了问题。 此 jsfiddle显示了到目前为止我所拥有的,但是因为我的重复模式是正方形,角会影响线条,我尝试使用 l
我正在开发一个 webassembly 程序。 我可以使用 emscripten_set_canvas_size 设置 Canvas 大小(我一直读到我需要切换到新的 API,因为这个 API 会贬值
您好,我已经为第一个 Canvas 中的第一个图像创建了一个圆形表单,但我没有成功使用第一个 Canvas 的 dataURL 并将其添加到第二个 Canvas 中。 这是我的 fiddle :htt
问题在于不同浏览器之间的不一致。 使用Dart Chrome,JS Chrome,JS Opera运行 双击可以进入和退出全屏 m_oCanvas.width =(window.screen.widt
我正在使用Flutter框架和Dart开发图像编辑器,因此无法将矩阵滤镜应用于 Canvas 。 我正在尝试使用“Paint”类和“canvas.drawPaint(paint)”函数将矩阵过滤器应用
如果在已经具有非整数比例因子的 Canvas 上绘制图像,我会遇到 Canvas 上下文drawImage()方法的问题。似乎这样的图像以一种奇怪的方式被剪切(有时图像的最右边的部分被剪切,有时是最底
Canvas 的“宽度”属性值有限制吗? 在下面的示例中,我在 ScrolledWindow 中创建一个 Canvas。 # Packages package require BWidget # Ma
我正在尝试制作类似于 this article 底部的效果的文本效果 我建议的方法是: 制作两个 Canvas ,一个是可见的,另一个是不可见的我用它作为缓冲区。 在缓冲区 Canvas 上绘制一些文
例如var new = canvas.toDataURL("image/png"); 我希望这个新变量中存在的 base64 显示到存在的第二个 Canvas 元素中。但是它不使用 drawimage
有人有使用这两个 Node.js 库中的一个或两个的经验吗?很想知道每个人的成功或困难。 最佳答案 LearnBoost是社区中最多产的 Node 模块开发人员之一,因此我选择使用 node-canv
如何知道 Canvas 运行的是“WebGL”还是普通 Canvas ? 通过检查源代码,我发现这两种情况都是 Canvas 。 最佳答案 这真的取决于你想如何去发现。 例如你可以这样调用 `getC
在 Canvas 上绘图非常好。甚至橡皮擦也能正常工作。问题是,当 Canvas 保存为图像时,它绘制的是黑线而不是橡皮擦。 为了更好地理解,我添加了屏幕截图和代码。 1。在删除绘图时 - 一个。源代
我正在尝试为 Canvas 附加鼠标悬停和鼠标移出事件: 默认 Canvas 是函数drawcircle的 Canvas 。 如果用户越过 Canvas ,应将其更改为drawEllipse的 Can
我正在使用 Three.js 构建一个简单的 2D 游戏。我只使用世界的 X 和 Y 位置来移动对象,将它们的 z 位置保留为零。我使用禁用旋转的 TrackballControls,以允许使用右键单
我是一名优秀的程序员,十分优秀!