|
Forum Index : Microcontroller and PC projects : Random ellipses: MMX or Armmite H7
| Author | Message | ||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
![]() Please watch the video This demo will run on an ARMMITE H7 or a Micromite eXtreme with the latest firmware versions, not unfortunately on a Maximite option explicit option default NONE dim INTEGER x(60), y(60), xd(60), yd(60) , xe(60), ye(60) dim integer i, c, f, xp, yp dim float a, s, e, sine, cosine for i=0 to 60 'store coordinates for a 60 point closed circle, radius 100 x(i)=sin(rad(i*6)) * 100 y(i)=COS(rad(i*6)) * 100 next i CLS do c=rnd()*255 + ((rnd()* 255)<<8) + ((rnd()* 255)<<16) ' random colour for border f=rnd()*255 + ((rnd()* 255)<<8) + ((rnd()* 255)<<16) ' random colour for fill xp=rnd()*mm.hres 'random x position of centre yp=rnd()*mm.vres 'random y position of centre s=rnd() 'random size a=rnd()* 360 'random angle sine=sin(rad(a)): cosine=cos(rad(a)) e=rnd()* 8/3 + (1/3) ' random aspect ratio between one third and three for i=0 to 60 ' first convert the aspect ratio and resize the coordinates xd(i)=x(i) * s * e yd(i)=y(i) *s next i for i=0 to 60 ' now rotate the coordinates by an angle between 0 and 360 degrees xe(i)=xd(i)*cosine - yd(i) * sine + xp ye(i)=yd(i)*cosine + xd(i) * sine + yp next i polygon xe(), ye(), c, f 'plot a filled ellipse loop |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
irresistible very good - can I pop it in the library? |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Any of my posted code is free to use / abuse in whatever way anyone wants. I actually prefer the star demo but both are based on the excellent fill algorithm that I found by chance when googling turtle graphics. It even seems to deal with crossed vertices OK. Demo also works on the Armmite L4 with latest firmware. |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
I always ask Peter... seems a presumption just to take. I will put the Star and Ellipse codes all in the same wiki. cheers |
||||
| PeterB Guru Joined: 05/02/2015 Location: AustraliaPosts: 655 |
G'Day Peter & Capt. I knew you would. Now I just have to understands how it works. Perhaps later today I will get the chance. Peter |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |