Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:03 01 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 : Problem with the "TRIANGLE" instruction.

     Page 1 of 2    
Author Message
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 09:24pm 21 Feb 2023
Copy link to clipboard 
Print this post


Nothing so constant as change.
 
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 09:42pm 21 Feb 2023
Copy link to clipboard 
Print this post

Hi,
I'm having a problem getting the "TRIANGLE" instruction to fill the shape with a specified colour.
I have a standard Picomite with these OPTION's :-

PicoMite MMBasic Version 5.07.07b18
OPTION SYSTEM SPI GP10,GP11,GP12
OPTION SYSTEM I2C GP20,GP21
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 48000
OPTION LCDPANEL ILI9488W, RLANDSCAPE,GP8,GP15,GP9,GP13
OPTION GUI CONTROLS 20
OPTION TOUCH GP16,GP17
GUI CALIBRATE 0, 241, 3907, 1271, -860
OPTION SDCARD GP22, GP5, GP18, GP19
OPTION RTC AUTO ENABLE

running on a Waveshare Pico IPS 3.5" ILI9488W 480 x 320 Touchscreen.

If I type at the prompt :-

> cls
> triangle 50,50,150,50,100,100,rgb(green),rgb(blue)

I should get a GREEN edged, BLUE filled triangle on a black background - I believe.

However, I do get the triangle, but it is filled GREEN, and I can't get the fill colour desired.

Am I doing something wrong here?

With best regards, Paul.
Nothing so constant as change.
 
nbrok

Regular Member

Joined: 13/02/2023
Location: Netherlands
Posts: 60
Posted: 04:44am 22 Feb 2023
Copy link to clipboard 
Print this post

  Bowden_P said  Hi,
I'm having a problem getting the "TRIANGLE" instruction to fill the shape with a specified colour.
I have a standard Picomite with these OPTION's :-

PicoMite MMBasic Version 5.07.07b18
OPTION SYSTEM SPI GP10,GP11,GP12
OPTION SYSTEM I2C GP20,GP21
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 48000
OPTION LCDPANEL ILI9488W, RLANDSCAPE,GP8,GP15,GP9,GP13
OPTION GUI CONTROLS 20
OPTION TOUCH GP16,GP17
GUI CALIBRATE 0, 241, 3907, 1271, -860
OPTION SDCARD GP22, GP5, GP18, GP19
OPTION RTC AUTO ENABLE

running on a Waveshare Pico IPS 3.5" ILI9488W 480 x 320 Touchscreen.

If I type at the prompt :-

> cls
> triangle 50,50,150,50,100,100,rgb(green),rgb(blue)

I should get a GREEN edged, BLUE filled triangle on a black background - I believe.

However, I do get the triangle, but it is filled GREEN, and I can't get the fill colour desired.

Am I doing something wrong here?

With best regards, Paul.


I tried it and become the same result as you did. It seems it doesn't recognizes the last command in the line. I cannot switch of fill with -1 also. Probably a bug?
Greetings,
Nick de pe1goo
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2640
Posted: 05:35am 22 Feb 2023
Copy link to clipboard 
Print this post

Further observations:-

PicoMiteVGA MMBasic Version 5.07.07b20
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

> mode 2
> font 7
> cls :triangle 222,222,88,111,111,188,255,0 'Filled blue triangle
> cls :triangle 222,222,88,111,111,188,255 'Un-filled blue triangle
> cls :triangle 222,222,88,111,111,188,255,-1 'Un-filled blue triangle
>

"0" in the top one can be anything up to 2^24 - 1 same result
Edited 2023-02-22 15:37 by phil99
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 05:51am 22 Feb 2023
Copy link to clipboard 
Print this post

For contrast,
cls:triangle 50,50,150,50,100,100,rgb(green),rgb(blue)
works on my CMM2 as expected.
Visit Vegipete's *Mite Library for cool programs.
 
nbrok

Regular Member

Joined: 13/02/2023
Location: Netherlands
Posts: 60
Posted: 06:19am 22 Feb 2023
Copy link to clipboard 
Print this post

  phil99 said  Further observations:-

PicoMiteVGA MMBasic Version 5.07.07b20
Copyright 2011-2023 Geoff Graham
Copyright 2016-2023 Peter Mather

> mode 2
> font 7
> cls :triangle 222,222,88,111,111,188,255,0 'Filled blue triangle
> cls :triangle 222,222,88,111,111,188,255 'Un-filled blue triangle
> cls :triangle 222,222,88,111,111,188,255,-1 'Un-filled blue triangle
>

"0" in the top one can be anything up to 2^24 - 1 same result


I get the same results as you did. pico mmbasic version 5.07.06.
Greetings,
Nick de pe1goo
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 07:39am 22 Feb 2023
Copy link to clipboard 
Print this post

It sound like a bug - can't look at it until the weekend but will post new betas then
 
IanRogers

Senior Member

Joined: 09/12/2022
Location: United Kingdom
Posts: 151
Posted: 09:13am 22 Feb 2023
Copy link to clipboard 
Print this post

Just checking, but I assumed you needed to set the colours

Const green XXX
Const blue XXX

before you use them...  Or have I missed something (or the plot)
I'd give my left arm to be ambidextrous
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4044
Posted: 09:16am 22 Feb 2023
Copy link to clipboard 
Print this post

  IanRogers said  Just checking, but I assumed you needed to set the colours

Const green XXX
Const blue XXX

before you use them...  Or have I missed something (or the plot)

Picomite MMBasic understands rgb(colourname) and does the right thing :)

John
 
IanRogers

Senior Member

Joined: 09/12/2022
Location: United Kingdom
Posts: 151
Posted: 09:21am 22 Feb 2023
Copy link to clipboard 
Print this post

The only reason I was checking as I've had to define the colour or they didn't work.

Even if I set rgb()  I had to define the actual colour... Im on a pico with a ILI9341.

Weird!
I'd give my left arm to be ambidextrous
 
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 01:03pm 22 Feb 2023
Copy link to clipboard 
Print this post

Hi,
Thanks for all confirmations, I initially thought I had not got the instruction right! Thanks to Peter to check this out.

You can use a range of pre-defined colours such as RGB(Green) etc., available within MMBASIC. See "Graphics Commands and Functions - Colours" in the Picomite Manual. (pg. 52.)

In the past - with a Micromite V2 - I had used the TRIANGLE CSub successfully, which has the same arguement list. There I discovered that if you define the colour name as an integer, you could dispense with the "RGB(..)" bit!
i.e.
DIM White%=RGB(255,255,255)
DIM Mauve%=RGB(150,0,150)
DIM Red%=RGB(255,0,0)
etc.

Then use them :-
"COLOUR White%,Mauve%", or "CLS Red%"

Where you use a number of custom defined colours, it helps with readability of the code.

With best regards, Paul.
Nothing so constant as change.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 04:27pm 22 Feb 2023
Copy link to clipboard 
Print this post

This works for me. yellow triangle filled blue. ili9341.
last beta

OPTION EXPLICIT
'colour shortcuts
const WH =RGB(255,  255,  255) 'WHITE
const YE =RGB(255,  255,    0) 'YELLOW
const LI =RGB(255,  128,  255) 'LILAC
const BR =RGB(255,  128,    0) 'BROWN
const FU =RGB(255,  64,   255) 'FUCHSIA
const RU =RGB(255,  64,     0) 'RUST
const MA =RGB(255,  0,    255) 'MAGENTA
const RE =RGB(255,  0,      0) 'RED
const CY =RGB(0,    255,  255) 'CYAN
const GR =RGB(0,    255,    0) 'GREEN
const CE =RGB(0,    128,  255) 'CERULEAN
const MI =RGB(0,    128,    0) 'MIDGREEN
const CO =RGB(0,    64,   255) 'COBALT
const MY =RGB(0,    64,     0) 'MYRTLE
const BL =RGB(0,    0,    255) 'BLUE
const Bk =RGB(0,    0,      0) 'BLACK
const Gy =RGB(128,  128,  128) 'GREY
const Lg =RGB(210,  210,  210) 'LITEGREY
const Og =RGB(255,  165,    0) 'ORANGE
const PK =RGB(255,  160,  171) 'PINK
const Gd =RGB(255,  215,    0) 'GOLD
const SA =RGB(250,  128,  114) 'SALMON
const BE =RGB(245,  245,  220) 'BEIGE
'
cls bk
triangle 0,20,100,100,20,70,ye,bl
 
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 04:58pm 22 Feb 2023
Copy link to clipboard 
Print this post

Hi Stanleyella,
Sorry, no - all I get is a yellow (filled) triangle from your code! Thanks for the post.

With best regards, Paul.
Edited 2023-02-23 03:03 by Bowden_P
Nothing so constant as change.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 05:44pm 22 Feb 2023
Copy link to clipboard 
Print this post

Paul, Hi. I'm using PicoMiteV5.07.05b18. This fixed a ssd1306 problem.
which picomite version are you using?
I always use colour abbreviations and this was fine on my ili9341.
I will try real colour values like rgb(255,255,0) for yellow and rgb(0,0,255) for blue
and retest.
regards stan
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 06:08pm 22 Feb 2023
Copy link to clipboard 
Print this post

triangle 0,0,100,100,20,70,rgb(255,255,0),rgb(0,0,255) also works fine.
It is yellow triangle filled blue on black background.. camera not good.

 
nbrok

Regular Member

Joined: 13/02/2023
Location: Netherlands
Posts: 60
Posted: 06:26pm 22 Feb 2023
Copy link to clipboard 
Print this post

  stanleyella said  triangle 0,0,100,100,20,70,rgb(255,255,0),rgb(0,0,255) also works fine.
It is yellow triangle filled blue on black background.. camera not good.



This mean that the bug is somehow introduced in the later version. You use an older version then the topic starter.
Greetings,
Nick de pe1goo
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 06:34pm 22 Feb 2023
Copy link to clipboard 
Print this post

There was a bug in earlier versions where triangles used in GUI commands weren't being erased properly. Sounds like I've made a mess of the fix. The triangle code is heavily optimized as it is the basis of other drawing functions and the line drawing and triangle fill don't produce exactly the same outline hence the issues
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 06:52pm 22 Feb 2023
Copy link to clipboard 
Print this post

I'm using PicoMiteV5.07.05b18.
Seems ok but want me to test more or is the beta ok for triangles?
Not used triangle for vga picomite.. is that ok.. or test it?
cheers.
 
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2566
Posted: 08:40pm 22 Feb 2023
Copy link to clipboard 
Print this post

Ah, problemo with vga, it fills with triangle shape colour ie yellow in this,not blue.
mode 2
OPTION BASE 0        ' 0 based arrays
option DEFAULT INTEGER
OPTION EXPLICIT

const WH =RGB(255,  255,  255) 'WHITE
const YE =RGB(255,  255,    0) 'YELLOW
const LI =RGB(255,  128,  255) 'LILAC
const BR =RGB(255,  128,    0) 'BROWN
const FU =RGB(255,  64,   255) 'FUCHSIA
const RU =RGB(255,  64,     0) 'RUST
const MA =RGB(255,  0,    255) 'MAGENTA
const RE =RGB(255,  0,      0) 'RED
const CY =RGB(0,    255,  255) 'CYAN
const GR =RGB(0,    255,    0) 'GREEN
const CE =RGB(0,    128,  255) 'CERULEAN
const MI =RGB(0,    128,    0) 'MIDGREEN
const CO =RGB(0,    64,   255) 'COBALT
const MY =RGB(0,    64,     0) 'MYRTLE
const BL =RGB(0,    0,    255) 'BLUE
const Bk =RGB(0,    0,      0) 'BLACK
const Gy =RGB(128,  128,  128) 'GREY
const Lg =RGB(210,  210,  210) 'LITEGREY
const Og =RGB(255,  165,    0) 'ORANGE
const PK =RGB(255,  160,  171) 'PINK
const Gd =RGB(255,  215,    0) 'GOLD
const SA =RGB(250,  128,  114) 'SALMON
const BE =RGB(245,  245,  220) 'BEIGE

cls bk
print mm.ver
triangle 20,20,300,200,55,135,ye,bl
triangle 20,20,300,200,55,135,RGB(255,  255,    0),RGB(0,    0,    255)


 
Bowden_P
Senior Member

Joined: 20/03/2019
Location: United Kingdom
Posts: 162
Posted: 11:20pm 22 Feb 2023
Copy link to clipboard 
Print this post

Hi Stan,
Thanks for trying your code on a PicoVGA. I originally had the V5.07.06 on my standard Picomite, but then changed to the current V5.07.07b18 just in case it was fixed in this later issue.

Will wait for Peter's investigation results.

With best regards, Paul.
Nothing so constant as change.
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025