Page 1 of 1
Moving dash line pattern
Posted: Thu Jan 23, 2014 5:01 pm
by Mr. Kibernetik
Code: Select all
graphics
draw size 5
draw color 0,0,1
loop:
graphics lock
graphics clear
draw dash 20,10 phase k
draw line 50,100 to 300,100
graphics unlock
pause 0.05
k+=1
goto loop
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 8:33 pm
by Dutchman
I think there is something missing
On my iPad-1 the line is slowly growing, but not moving.
I made the following example, which is also in the PDF-manual:
Code: Select all
' moving lines
GRAPHICS
sw=SCREEN_WIDTH()
sh=SCREEN_HEIGHT()
DRAW SIZE 5
DO
i+=1
DRAW DASH 20,10,5,10 PHASE i*5
GRAPHICS LOCK
GRAPHICS CLEAR 0,0,0
DRAW CIRCLE sw/2,sh/2 SIZE sw/4
DRAW RECT 2,2 TO sw/3,sh/3
DRAW LINE 2,sh/2 TO sw,sh
GRAPHICS UNLOCK
i%=9
GET TOUCH n AS x,y
UNTIL x>-1 AND y>-1
END
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 8:42 pm
by Mr. Kibernetik
Your sample is fantastic!
I just re-checked my own sample on iPad - and it works. Actually it is so simple that it cannot be non-working...
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 9:21 pm
by Dutchman
You are right, I was too hasty
It moves very slow.
Now the problem is that I don't understand the code.
There is no cycle-period in the value of 'k', it is constantly growing instead. What is e.g. phase 890 on a line of length 250.
In my example the phase steps with 5 pixels until the end of the pattern (9*5=45 pixels) and repeats that again and again.
Can you please explain how 'your' line moves?
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 9:43 pm
by Mr. Kibernetik
Dutchman wrote:
Can you please explain how 'your' line moves?
Of course!
Actually "phase" is always valid. Even negative - just moves in another direction. For "phase", remainder of division (what you have done as i%=9) is always performed internally, so you may not bother about this
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 9:48 pm
by Dutchman
OK, smart!
I changed in your code 'k+=1' to 'k+=5' and that clarified why it moved so slowly.
Thanks, I will make a remark in the manual about that automatic cycling.
Re: Moving dash line pattern
Posted: Fri Jan 31, 2014 9:49 pm
by Mr. Kibernetik
Dutchman wrote:
It moves very slow.
Actually it is slow only on our iPads
On iPhone 5S it will be just a mess...