Moving dash line pattern

Post Reply
User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Moving dash line pattern

Post 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

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Moving dash line pattern

Post by Dutchman »

I think there is something missing :roll:
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

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Moving dash line pattern

Post 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... :shock:

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Moving dash line pattern

Post by Dutchman »

You are right, I was too hasty :oops: 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?

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Moving dash line pattern

Post 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 :geek:

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: Moving dash line pattern

Post 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.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Moving dash line pattern

Post by Mr. Kibernetik »

Dutchman wrote: It moves very slow.
Actually it is slow only on our iPads :lol:
On iPhone 5S it will be just a mess...

Post Reply