本來是要用一天的變化的(但是0:15那邊好像顏色不是很正確) #**誰家半夜天還那麼亮** ![](https://i.imgur.com/PfQDbMi.gif)
运行程式开始灌水 ``` setInterval(()=> { fetch("https://codelove.tw/@yydsAwA/post/2andkx")},100) ```
好了 ``` const fill_rect = hmUI.createWidget(hmUI.widget.FILL_RECT, { x: 0, y: 0, w: 192 * 4, //768 h: 490, radius: 20, color: 0x5BA33D }) let canmove=true fill_rect.addEventListener(hmUI.event.CLICK_DOWN, (info) => { if(canmove){UI_move_for_easeInOutQuart(oTo, { x: info.x, y: info.y }) canmove=false } }) let oToxy = { x: 70, y: 150 } let oTo = hmUI.createWidget(hmUI.widget.TEXT, { x: oToxy.x, y: oToxy.y, w: 70, h: 25, color: "0x000000", text_size: 20, text_style: hmUI.text_style.WRAP, text: "史莱姆" }); function easeInOutQuad(t, b, c, d) { t /= d/2; if (t < 1) return c/2*t*t + b; t--; return -c/2 * (t*(t-2) - 1) + b; } //easeInOutQuad(count, wansixy.y, moveend, 20)//0.1*20=2秒 /* t是當前時間 b是起始值 c是值的變化 d是持續時間 */ function UI_move_for_easeInOutQuart(UI, xy) { let wansixy = { x: oToxy.x, y: oToxy.y } let count=0 let moveendy = xy.y-wansixy.y let moveendx = xy.x-wansixy.x let timers = timer.createTimer(15, 10, (function(e) { count++; UI.setProperty(hmUI.prop.MORE, { x: (oToxy.x=easeInOutQuad(count, wansixy.x, moveendx, 20)), y: (oToxy.y=easeInOutQuad(count, wansixy.y, moveendy, 20)), }) if (count>=20) { canmove=true timer.stopTimer(timers) } })) } ```
我主要是想寫個解方程式的程式碼
``` var time_val; var go_timer; var stop_time = 0; function add_zero(num, digit) { let numString = String(num) while (numString.length < digit) { numString = "0" + numString } return numString } go_timer = new Date(); time_val = setInterval(() => { let temp_timer = new Date().getTime() - go_timer.getTime(); let day = add_zero(Math.floor(temp_timer / 1000 / 60 / 60 / 24), 2); let hours = add_zero(Math.floor(temp_timer / 1000 / 60 / 60) % 24, 2); let minutes = add_zero(Math.floor(temp_timer / 1000 / 60) % 60, 2); let seconds = add_zero(Math.floor(temp_timer / 1000 % 60), 2); let milliseconds = add_zero(temp_timer % 1000, 3); var timers = [day, hours, minutes, seconds, milliseconds]; console.log(timers[0] + "天\n" + timers[1] + "時\n" + timers[2] + "分\n" + timers[3] + "秒\n" + timers[4] + "毫秒"); }, 1)
``` function hexToRgb(hex) { let result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? { r: parseInt(res...
#程式码如下 --- ###JavaScript ``` const fill_rect=hmUI.createWidget(hmUI.widget.FILL_RECT, { x: 0, y: 0, w: 192 * 4, //768 ...
#我要做一個自動解方程 主控臺 --- "Error solving equation: Invalid left hand side of assignment operator = (char 5) Return:a + 27 = 0" --- ```<!DOCTYPE ...
然後作為一個計時器可是總是顯示undefined 小米手環文件 https://cdn.discordapp.com/attachments/1132882463522312204/1132987644255670322/helloworld_pro.bin ``` var time_val...
我要做一個檢測undefined值的 代碼: data = { highscore: 0, localStorage: null, footsteps: 0, start: 0, checkin: 0, health: 6, fed: 0, birthday: Date.now(...
精選技術文章、免費程式設計資源、以及業界重要新聞!