[setup] global Points, Snap, WF, HF, SmFont, MedFont, LgFont, LeftBox, RightBox, Shortcut Points = 0 ' Current number of points in spline ' Erase = 0 ' UNKNOWN PURPOSE UseModel = 0 ' Flag for background bitmap WorkBackg = 0 ' Flag for Reference spline WhiteGrid = 0 ' Flag for Light colored Grid NoGrid = 0 ' Flag for turning off grid display Snap = 0 ' Flag for Snap ' Snap2 = 1 WindowWidth = 1024' JustBasic opens program window of this width WindowHeight = 768 ' JustBasic opens program window of this height WF = 1 ' Width multiplier for other screen resolutions HF = 1 ' Height multiplier for other screen resolutions SmFont = 9 MedFont = 11 LgFont = 12 dim XandY (500, 3) ' Array to hold the clicked X or Y value XandY (0, 3) = 1 ' [ ] What is the purpose of initializing this? dim Background (500, 3) ' Array to hold a previous shape to be used as the background for a new drawing Background (0, 3) = 1 ' [ ] What is the purpose of initializing this? dim info$(10, 10) ' For [checkfile] fileExists( ) function - see Function definition section ' F1 through F12 _VK_F1 through _VK_F16 KeyF1$ = chr$(_VK_F1) KeyF2$ = chr$(_VK_F2) KeyF3$ = chr$(_VK_F3) KeyF4$ = chr$(_VK_F4) KeyF5$ = chr$(_VK_F5) KeyF6$ = chr$(_VK_F6) KeyF7$ = chr$(_VK_F7) KeyF8$ = chr$(_VK_F8) KeyF9$ = chr$(_VK_F9) KeyF10$ = chr$(_VK_F10) KeyF11$ = chr$(_VK_F11) KeyF12$ = chr$(_VK_F12) ' 0 through 9 on regular keyboard _VK_0 through _VK_9 ' 0 through 0 on number pad _VK_NUMPAD0 through _VK_NUMPAD9 ' a through z _VK_A through _VK_Z ' Alt _VK_MENU KeyAlt$ = chr$(_VK_MENU) ' Shift _VK_SHIFT KeyShift$ = chr$(_VK_SHIFT) ' Home _VK_HOME KeyHome$ = chr$(_VK_HOME) ' End _VK_END KeyEnd$ = chr$(_VK_END) ' Insert _VK_INSERT KeyInsert$ = chr$(_VK_INSERT) ' Delete _VK_DELETE KeyDelete$ = chr$(_VK_DELETE) ' NumLock _VK_NUMLOCK KeyNumLock$ = chr$(_VK_NUMLOCK) ' Arrow Up _VK_UP KeyArrowUp$ = chr$(_VK_UP) ' Arrow Down _VK_DOWN KeyArrowDown$ = chr$(_VK_DOWN) ' Arrow Left _VK_LEFT KeyArrowLeft$ = chr$(_VK_LEFT) ' Arrow Right _VK_RIGHT KeyArrowRight$ = chr$(_VK_RIGHT) Color$ = "black, blue, brown, buttonface, cyan, darkblue, darkcyan, darkgray, darkgreen, darkpink, darkred, green, lightgray, palegray, pink, red, white, yellow" ' use WORD$( Color$, n , "," ) Thickness$ = "1, 1, 1, 2, 0" ' nomainwin open "PointWriter 1.0 for POV-Ray by Christian Nevado (Last Point) (Current Point) (Mouse Position) From Last to Mouse:" for graphics_nf_nsb as #grid #grid, "trapclose [quit]" print #grid, "setfocus" ' ##### end setup ' ' ' ' ' ' ' ' ' '12345678911234567892123456789312345678941234567895123456789612345678971234567898 ' Main Program Loop [Loop] ' while RunProgram = 1 'scan '#grid, "when characterInput [letter]" ' Need/should this be here if already have other input section? if UseModel = 1 then if fileExists(DefaultDir$, "Model.bmp") then loadbmp "model", "Model.bmp" ' Uden komplet sti søger programmet denne fil i sin egen mappe ' Unless specifying a complete path, Place this file in the PointWriter folder #grid, "backcolor white ; background model" #grid, "drawsprites" ' Actually displays the background bitmap else UseModel = 0 notice "File Error - Model.bmp does not exist" end if end if if NoGrid = 0 then ' plot grid ' define grid colors select case case (WhiteGrid = 1) and (Snap = 0)' and (Snap2 = 0) GridCol$="white" case (WhiteGrid = 1) and (Snap = 2) '(Snap2 = 1) GridCol$="pink" case (WhiteGrid = 1) and (Snap = 1) GridCol$="pink" case (WhiteGrid = 0) and (Snap = 2) '(Snap2 = 1) GridCol$="darkpink" case (WhiteGrid = 0) and (Snap = 1) GridCol$="darkpink" case else GridCol$="blue" end select ' Define position and extent of axis lines Leftmost = 25 Rightmost = 900 Lower = 675 Upper = 24 LineOffset = 50 ' Draw Main Y Axis (X = 0) FromX = (LineOffset*WF)+(400*CenterY)*WF : FromY = (Upper+2)*HF : ToX = FromX : ToY = Lower*HF call DrawLine 4, GridCol$, FromX, FromY, ToX, ToY ' Draw Main X Axis (Y = 0) FromX = Leftmost*WF : FromY = (650*HF)-(300*CenterX*HF) : ToX = Rightmost*WF : ToY = FromY call DrawLine 4, GridCol$, FromX, FromY, ToX, ToY ' Plot out grid and axis labels on screen TextOffset = 10 Adjustment = 0 DoubleDigitShift = 15 for DashY = 1 to 13 ' Horizontal selections along y if DashY < 3 then Adjustment = 1 ' Shift numbers from 10 up to align with 1-9 end if for AxisLine = 0 to 4 Thickness = val(WORD$( Thickness$, AxisLine , "," )) ' MouseX/(50*WF)-8*CenterY-1;" , "; (650*HF-MouseY)/(50*HF)-6*CenterX FromX = Leftmost*WF : FromY = (DashY*LineOffset*HF)-(AxisLine*12.5*HF) : ToX = Rightmost*WF : ToY = FromY if FromY > Upper-1 then call DrawLine Thickness, GridCol$, FromX, FromY, ToX, ToY end if ' Y-axis numeric labels #grid, "backcolor white ; font Arial 15 ; color black ; up ; place ";_ (TextOffset*WF)+(415*CenterY*WF)-(DoubleDigitShift*Adjustment*WF);" ";(DashY*LineOffset*HF)+(7*HF);" ; down ;\ ";13-6*CenterX-DashY; next AxisLine next DashY for DashX = 1 to 17 ' Vertical selections along x if DashX > 9 then Adjustment = 1 end if for AxisLine = 0 to 4 Thickness = val(WORD$( Thickness$, AxisLine , "," )) FromX = ((DashX)*LineOffset*WF)+(AxisLine*12.5*HF) : FromY = (Upper+1)*HF : ToX = FromX : ToY = Lower*HF call DrawLine Thickness, GridCol$, FromX, FromY, ToX, ToY ' X-axis numeric labels #grid, "backcolor white ; font Arial 15 ; color black ; up ; place ";_ (DashX*LineOffset)-(DoubleDigitShift*Adjustment)+(CenterY*XShift);" ";700-325*CenterX;" ; down ;\ ";DashX-(8*CenterY)-1; next AxisLine next DashX else ' do not plot grid end if ' end no grid or grid [Menu] ' Display Menu ' Main Screen Layout WF = 1 HF = 1 LeftBox = 900 RightBox = 1000 Shortcut = 1003 #grid, "font Arial ";Font0;" ; backcolor white ; color black ; place ";45*WF;" ";17*HF;_ " ; down ;\ Press arrow key between clicks for V or H lines" ' Menu Item - HELP #grid, "size 1 ; font Arial ";Font1;" bold ; color blue ; backcolor white ; up ; place ";LeftBox*WF;" ";25*HF;_ " ; down ; boxfilled ";RightBox*WF;" ";100*HF;" ; place ";905*WF;" ";45*HF;" ;\ PointWriter" #grid, "up ; place ";905*WF;" ";65*HF;" ;\ for POVRay" #grid, "backcolor white ; place ";Shortcut*WF;" ";65*HF;" ;\H" ' Points out of 500 Counter #grid, "font Arial ";Font2;" bold ; place ";910*WF;" ";90*HF;" ;\ ";Points;" / ";500-Points 'call MenuItem BoxColor$, TextColor$, AtY, Nudge, Item$, Shortcut$ ' Menu Item - NEW MenuY=100 call MenuItem "cyan", "black", MenuY, 25, "New", "N", LeftBox, RightBox, Shortcut '#grid, "color black ; backcolor cyan ; up ; place ";LeftBox*WF;" ";100*HF;" ; down ; boxfilled ";RightBox*WF;" ";125*HF;" ; place ";925*WF;" ";120*HF;" ;\ New" '#grid, "backcolor white ; place ";Shortcut*WF;" ";120*HF;" ;\N" MenuY = MenuY + 25 'call MenuItem "cyan", "black", AtY, Nudge, Item$, Shortcut$ ' Menu Item - UNDO #grid, "backcolor yellow ; up ; place ";LeftBox*WF;" ";125*HF;" ; down ; boxfilled ";RightBox*WF;" ";150*HF;_ " ; place ";925*WF;" ";145*HF;" ;\ Undo" #grid, "backcolor white ; place ";Shortcut*WF;" ";145*HF;" ;\Z" ' Menu Item - EDIT #grid, "backcolor yellow ; up ; place ";LeftBox*WF;" ";150*HF;" ; down ; boxfilled ";RightBox*WF;" ";175*HF;_ " ; place ";930*WF;" ";170*HF;" ;\Edit" #grid, "backcolor white ; place ";Shortcut*WF;" ";170*HF;" ;\E" ' Menu Item - CENTER X #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";175*HF;" ; down ; boxfilled ";RightBox*WF;" ";200*HF;_ " ; place ";915*WF;" ";195*HF;" ;\ Center X" #grid, "backcolor white ; place ";Shortcut*WF;" ";195*HF;" ;\X" ' Menu Item - CENTER Y #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";200*HF;" ; down ; boxfilled ";RightBox*WF;" ";225*HF;_ " ; place ";915*WF;" ";220*HF;" ;\ Center Y" #grid, "backcolor white ; place ";Shortcut*WF;" ";220*HF;" ;\Y" ' Menu Item - MODEL BITMAP FILE #grid, "backcolor lightgray ; up ; place ";LeftBox*WF;" ";225*HF;" ; down ; boxfilled ";RightBox*WF;" ";250*HF;_ " ; place ";905*WF;" ";245*HF;" ;\'Model.bmp'" #grid, "backcolor white ; place ";(Shortcut-1)*WF;" ";245*HF;" ;\M" ' Menu Item - WHITE GRID #grid, "backcolor lightgray ; up ; place ";LeftBox*WF;" ";250*HF;" ; down ; boxfilled ";RightBox*WF;" ";275*HF;_ " ; color white ; place ";905*WF;" ";268*HF;" ;\ White" #grid, "color black ; up ; place ";955*WF;" ";268*HF;" ;\ grid" #grid, "backcolor white ; place ";(Shortcut-2)*WF;" ";268*HF;" ;\W" ' Menu Item - NO GRID #grid, "backcolor lightgray ; up ; place ";LeftBox*WF;" ";275*HF;" ; down ; boxfilled ";RightBox*WF;" ";300*HF;_ " ; place ";915*WF;" ";293*HF;" ;\ No grid" #grid, "backcolor white ; place ";Shortcut*WF;" ";293*HF;" ;\G" ' Menu Item - SAVE WORK #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";300*HF;" ; down ; boxfilled ";RightBox*WF;" ";325*HF;_ " ; place ";905*WF;" ";320*HF;" ;\ Save work" #grid, "backcolor white ; place ";Shortcut*WF;" ";320*HF;" ;\S" ' Menu Item - RELOAD WORK #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";325*HF;" ; down ; boxfilled ";RightBox*WF;" ";350*HF;_ " ; place ";907*WF;" ";345*HF;" ;\Load work" #grid, "backcolor white ; place ";Shortcut*WF;" ";345*HF;" ;\R" ' Menu Item - WORK IN BACK #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";350*HF;" ; down ; boxfilled ";RightBox*WF;" ";375*HF;_ " ; place ";903*WF;" ";370*HF;" ;\WorkBehind" #grid, "backcolor white ; place ";Shortcut*WF;" ";370*HF;" ;\A" ' Menu Item - WRITE SPLINE #grid, "backcolor darkcyan ; up ; place ";LeftBox*WF;" ";375*HF;" ; down ; boxfilled ";RightBox*WF;" ";400*HF;_ " ; place ";902*WF;" ";395*HF;" ;\ Write spline" #grid, "backcolor white ; place ";Shortcut*WF;" ";395*HF;" ;\V" ' Menu Item - WRITE LATHE #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";400*HF;" ; down ; boxfilled ";RightBox*WF;" ";425*HF;_ " ; place ";905*WF;" ";420*HF;" ;\ Write lathe" #grid, "backcolor white ; place ";Shortcut*WF;" ";420*HF;" ;\L" ' Menu Item - WRITE CUBIC LATHE #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";425*HF;" ; down ; boxfilled ";RightBox*WF;" ";450*HF;_ " ; place ";905*WF;" ";445*HF;" ;\W CubLathe" #grid, "backcolor white ; place ";Shortcut*WF;" ";445*HF;" ;\B" ' Menu Item - CLOSE POLYGON #grid, "backcolor 0 175 0 ; up ; place ";LeftBox*WF;" ";450*HF;" ; down ; boxfilled ";RightBox*WF;" ";475*HF;_ " ; place ";907*WF;" ";470*HF;" ;\Close poly" #grid, "backcolor white ; place ";Shortcut*WF;" ";470*HF;" ;\K" ' Menu Item - WRITE POLYGON #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";475*HF;" ; down ; boxfilled ";RightBox*WF;" ";500*HF;_ " ; place ";910*WF;" ";495*HF;" ;\Write poly" #grid, "backcolor white ; place ";Shortcut*WF;" ";495*HF;" ;\O" ' Menu Item - CLOSE PRISM #grid, "backcolor 0 175 0 ; up ; place ";LeftBox*WF;" ";500*HF;" ; down ; boxfilled ";RightBox*WF;" ";525*HF;_ " ; place ";905*WF;" ";520*HF;" ;\Close prism" #grid, "backcolor white ; place ";(Shortcut+3)*WF;" ";520*HF;" ;\I" ' Menu Item - WRITE PRISM #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";525*HF;" ; down ; boxfilled ";RightBox*WF;" ";550*HF;_ " ; place ";905*WF;" ";545*HF;" ;\Write prism" #grid, "backcolor white ; place ";Shortcut*WF;" ";545*HF;" ;\P" ' Menu Item - CLOSE CUBIC PRISM #grid, "backcolor 0 175 0 ; up ; place ";LeftBox*WF;" ";550*HF;" ; down ; boxfilled ";RightBox*WF;" ";575*HF;_ " ; place ";904*WF;" ";570*HF;" ;\Cl prismCub" #grid, "backcolor white ; place ";Shortcut*WF;" ";570*HF;" ;\U" ' Menu Item - WRITE CUBIC PRISM #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";575*HF;" ; down ; boxfilled ";RightBox*WF;" ";600*HF;_ " ; place ";902*WF;" ";595*HF;" ;\WrPrismCub" #grid, "backcolor white ; place ";Shortcut*WF;" ";595*HF;" ;\C" ' Menu Item - SNAP - OFF, 0.1, 0.2 #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";600*HF;" ; down ; boxfilled ";RightBox*WF;" ";625*HF;_ " ; place ";910*WF;" ";620*HF;" ;\ 'Snap' off" #grid, "backcolor white ; place ";Shortcut*WF;" ";620*HF;" ;\0" #grid, "backcolor white ; up ; place ";LeftBox*WF;" ";625*HF;" ; down ; boxfilled ";RightBox*WF;" ";650*HF; #grid, "backcolor white ; place ";Shortcut*WF;" ";637*HF;" ;\1" #grid, "backcolor white ; place ";Shortcut*WF;" ";653*HF;" ;\2" select case case Snap = 2' and Snap2 = 1 #grid, "backcolor white ; color red ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color lightgray ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF case Snap = 1' and Snap2 = 0 #grid, "backcolor white ; color lightgray ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color red ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF case Snap = 0' and Snap2 = 0 #grid, "backcolor white ; color lightgray ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color lightgray ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF end select ' Menu Item - EXIT #grid, "color black ; backcolor red ; up ; place ";900*WF;" ";650*HF;" ; down ; boxfilled ";RightBox*WF;" ";675*HF;_ " ; place ";928*WF;" ";670*HF;" ;\ Exit" #grid, "backcolor white ; place ";Shortcut*WF;" ";670*HF;" ;\Q" ' Menu Item - Move Spline Object #grid, "color black ; backcolor white ; up ; place ";900*WF;" ";675*HF;" ; down ; boxfilled ";RightBox*WF;" ";700*HF;_ " ; place ";903*WF;" ";695*HF;" ;\Lf Up Dn Rg" #grid, "color darkgreen ; backcolor white ; place ";895*WF;" ";715*HF;" ;\(F1, F2, F3, F4)" #grid, "flush; redraw" DeviceInput = 0 while DeviceInput = 0 scan #grid, "when leftButtonDown [ProcessInput]" #grid, "when mouseMove [ProcessInput]" #grid, "when characterInput [ProcessInput]" wend 'wait [ProcessInput] if Inkey$ <> "" then KeyPress = 1 end if if MouseX > LeftBox*WF then ' Mouse click is in Menu area MenuSelection$ = "" select case case MouseY > 675*HF ' Move spline by 0.25-Unit increments MenuSelection$ = "moveit" case MouseY > 650*HF ' QUIT goto [quit] case MouseY > 625*HF ' SNAP if MouseX > 950*WF then ' 0.250-Unit Mode Snap = 2 'Snap2 = 0 else ' 0.125-Unit Mode Snap = 1'Snap = 0 'Snap2 = 1 end if MenuSelection$ = "drawgrid" case MouseY > 600 * HF ' Toggle SNAP to OFF Snap = 0 Snap2 = 0 MenuSelection$ = "drawgrid" case MouseY > 575 * HF ' Write Cubic Prism [pressedc] PrismCubic = 1 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 550*HF ' Close Cubic Prism [pressedu] PrismCubic = 0 SubPrismCubic = 1 XandY(Points+3, 3) = 1 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "Undo2" case MouseY > 525*HF ' Write Prism [pressedp] PrismCubic = 0 SubPrismCubic = 0 Prism = 1 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 500*HF ' Close Prism [pressedi] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 1 XandY(Points+1, 3) = 1 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "Undo2" case MouseY > 475*HF ' Write Polygon [pressedo] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 1 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 450*HF ' Close Polygon [pressedk] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 1 XandY(Points+1, 3) = 1 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 425*HF ' Write Cubic Lathe [pressedb] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 1 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 400*HF ' Write Lathe [pressedl] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 1 Spline = 0 Plot = 0 MenuSelection$ = "makefile" case MouseY > 375 * HF ' Write Spline [pressedv] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 1 Plot = 0 MenuSelection$ = "makefile" case MouseY > 350*HF ' Load underlay Drawing - "Work in Back" [presseda] WorkBackg = 1 - WorkBackg MenuSelection$ = "readbackground" case MouseY > 325 * HF ' Load Work [pressedr] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 0 MenuSelection$ = "readpoints" case MouseY > 300 * HF ' Save work [presseds] PrismCubic = 0 SubPrismCubic = 0 Prism = 0 SubPrism = 0 Polygon = 0 SubPoly = 0 LatheCubic = 0 Lathe = 0 Spline = 0 Plot = 1 MenuSelection$ = "makefile" case MouseY > 275 * HF ' No Grid MenuSelection$ = "nogrid" case MouseY > 250 * HF ' White Grid MenuSelection$ = "wgrid" case MouseY > 225 * HF ' Load Model.bmp MenuSelection$ = "model" case MouseY > 200 * HF ' Center Y-Axis [pressedy] #grid, "cls" CenterY = 1 - CenterY MenuSelection$ = "drawgrid" case MouseY > 175 * HF ' Center X-Axis [pressedx] #grid, "cls" CenterX = 1 - CenterX MenuSelection$ = "drawgrid" case MouseY > 150 * HF ' Edit if Edit > 0 then Edit = 0 #grid, "cls" else Edit = 1 end if MenuSelection$ = "drawgrid" case MouseY > 125 * HF ' Undo MenuSelection$ = "erase" case MouseY > 100 * HF ' New gMenuSelection$ = "new" case MouseY > 75 * HF ' Help MenuSelection$ = "helpme" end select end if if MouseClicked = 1 then Points = Points + 1 end if if Snap > 0 then '= 1 or Snap2 = 1 then 'redefine subroutine as function Snap MouseX = SnapMouse(MouseX, MouseY) MouseY = SnapMouse(MouseX, MouseY) end if if KeepX = 0 then ' Hvis pil op eller ned er trykket ' If arrow up or down is pressed XandY(Points, 1) = MouseX else XandY(Points, 1) = XandY(Points-1, 1) KeepX=0 ' nulstil ' reset end if if KeepY = 0 then ' Hvis pil højre eller venstre er trykket ' If arrow left or right is pressed XandY(Points, 2) = MouseY else XandY(Points, 2) = XandY(Points-1, 2) KeepY=0 ' nulstil ' reset end if [Undo2] if Points < 0 then 'goto [new] ' Så vi ikke får fejlmeddelelser ved at bruge Undo for meget ' So we do not get error messages by using Undo too many times end if if SubPrismCubic = 1 then FindSub = Points Points = Points + 3 ' Her skaber vi et ekstra punkt, som bliver en kopi af det, der skal lukkes ' Here, we create an additional point, which is a copy of it to be closed while XandY(FindSub, 3) = 0 FindSub = FindSub-1 wend FindSub = FindSub + 3 XandY(Points-2, 1) = XandY(FindSub-2, 1)' PrismCount fandt vi længere nede - et punkt, hvor subprisms skiller ' PrismCount we found further down - a point where subprisms stand XandY(Points-2, 2) = XandY(FindSub-2, 2) XandY(Points-1, 1) = XandY(FindSub-1, 1)' PrismCount fandt vi længere nede - et punkt, hvor subprisms skiller ' PrismCount we found further down - a point where subprisms stand XandY(Points-1, 2) = XandY(FindSub-1, 2) XandY(Points, 1) = XandY(FindSub, 1) ' PrismCount fandt vi længere nede - et punkt, hvor subprisms skiller ' PrismCount we found further down - a point where subprisms stand XandY(Points, 2) = XandY(FindSub, 2) SubPrismCubic = 0 ' reset ' Marker for, om subprism er aktuelt, så vi ikke slæber rundt på det gennem hele programmet ' Mark, on subprism is currently so we carry around with it through the entire program 'goto [skipline] end if if SubPrism = 1 then FindSub = Points ' Her skaber vi et ekstra punkt, som bliver en kopi af det, der skal lukkes ' Here, we create an additional point, which is a copy of it to be closed Points = Points + 1 while XandY(FindSub, 3) = 0 FindSub = FindSub-1 wend FindSub = FindSub+1 XandY(Points, 1) = XandY(FindSub, 1) ' PrismCount fandt vi længere nede - et punkt, hvor subprisms skiller ' PrismCount we found further down - a point where subprisms stand XandY(Points, 2) = XandY(FindSub, 2) SubPrism = 0 ' reset ' Marker for, om subprism er aktuelt, så vi ikke slæber rundt på det gennem hele programmet ' Mark, on subprism is currently so we carry around with it through the entire program 'goto [skipline] end if if SubPoly = 1 then FindSub = Points Points = Points + 1 ' Her skaber vi et ekstra punkt, som bliver en kopi af det, der skal lukkes ' Here, we create an additional point, which is a copy of it to be closed while XandY(FindSub, 3)=0 FindSub = FindSub-1 wend FindSub = FindSub+1 XandY(Points, 1) = XandY(FindSub, 1) ' PolyCount fandt vi længere nede - et punkt, hvor subpolys skiller ' PrismCount we found further down - a point where subprisms stand XandY(Points, 2) = XandY(FindSub, 2) SubPoly = 0 ' reset 'Marker for, om subpoly er aktuelt, så vi ikke slæber rundt på det gennem hele programmet ' Mark, on subprism is currently so we carry around with it through the entire program 'goto [skipline] end if if Edit = 1 then #grid, "size 5 ; font Arial 20 bold ; color green ; backcolor white ; place ";800*WF;" ";80*HF;" ;\EDIT" #grid, "size 2 ; font Arial ";Font1;" bold ; color darkgreen ; backcolor white ; place ";400*WF;" ";725*HF;" ;\Click point to be edited" Edit = 2 'goto [skipline] ' Added to redraw line - BW 'goto [nextpoint] end if if Edit = 2 then for editcheck = 0 to Points-1 if abs (XandY(editcheck, 1) - XandY(Points, 1)) < 10 and abs (XandY(editcheck, 2) - XandY(Points, 2)) < 10 then ' Hvilket gammelt punkt er der nu klikket på? Sammenligner med alle indenfor 0.1 unit ' Which old item is currently clicked? Comparing to all within 0.1 unit #grid, "size 5 ; color green ; set "; XandY(editcheck, 1); " "; XandY(editcheck, 2) ' Sæt en grøn prik hvor punkt der skal rettes ligger ' Put a green dot where the point to be addressed is #grid, "size 2 ; font Arial ";Font1;" bold ; color darkgreen ; backcolor white ; place ";400*WF;" ";725*HF;" ;\Click new position for point" Edit = 3 ' Nu har vi fundet punktet blandt de tegnede og gemt det. Næste skridt er at vælge det nye punkt der skal erstatte det ' Now we have found the point among the undersigned and saved it. The next step is to select the new item to replace it Points = Points-1 'goto [nextpoint] end if next editcheck ' Hvis der ikke findes matches med det nye punkt, tilføjes figuren en streg i stedet, men edit mode forbliver ON ' If no matches are found with the new point is added to the figure a line instead, but edit mode remains ON end if if Edit = 3 then XandY(editcheck, 1) = XandY(Points, 1) ' Det gamle punkt udskiftes med det nye ' The existing entry is replaced with the new XandY(editcheck, 2) = XandY(Points, 2) Points = Points-1 Edit = 0 ' Reset Edit Mode to Zero #grid, "cls" 'goto [drawgrid] end if [skipline] if AddNewPoint = 1 then #grid, "size 5 ; color blue ; set "; XandY(Points, 1); " "; XandY(Points, 2) ' Sæt en rød prik hvor det nye punkt ligger ' Put a red dot where the new point is ' ^^^^^ This is one of the first things that gets hit, so probably why phantom 1st point exists ' Used / remaining point counter #grid, "font Arial ";Font2;" bold ; color red ; backcolor white ; place ";910*WF;" ";90*HF;" ;\ ";Points;" / ";500-Points end if ' Change menu text color depending on SNAP mode select case case Snap = 1'0 and Snap2 = 1 #grid, "backcolor white ; color red ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color lightgray ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF; case Snap = 2'1 and Snap2 = 0 #grid, "backcolor white ; color lightgray ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color red ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF; case else #grid, "backcolor white ; color lightgray ; place ";903*WF;" ";645*HF;" ;\ ";0.125/HF; #grid, "backcolor white ; color lightgray ; place ";950*WF;" ";645*HF;" ;\ ";0.25/HF; end select if WorkBackg = 1 then for Back = 2 to PointsB #grid, "size 3 ; color 150 150 150 ; line "; Background(Back-1, 1) ;" "; Background(Back-1, 2);" ";Background(Back, 1);" ";Background(Back, 2) if Background(Back, 3) = 1 then ' Subpoly her? Så spring over ' Subpoly here? So skip Back = Back + 1 end if next Back end if if Points < 0 then Points = 0 end if select case Points case 0 ' do nothing case 1 ' display current point coordinates when # of points > 1 #grid, "backcolor white ; color red ; place ";500*WF;" ";18*HF;" ; down ;\C:(";XandY(1, 1)/(50*WF)-8*CenterY-1;" , ";(650*HF-XandY(1,2))/(50*HF)-6*CenterX;")" case else ' Hvis dette ikke er første tegnede punkt, så tegn en streg mellem forrige og dette ' If this is not the first plotted point, then draw a line between the previous and this for Streg = 2 to Points ' streg = line #grid, "size 2 ; color red ; line "; XandY(Streg-1, 1) ;" "; XandY(Streg-1, 2);" ";XandY(Streg,1);" ";XandY(Streg,2) #grid, "size 5 ; color blue ; set "; XandY(Streg, 1); " "; XandY(Streg, 2) ' Sæt en rød prik hvor det nye punkt ligger ' Put a BLUE dot where the new point is Xpos1 = XandY(Points, 1) / (50*WF) -8*CenterY -1 Ypos1 = (650*HF - XandY(Points, 2)) / (50*HF) -6*CenterX Xpos0 = XandY(Points-1, 1)/(50*WF) -8*CenterY -1 Ypos0 = (650*HF - XandY(Points-1, 2)) / (50*HF) -6*CenterX Distance = sqr((Xpos1 - Xpos0)^2 + (Ypos1 - Ypos0)^2) if (MouseClicked = 1) and (Distance = 0) then Points = Points-1 notice "You have clicked the same point twice" 'goto [nextpoint] end if Distance$ = using("##.##", Distance) #grid, "backcolor white ; color white ; place ";400*WF;" 0 ; down ; boxfilled ";1020*WF;" ";22*HF; ' sletter alt tidligere ' deletes all previous ' display Last point coordinates #grid, "font Arial ";Font2;" bold ; backcolor white ; color lightgray ; place ";350*WF;" ";18*HF;" ; down ;\L:(";Xpos0;" , ";Ypos0;")" ' display current point coordinates if Angle = 0 or Angle = 45 or Angle = 90 then #grid, "backcolor white ; color 0 175 0 ; place ";500*WF;" ";18*HF;" ; down ;\C:(";Xpos1;" , ";Ypos1;")" else #grid, "backcolor white ; color red ; place ";500*WF;" ";18*HF;" ; down ;\C:(";Xpos1;" , ";Ypos1;")" ' DETTE ER I SKOVEN ' THIS IS IN THE FOREST end if #grid, "backcolor white ; color lightgray ; place ";790*WF;" ";18*HF;" ; down ;\ Distance ";Distance$ if Xpos1<>Xpos0 then AngRad = ATN((Ypos1 - Ypos0) / (Xpos1 - Xpos0)) AngDeg = abs(AngRad * 180/3.14159265) else AngDeg = 90 end if #grid, "backcolor white ; color lightgray ; place ";910*WF;" ";18*HF;" ; down ;\ Angle ";using("##.##", AngDeg) if XandY(Streg, 3)=1 then ' Subpoly her? Så spring over ' Subpoly here? So skip Streg=Streg+1 end if next Streg end select '3 snap conditons - only need ONE variable with values 0, 1, 2 if Snap > 0 then MouseX = SnapMouse(MouseX, MouseY) MouseY = SnapMouse(MouseX, MouseY) ' Xval = MouseX-(100*int(MouseX/100)) ' Yval = MouseY-(100*int(MouseY/100)) ' MouseX=MouseX-XVal+(int((XVal+SNAP^2)/(SNAP*6))*(SNAP*6.25)) ' MouseY=MouseY-YVal+(int((YVal+SNAP^2)/(SNAP*6))*(SNAP*6.25)) end if 'if Snap2 = 1 and Snap = 0 then ' Xval = MouseX-(100*int(MouseX/100)) ' MouseX=MouseX-XVal+(INT((XVal+1)/6)*6.25) ' ' Yval = MouseY-(100*int(MouseY/100)) ' MouseY=MouseY-YVal+(INT((YVal+1)/6)*6.25) 'end if ' 'if Snap = 1 and Snap2 = 0 then ' Xval = MouseX-(100*int(MouseX/100)) ' MouseX=MouseX-XVal+(INT((XVal+4)/12)*12.5) ' ' Yval = MouseY - (100 * int(MouseY / 100)) ' MouseY=MouseY-YVal+(INT((YVal+4)/12)*12.5) 'end if #grid, "backcolor white ; place ";640*WF;" 0 ; color white ; boxfilled ";790*WF;" ";21*HF; ' display current mouse position #grid, "color blue ; place ";650*WF;" ";18*HF;" ; down ;\M:(";MouseX/(50*WF)-8*CenterY-1;" , "; (650*HF-MouseY)/(50*HF)-6*CenterX;") " ' afrund y her ' rounding y here ' ########################################################################################### ' show "live" distance and angle if Points > 0 then Xpos1 = MouseX/(50*WF)-8*CenterY-1 Ypos1 = (650*HF-MouseY)/(50*HF)-6*CenterX Xpos0 = XandY(Points,1)/(50*WF) -8*CenterY -1 Ypos0 = (650*HF - XandY(Points, 2)) / (50*HF) -6*CenterX Distance = sqr((Xpos1 - Xpos0)^2 + (Ypos1 - Ypos0)^2) Distance$ = using("##.##", Distance) #grid, "backcolor white ; color white ; place ";785*WF;" 0 ; down ; boxfilled ";1020*WF;" ";22*HF; ' sletter alt tidligere ' deletes all previous #grid, "backcolor white ; color lightgray ; place ";790*WF;" ";18*HF;" ; down ;\ Distance ";Distance$ if Xpos1<>Xpos0 then AngRad = ATN((Ypos1 - Ypos0) / (Xpos1 - Xpos0)) AngDeg = abs(AngRad * 180/3.14159265) else AngDeg = 90 end if #grid, "backcolor white ; color lightgray ; place ";910*WF;" ";18*HF;" ; down ;\ Angle ";using("##.##", AngDeg) end if 'wend ' end while RunProgram loop goto [Loop] [quit] beep close #grid stop ' ##### end loop ' Function definitions function fileExists(path$, filename$) ' dimension the array info$() at the beginning of your program files path$, filename$, info$() fileExists = val(info$(0, 0)) 'non zero is true end function function SnapMouse(MouseX, MouseY) Xval = MouseX-(100*int(MouseX/100)) Yval = MouseY-(100*int(MouseY/100)) MouseX=MouseX-XVal+(int((XVal+SNAP^2)/(SNAP*6))*(SNAP*6.25)) MouseY=MouseY-YVal+(int((YVal+SNAP^2)/(SNAP*6))*(SNAP*6.25)) end function sub DrawLine LineWidth, LineColor$, FromX, FromY, ToX, ToY ' #handle, "line X1 Y1 X2 Y2" #grid, "size "; LineWidth ; "color ";LineColor$;" ; up ; place ";_ FromX;" ";FromY;_ " ; down ; line ";_ FromX;" ";FromY;" ";_ ToX;" ";ToY; end sub sub MenuBox AtY #grid, "backcolor green ; up ; place ";LeftBox*WF;" ";AtY;" ; down ; boxfilled ";RightBox*WF;" ";AtY+20*HF end sub sub MenuItem BoxColor$, TextColor$, AtY, Nudge, Item$, Shortcut$, LeftBox, RightBox, Shortcut ' #grid, "down; backcolor ";BoxColor$ 'set pen color and size for shape ' #grid, "color ";TextColor$;"; size 1" 'place the pen at upper left corner ' #grid, "place ";(LeftBox+Nudge)*WF;" ";AtY*HF 'draw a 100 x 100 box ' #grid, "boxfilled ";RightBox*WF;" ";(AtY+25)*HF #grid, "backcolor ";BoxColor$;" ; place ";LeftBox*WF;" ";AtY*HF;" ; down ; boxfilled ";RightBox*WF;" ";(AtY+25)*HF; #grid, "color ";TextColor$;" ; up ; place ";(LeftBox+Nudge)*WF;" ";(AtY+20)*HF;"; down ;\";Item$ #grid, "backcolor white ; place ";Shortcut*WF;" ";(AtY+20)*HF;" ;\";Shortcut$ end sub '#grid, "color black ; backcolor cyan ; up ; place ";LeftBox*WF;" ";100*HF;" ; down ; boxfilled ";RightBox*WF;" ";125*HF;" ; place ";925*WF;" ";120*HF;" ;\ New" '#grid, "backcolor white ; place ";Shortcut*WF;" ";120*HF;" ;\N"