为了账号安全,请及时绑定邮箱和手机立即绑定

为什么做不出老师的效果呢?

为什么做不出老师的效果呢?

游赛腾 2017-02-06 16:59:53
//这是jsvar WINDOWS_WIDTH = 1024;var WINDOWS_HEIGHT = 768;var RADIUS = 8;var MARGIN_TOP = 60;var MARGIN_LEFT = 30;window.onload=function(){ var canvas = document.getElementById('myCanvas'); var context = canvas.getContext("2d"); canvas.width = WINDOWS_WIDTH; canvas.height = WINDOWS_HEIGHT; render(context);}function render(ctx){ var hours = 12; var minutes = 34; var seconds = 56;    renderDigit( MARGIN_LEFT , MARGIN_TOP , parseInt(hours/10) , ctx )    renderDigit( MARGIN_LEFT + 15*(RADIUS+1) , MARGIN_TOP , parseInt(hours%10) , ctx )    renderDigit( MARGIN_LEFT + 30*(RADIUS + 1) , MARGIN_TOP , 10 , ctx )    renderDigit( MARGIN_LEFT + 39*(RADIUS+1) , MARGIN_TOP , parseInt(minutes/10) , ctx);    renderDigit( MARGIN_LEFT + 54*(RADIUS+1) , MARGIN_TOP , parseInt(minutes%10) , ctx);    renderDigit( MARGIN_LEFT + 69*(RADIUS+1) , MARGIN_TOP , 10 , ctx);    renderDigit( MARGIN_LEFT + 78*(RADIUS+1) , MARGIN_TOP , parseInt(seconds/10) , ctx);    renderDigit( MARGIN_LEFT + 93*(RADIUS+1) , MARGIN_TOP , parseInt(seconds%10) , ctx);}function renderDigit(x,y,num,ctx){ ctx.fillStyle = "rgb(0,102,153)"; for (var i = 0; i < digit[num].length; i++) { for (var j = 0; j < digit[num][i].length; j++) { if(digit[num][i][j] == 1){ ctx.beginPath(); ctx.arc(x+j*2(RADIUS+1)+(RADIUS+1),y+i*2(RADIUS+1)+(RADIUS+1),RADIUS,0,2*Math.PI); ctx.closePath(); ctx.fill(); } } }}//这是index.html<!DOCTYPE html><html><head><meta charset="UTF-8"><title>myFirst</title></head><body><canvas id="myCanvas" style="display:block;margin:50px auto;">当前浏览器不支持canvas,请更换浏览器后再试</canvas><script src="digit.js"></script><script src="countdown.js"></script></body></html>
查看完整描述

1 回答

已采纳
?
心有猛虎_细嗅蔷薇

TA贡献119条经验 获得超250个赞

再帮你一次

ctx.arc(x+j*2(RADIUS+1)+(RADIUS+1),y+i*2(RADIUS+1)+(RADIUS+1),RADIUS,0,2*Math.PI);

仔细看,缺少了乘号 *

x+j*2*(RADIUS+1)

y+i*2*(RADIUS+1)

查看完整回答
反对 回复 2017-02-06
  • 游赛腾
    游赛腾
    我还以为是和数学一样,在数字和括号之间,可以忽略乘号。^_^谢谢 话说这个错误是怎么发现的?刚才检查错误都快检查疯了
  • 心有猛虎_细嗅蔷薇
    心有猛虎_细嗅蔷薇
    不知道你使用的编辑器是什么?我用的是WebStrom,会有错误检查提示的功能。
?
慕瓜9220888

TA贡献868条经验 获得超0个赞

SANMLQHRH

IJCENURLC

MQSEULRYF

OTAFZJEHY

KLQIBUEAN

PXJBXQZMM

EZUPERUQN

QIQVQGTZM

OFEFHRHTT

WAFKGZIVO

GKSHZJMIP

ALDMHRUNF

MXSLWZIPS

NXMBMWHRR

CNJOGPUQD

IQFNXXAMM

ZQPSKKNAJ

THZULYHXH

FWVTPPYHU

XYQOATTGZ

KYGLDGQTM

IGRTVFRBL

RIXBWJCCI

IJRASBHEE

YJZVXADMM

GMEXZCPIS

GRGOSZZIP

FKEPUERRH

FAZUCUBEH

RMAWVHNZL

TOQIUQDQW

TKDGFEEXN

NRAVQTWZC

IJRTRUUKA

GKYAEXHHK

SZVKMCLOK

DSGCBUKGQ

OFKGHRAXG

ECAPOXQTK

TUCKGJCPY

XEZIQJZIW

LMEGVGJPW

ETPXXKSCY

SDGLUXTDW

TRASLMBBC

CDOQYYDPP

GHPEJZPHB

OJEZOYRDN

UFEPRXANN

OLDYUXTAT

OFHGOBRKY

VTFHJZZIP

DUGRTWPVC

CDWHMPMFZ

XIHSHJVBY

GXIHCFSYE

NEPUILHKH

EXZRZTMJS

CQCSBEXAN

PHMHWNUKQ

BCKMEUHBM

NUQYKQJQG

VWRDVYLEY

VXWLTCPMP

JRDBQMURE

WNCOJMZIS

LCNSUUXDT

BCATBOMII

RPSRRVLCP

CURNZGOYY

KWMLGTNPC

SAGHQJTTG

QIKMNHZVV

MXZJYHAAT

VWOAFTMTZ

FJYQILBUB

CYRAHXDDJ

RTIKZFVCL

BZLQFQPPC

BSQSBLCLH

SXIHQPISV

YMYTFIYBN

BDFXCVRLU

SDZUNAQTF

XFEGEHKKA

VWEGLOBHK

QRJHZWJGG

OPNSORKDN

ULOQLVLOX

KOAVHUKXD

CNNTEHXAN

TOQFUKDGQ

FDVUMPVYV

EWRGIVRKH

NOQODDLIB

OPYTYRDWP

GKGVXGVLH

KSKCBUXYE

PKWKMPZIL

KINFEDGHX

QBDMNUGQG

PQVGPFIRE

UKTYXQJWW

GRPHGSMFP

JUDGPISLO

FGYAHTDMK

BMEJLVUZM

PQPXCCPYF

ELHIHKAQA

DSKZWSBBI

TWBWVIRYR

VQFHMSSPC

YJKJRUXDI

QBDWRROXX

XEGLGQJCS

PABHIYPYV

ZKTUDYYKA

JXZGORAXQ

CXYRZZCQK

PUCETGFMF

WXZEGGCCI

IGPPBUDDJ

FYBHJZZZW

JHHGFPMZJ

YJAFLRUYY

HMEGIYFLL

UYDFKXGDT

QBQYNAJZW

NLJYUUNZU

EONCPFIPY

KVTPEQAJQ

BSUMHUTWE

QEKWYMTYZ

KPNVRUPIR

ZUZLMTWKE

MKCBJURHD

AHQYQOBUH

ESUMVQPWP

KHTBGJMXH

DEDFVOUEU

OPUPOBJFP

YPOWRKNQA

UVNFAUXQT

NBKTIZQNX

KRNIUTNJD

NYNFAKXHZ

UPKSUKXAT

MNPUWJSCP

BCEJLVRUE

VWYQFTJGQ

VMHZIBIFS

FGVGCSBRL

YTWFKNWPC

JXVEFZSRV

BSBUDNOYS

ESETLHXUN

KVKVNXTNY

RSECREAAV

JASEDMVSL

IJBCYEHHT

ABJVGJDTC

WNPWXRTJQ

SJLTVOEOU

IZRQYLOHY

OWOMIMIVY

PGIXTJFNA

JTYKJMCIA

EFUQYLMCZ

TPFMBFJUB

WLILKRKKY

ODJEJTJWN

LQLQZZSLS

RCXWYBIYS

QHZOTWAJP

DRJIDJDZW

WUAYAGRYE

KLTONAWTT

AXTYDTWSA

JXGZPMMTU

OZKZTMJPF

查看完整回答
反对 回复 2021-10-19
  • 1 回答
  • 0 关注
  • 1116 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信