draw an image of a solderless board (for circuit testing)

Started by RemiD, September 15, 2019, 10:06:17

Previous topic - Next topic

RemiD


;draw an image of a solderless board, to draw components wires on it (for circuit testing)
Graphics(1000,500,32,2)

WCount% = 1+75+1 ;number of holes along the width
HCount% = 1+1+1+1+10+1+1+10+1+1+1+1 ;number of holes along the height (for each side)

XImage = CreateImage(WCount*10,HCount*10)

SetBuffer(ImageBuffer(XImage))
;color of background
ClsColor(200,200,200) : Cls()
;highlight positive holes at top
PX% = 1*10 : PY% = 1*10 : PWidth% = (75)*10 : PHeight% = (1)*10
Color(255,125,125) : Rect(PX,PY,PWidth,PHeight,True)
;highlight negative holes at top
PX% = 1*10 : PY% = 2*10 : PWidth% = (75)*10 : PHeight% = (1)*10
Color(125,125,255) : Rect(PX,PY,PWidth,PHeight,True)
;highlight positive holes at bottom
PX% = 1*10 : PY% = (30-3)*10 : PWidth% = (75)*10 : PHeight% = (1)*10
Color(255,125,125) : Rect(PX,PY,PWidth,PHeight,True)
;highlight negative holes at bottom
PX% = 1*10 : PY% = (30-2)*10 : PWidth% = (75)*10 : PHeight% = (1)*10
Color(125,125,255) : Rect(PX,PY,PWidth,PHeight,True)
;holes
For WC% = 1 To WCount Step 1
For HC% = 1 To HCount Step 1
  PX% = (WC-1)*10 : PY% = (HC-1)*10 : PWidth% = 10 : PHeight% = 10
  Color(125,125,125) : Oval(PX+3,PY+3,PWidth-6,Pheight-6,True)
Next
Next
;gaps at top
PX% = 0*10 : PY% = 0*10 : PWidth% = (1+75+1)*10 : PHeight% = (1)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gaps at bottom
PX% = 0*10 : PY% = (30-1)*10 : PWidth% = (1+75+1)*10 : PHeight% = (1)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gap in the middle
PX% = 0*10 : PY% = (15-1)*10 : PWidth% = (1+75+1)*10 : PHeight% = (2)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gap at left
PX% = 0*10 : PY% = 0*10 : PWidth% = (1)*10 : PHeight% = (30)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gap at right
PX% = (75+1)*10 : PY% = 0*10 : PWidth% = (1)*10 : PHeight% = (30)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gap to separate holes from middle top to negative positive top
PX% = 0*10 : PY% = 3*10 : PWidth% = (1+75+1)*10 : PHeight% = (1)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)
;gap to separate holes from middle bottom to negative positive bottom
PX% = 0*10 : PY% = (30-4)*10 : PWidth% = (1+75+1)*10 : PHeight% = (1)*10
Color(200,200,200) : Rect(PX,PY,PWidth,PHeight,True)

;save the image
XFileName$ = "solderlessboard"+"-"+Str(WCount-1-1)+"x"+Str(HCount-1-1-1-1-1-1-1-1-1-1)+".bmp"
SaveImage(XImage,XFileName)

;draw the image
SetBuffer(BackBuffer())
ClsColor(000,000,000) : Cls()
DrawImage(XImage,0,0)
PX% = 0 : PY% = ImageHeight(XImage)+16 : Color(255,255,255) : Text(PX,PY,XFileName)
Flip()
WaitKey()

;finis
End()