panky
Guru
Joined: 02/10/2012 Location: AustraliaPosts: 1094 |
Posted: 06:21pm 06 Mar 2017 |
Copy link to clipboard |
Print this post |
|
The following code segment was created to show a dashed (or dotted) line on lcdpanel display. It may be usefull to someone
' A frivolous code fragment to draw dashed lines ' Coded as a sub routine DLine and passed the following parameters:- ' x1 and y1 - the start of the line in pixels ' numbrms - the number of mark, space sequences ' lorient - line orientation as either 0 for horizontal or 1 for vertical ' lthick - line thickness in pixels ' mklen - the length in pixels of the mark dash ' splen - the length in pixels of the space dash ' mkcol - the colour of the mark dash - must be constant or integer ' spcol - the colour of the space dash - must be constant or integer
' Test code option explicit cls dim ic% dim dloop% dim x1% = 10 dim y1% = 10 dim numbrms% = 20 dim lorient% = 0 dim lthick% = 10 dim mklen% = 10 dim splen% = 10 dim mkcol% = rgb(red) dim spcol% = rgb(white) DLine x1%,y1%,numbrms%,lorient%,lthick%,mklen%,splen%,mkcol%,spcol% lorient% = 1 numbrms% = 20 x1% = 200 y1% = 100 DLine x1%,y1%,numbrms%,lorient%,lthick%,mklen%,splen%,mkcol%,spcol% y1% = 200 lthick% = 20 lorient% = 0 ' this bit does a walking line :-) for dloop% = 1 to 20 for ic% = x1% to x1% + mklen% DLine ic%,y1%,numbrms%,lorient%,lthick%,mklen%,splen%,mkcol%,spcol% pause 200 next ic% next dloop% end
' Dashed line routine ' Subroutine to draw a horizontal or vertical dashed line ' with variable mark to space ratio. ' x1 and y1 are the starting co-ordinates ' numbrms is the number of mark space segments eg. 1 will draw 1 mark and 1 space ' lorient is the orientation - 0 = horizontal and 1 = vertical ' lthick is the line width in pixels ' mklen is the length of the mark in pixels ' splen is the length of the space in pixels ' the mark and space colours must be defined as integer variables ' or as constants, all other variables could be fp sub DLine(x1%,y1%,numbrms%,lorient%,lthick%,mklen%,splen%,mkcol%,spcol%) local xs%,ys%,dlnum%,orient%,dlthick%,mlen%,slen% local pixlen%,lic%,mcol%,scol% xs% = x1% ys% = y1% dlnum% = numbrms% orient% = lorient% dlthick% = lthick% mlen% = mklen% slen% = splen% pixlen% = mlen% + slen% mcol% = mkcol% scol% = spcol% for lic% = 0 to dlnum% - 1 if orient% = 0 then 'horizontal line xs% + (lic% * pixlen%),ys%, xs% + (lic% *pixlen%) + mlen%,ys%,dlthick%,mcol% line xs% + (lic% * pixlen%) + mlen%,ys%, xs% + (lic% *pixlen%) + slen% + mlen%,ys%,dlthick%,scol% elseif orient% = 1 then 'vertical line xs%, ys% + (lic% * pixlen%), xs%, ys% + (lic% * pixlen%) + mlen%,dlthick%,mcol% line xs%, ys% + (lic% * pixlen%) + mlen%, xs%, ys% + (lic% * pixlen%) + slen% + mlen%,dlthick%,scol% endif next lic% end sub
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it! |