Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:57 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : polygons

     Page 2 of 2    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2567
Posted: 01:42pm 25 Feb 2023
Copy link to clipboard 
Print this post

@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 Kingdom
Posts: 7937
Posted: 02:17pm 25 Feb 2023
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10315
Posted: 02:43pm 25 Feb 2023
Copy link to clipboard 
Print this post

  Quote  but c%,fc% and fb% need to use element 1. I'll experiment more.

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 Kingdom
Posts: 4044
Posted: 03:53pm 25 Feb 2023
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 2567
Posted: 06:39pm 25 Feb 2023
Copy link to clipboard 
Print this post

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 :)
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025