![]() |
Forum Index : Microcontroller and PC projects : polygons
![]() ![]() |
|||||
Author | Message | ||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
@Andrew_G, I've only used MMedit as I'm used to windoze ide for picaxe, then gcbasic and now mmbasic. It's familiar and mouse driven and I'm more used to saving code to win folders. The built in editor is great as the picomite can be a stand alone board, I just prefer mmedit. Polygon takes a while to learn but getting there. I coded a pentagon and octagon. It fills the shape faster than you can see, it just appears. Very clever. I'm not sure why x% and y% start from element 0 but c%,fc% and fb% need to use element 1. I'll experiment more. DIM c%(1)=8 DIM x%(7)=(200,250,300,300,250,200,150,150) DIM y%(7)=(50,50,100,150,200,200,150,100) DIM fc%(1)=bl DIM fb%(1)=ye CLS POLYGON c%(),x%(),y%(),fb%(),fc%() |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
X% and Y% start from the *first element* of the array. The base element number for arrays can be changed (see OPTION BASE). By default, or if you use OPTION BASE 0 in your program the first element is zero so they will be in xarray(0) and yarray(0). If you use OPTION BASE 1 in your program then arrays start at one, so they will be in xarray(1) and yarray(1) If you use OPTION BASE 1 then there is no zero element in your arrays, they all start at one. Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
I'm surprised your code works. You are only defining 1 polygon so c%, fc% and fb% only need to be integers not arrays DIM c%(1)=8 says create a two element array and set the first element to 8. i.e. DIM c%(1) c%(0)=9 The fact that your version works is what surprises me as it is not in the manual as an option. The normal way of initialising arrays is as per your x% and y%. Correct version is: Dim c%=8 Dim x%(7)=(200,250,300,300,250,200,150,150) Dim y%(7)=(50,50,100,150,200,200,150,100) Dim fc%=RGB(blue) Dim fb%=RGB(green) CLS Polygon c%,x%(),y%(),fb%,fc% |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4044 |
Looks like DIM c%(1)=8 creates a 2-element array and initialises c%(0) to 8, which then is why the code works. Sort of happy accident? John |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2567 |
My first use of Polygon. I thought it had to be arrays for 1 polygon. I set OPTION BASE 0 to make sure arrays start from 0. I like the Polygon function. Going try odd shapes to test the fill. Using integers for 1 polygon worked. Thanks for that info @matherp. It gets to look lots of numbers if you use several complex polygons :) |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |