Small Feature Errors

Discuss suspected bugs with other users and Sim Innovations Staff

Moderators: russ, Ralph

Message
Author
The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

Small Feature Errors

#1 Post by The Artful Dodger »

Hello:

I have been programming lately and I noticed what I consider to be errors as I will discuss. First, let me insert an image which illustrates the error:
Error Panel.png
Error Panel.png (744 Bytes) Viewed 885 times
and here is the lua logic file:

Code: Select all

PaneCanvas = canvas_add(0, 0, 200, 100)
BoxCanvas = canvas_add(15, 15, 150, 40)
--
	canvas_draw(PaneCanvas, function() 
		_rect(1, 1, 198, 98)
		_stroke("#FFD700", 2)
--
		_move_to(25, 60)
		_line_to(150, 60)
		_stroke("#FFD700", 1)
--
		_move_to(100, 50)
		_line_to(100, 90)
		_stroke("#FF0084", 1)
--
	end)
--
	canvas_draw(BoxCanvas, function()
		_rect(2, 2, 148, 23)
		_stroke("#008000", 1)
--
		_move_to(10, 10)
		_line_to(125, 10)
		_stroke("#9932CC", 1)
--
	end)
--
Now, before I point out the errors, I want to make clear that I drew the 4 solid boxes (Green, Purple, Gold, & Red) to illustrate the correct RGB colors as a comparison with the colors that AM produced, which were very washed-out versions of those colors:
1. The 4 colors inside the Gold panel are washed out. All are associated with lines that are supposed to be 1 pixel in width.
2. 3 sides of the green box (Top, Left, & bottom) are 2 pixels in width, the right side (pardon the pun) is correctly 1 pixel in width.
3. The 3 long lines (Purple, Gold, & Red) are all 2 pixels in width and not 1 as specified in the stroke commands.

These are commands that I have used successfully in the past so there has been a recent change. Please note that the lua code in the code box above is all the code in the instrument folder.

Thank you for your help and I look forward to learning the outcome.

Sparky

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Small Feature Errors

#2 Post by Keith Baxter »

Hi Sparky,

It is clear that you did not understand what I was saying.

Try this code to understand how _stroke() works.
If you draw outside of the canvas then those Px will be lost.

You can play around by adding _line_to() rect() circle() etc . As long as the draw is within the canvas you will not lose Px.

Code: Select all

PaneCanvas = canvas_add(0, 0, 200, 200)
	canvas_draw(PaneCanvas, function() 
		_rect(0, 0, 200, 100)	
		_fill("#FFD700", 0.2)	
	
		_rect(1, 1, 198, 98)
		_stroke("red", 2)

--Lets add a _rect() 1 Px so that it shows the 1 PX on each side and top.
		_rect(1.5, 1.5, 197, 30)
		_stroke("blue", 1)	
		
		_move_to(10, 15)
		_line_to(125, 15)
		_stroke("blue", 1)		
		
		
--Lets add a _rect() 1 Px so that it shows the 0.5 PX on each side.
 		_rect(1, 35, 198, 30)
		_stroke("black", 1)
--Lets add a _rect() 1 Px so that it shows the 0 PX on each side and the bottom.		
 		_rect(0.5, 69.5, 199, 30)
		_stroke("green", 1)	

--This pink area is to demonstrate a draw that exceeds canvas(0 parameters
		_rect(0, 100, 200, 100)	
		_fill("pink", 0.4)

		_rect(1, 102, 198, 97)
		_stroke("black", 2)	

--Lets add a _rect() 6 Px so that it shows the 1 PX on left side and 3 Px on right side.
		_rect(3, 138, 197, 30)
		_stroke("blue", 6)			

	end)
There is nothing wrong with _stroke(). It is a math thing in your calculations regarding the _rect() and canvas size.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: Small Feature Errors

#3 Post by Tetrachromat »

Hi Sparky

The effects you are encountering depend on your 'Graphics' settings in the 'Settings' tab of AirManager. What are your settings?
- Graphics API
- Image presacaling
- Anti aliasing

You will get different effects on different settings. Try them out. If you enlarge the screenshots x20 (I use IrfanView) you can see the different artifacts quite clearly.

And @Keith Baxter, he is not drawing outside the canvas. All strokes are inside the canvas.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Small Feature Errors

#4 Post by Keith Baxter »

Tetrachromat wrote: Sat Jan 14, 2023 8:44 pm And @Keith Baxter, he is not drawing outside the canvas. All strokes are inside the canvas.
Hi
I disagree Paul.
Sparky said
2. 3 sides of the green box (Top, Left, & bottom) are 2 pixels in width, the right side (pardon the pun) is correctly 1 pixel in width.
This is also incorrect as the code supplied states that the stroke is 1 Px. His image is showing 1Px (left, top, bottom) and 0.5Px on the right side

Anyway...His code ...

This will produce a right side of the _rect() having a 0.5 Px line. This is because the _rect() starts at 2 Px and is 148 Px in length (150). Now the stroke is 1 PX so we have to add 0.5 to that making a total draw length of (150.5). That means that 0.5 Px of the rect() is outside of the canvas.

Code: Select all

BoxCanvas = canvas_add(15, 15, 150, 40)
	canvas_draw(BoxCanvas, function()
		_rect(2, 2, 148, 23)
		_stroke("#008000", 1)
       end)
If Sparky wants the stroke to be 2 Px then the math below will change. However for 1Px... To be within the canvas it needs to be like below.

Code: Select all

BoxCanvas = canvas_add(15, 15, 150, 40)
	canvas_draw(BoxCanvas, function()
		_rect(1, 2, 148, 23)
		_stroke("#008000", 1)
       end)
Or

Code: Select all

BoxCanvas = canvas_add(15, 15, 150, 40)
	canvas_draw(BoxCanvas, function()
		_rect(1.5, 2, 147, 23)
		_stroke("#008000", 1)
       end)
Or

Code: Select all

BoxCanvas = canvas_add(15, 15, 150, 40)
	canvas_draw(BoxCanvas, function()
		_rect(0.5, 2, 149, 23)
		_stroke("#008000", 1)
       end)
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Small Feature Errors

#5 Post by Keith Baxter »

Hi,

What might help to lessen confusing, is if @Corjan could make a parameter (left, right, center) or (inside, outside, center) align for strokes.
I know what the answer is going to be though. ;)

Keith
Last edited by Keith Baxter on Sat Jan 14, 2023 11:54 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

Re: Small Feature Errors

#6 Post by The Artful Dodger »

I was not aware of the graphics settings you mention and next time I have the laptop turned on (tomorrow morning) I will certainly look for them, especially the anti-aliasing.
Keith: I can't be more appreciative of the fact that you steered me towards canvas because it is absolutely down my street. But on this occasion I must disagree when you say that it is doing what I told it to. My graphics program allows me to easily see down to the pixel and I know that it isn't behaving like it did. However I must have a look at the graphics settings - they may be my undoing. I am thinking about making a crude video (crude because I have never made one before and I'm not sure where to begin) showing exactly how I go from a rough drawing to the finished article in AM.

Thanks to both of you for taking the time to come to my rescue.

Sparky

P. S. Would someone please explain to me how you reference someone as "@Keith Baxter" or "@Corjan"? Thanks.

User avatar
Keith Baxter
Posts: 4685
Joined: Wed Dec 20, 2017 11:00 am
Location: Botswana

Re: Small Feature Errors

#7 Post by Keith Baxter »

Sparky,

Did you copy the code I posted in post #2 and run it?

For the @ thing. When you type @ and a few search chars like "keith" then a pop up menu appears with users. in this case <Keith Baxter and keithskaggs>. Click on the user and they will be mentioned.

Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board,  32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card 

The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

Re: Small Feature Errors

#8 Post by The Artful Dodger »

@Keith - No, I didn't run anything because the laptop was put up for the night. But, first thing tomorrow I will. And thanks for the mention thing.

Sparky

The Artful Dodger
Posts: 204
Joined: Sat Jul 09, 2022 3:20 pm

Re: Small Feature Errors

#9 Post by The Artful Dodger »

Hello, all:
Well, I sit here red-faced because as @Tetrachromat (thank you - I hope I learned the answer early enough that my hair will still regrow!) suggested, there is a settings section of AM! I honestly don't remember ever paying it any attention. But "Image Prescaling" and "anti-aliasing" were both ticked. I removed the ticks and here's the result - and I have changed nothing in the code!! Notice that, with the exception of the gold box around the panel, all the lines are 1 pixel in width!
Error Panel - Corrected.png
Error Panel - Corrected.png (575 Bytes) Viewed 793 times
And, note to self: RTFM!

Sparky

User avatar
Ralph
Posts: 7933
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Small Feature Errors

#10 Post by Ralph »

Those options are useful for analog gauges, but indeed maybe less useful for digital.

Post Reply