From 5fc3dff2d5f1e538fcb5354c4fddc6497a1dba52 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sat, 3 Apr 2021 16:25:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=9C=BA=E5=9C=B0=E7=9A=84ui=EF=BC=8C=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=9C=8B=E5=88=B0=E9=BC=A0=E6=A0=87=E4=B8=8D=E5=90=8C=E6=8C=89?= =?UTF-8?q?=E9=94=AE=E5=AF=B9=E5=BA=94=E7=94=BB=E7=AC=94=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/custom_field.lua | 62 +++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/parts/scenes/custom_field.lua b/parts/scenes/custom_field.lua index 9ef1d67b..968c5f85 100644 --- a/parts/scenes/custom_field.lua +++ b/parts/scenes/custom_field.lua @@ -63,8 +63,7 @@ local function SPpath(x,y) end ins(SPlist,{x,y}) if #SPlist==1 then - local start=FIELD[page][y][x] - SPmode=start==0 and 0 or 1 + SPmode=FIELD[page][y][x]==0 and 0 or 1 end end local function SPdraw() @@ -100,6 +99,7 @@ local function SPdraw() end end SPlist={} + SPmode=0 end function scene.sceneInit() @@ -152,13 +152,7 @@ end function scene.wheelMoved(_,y) if penColor>0 then - if y<0 then - penColor=penColor+1 - if penColor==25 then penColor=1 end - else - penColor=penColor-1 - if penColor==0 then penColor=24 end - end + penColor=(penColor+(y<0 and 1 or -1)-1)%24+1 end end function scene.touchDown(x,y)scene.mouseDown(x,y,1)end @@ -329,9 +323,9 @@ function scene.draw() gc.rectangle("line",30*SPlist[i][1]-30+2,600-30*SPlist[i][2]+2,30-4,30-4,3) end else - gc.setColor(1,1,1) + gc.setColor(1,0,0) for i=1,#SPlist do - gc.draw(cross,30*SPlist[i][1]-30,600-30*SPlist[i][2]) + gc.draw(cross,30*SPlist[i][1]-30+math.random(-1,1),600-30*SPlist[i][2]+math.random(-1,1)) end end end @@ -345,20 +339,38 @@ function scene.draw() gc.rectangle("fill",50,600,100,6) --Draw pen color - if penColor>0 then - gc.setLineWidth(13) - gc.setColor(minoColor[penColor]) - gc.rectangle("line",565,495,70,70) - elseif penColor==-1 then - gc.setLineWidth(5) - gc.setColor(.9,.9,.9) - gc.line(575,505,625,555) - gc.line(575,555,625,505) - elseif penColor==-2 then - gc.setLineWidth(13) - gc.setColor(COLOR.rainbow(TIME()*6.2)) - gc.rectangle("line",565,495,70,70) - end + gc.translate(560,475) + --Right mouse button + gc.setLineWidth(3) + gc.setColor(1,1,1,.9) + gc.line(52,5,75,35) + gc.line(75,5,52,35) + --Left mouse button + if penColor>0 then + gc.setColor(minoColor[penColor]) + gc.rectangle("fill",5,5,23,30) + elseif penColor==-1 then + gc.line(5,5,28,35) + gc.line(28,5,5,35) + elseif penColor==-2 then + if SPmode==1 then + gc.setColor(1,0,0) + gc.line(5,5,28,35) + gc.line(28,5,5,35) + else + gc.setLineWidth(13) + gc.setColor(COLOR.rainbow(TIME()*12.6)) + gc.rectangle("fill",5,5,23,30) + end + end + --Draw mouse + gc.setLineWidth(2) + gc.setColor(1,1,1) + gc.rectangle("line",0,0,80,110,5) + gc.line(0,40,80,40) + gc.line(33,0,33,40) + gc.line(47,0,47,40) + gc.translate(-560,-475) --Confirm reset if sure>0 then