Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

Let Sim Innovations know about your Air Manager experience and let us know about your dream feature addition

Moderators: russ, Ralph

Post Reply
Message
Author
Toddimus
Posts: 39
Joined: Wed Feb 17, 2021 6:01 pm

Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#1 Post by Toddimus »

Hi there,

I looked around for a viewport circle and the closest thing I could find was Ralph's example siff for a custom viewport. While that satisfies some use cases, it ultimately requires blocking a rectangular region at the outer extremes. I want the effect to end at the outer edge of the circle. I'd like to be able to move an image across and behind a circular viewport while not affecting the layering transparency outside the circle. Think moving glare on a steam gauge face. It needs to end at the edges of the bezel and not show up on the rest of the rectangular instrument's pixels.

I know it's been requested in the past, along with a polygon viewport shape. I just wanted to add another vote for this.

Can we pretty, pretty please have something like this? I think we could make some really cool stuff with it.

viewport_circle(x , y, radius)

Thanks!
Last edited by Toddimus on Thu Dec 28, 2023 9:01 pm, edited 1 time in total.
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

Toddimus
Posts: 39
Joined: Wed Feb 17, 2021 6:01 pm

Re: Request: viewport_circle(x,y,radius)

#2 Post by Toddimus »

So I decided to see if I could replicate this effect with the tools available and it turns out that, technically yes I can... but it's not really feasible in normal use.

It's a crude, brute force way of getting a result similar to what I'm asking for. Way too processor heavy if you make the circle have nice edges with a higher "pixel" density. Check out the code to see how I did it.

Demo - Viewport Circle Demo.siff
(16.69 KiB) Downloaded 141 times
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Sling
Posts: 5277
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#3 Post by Sling »

Another bump for a viewport circle or the ability to add a circular canvas which would give a similar ability is really needed. This was originally discussed back in the AM3.6 thread.

https://siminnovations.com/forums/viewt ... 667#p17667

Toddimus
Posts: 39
Joined: Wed Feb 17, 2021 6:01 pm

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#4 Post by Toddimus »

Agreed! Circular canvas and circular viewport would be awesome!!

Could you guys at SI have a look at feasibility? I have an immediate use case for it and it would save me a ridiculous amount of vector graphics work if it were available.

And maybe as a bonus, generalized related feature... (I think Sling mentioned this a long time ago too) ... being able to create an arbitrarily defined viewport using vectors. It would be akin to canvas_draw's _fill except that instead of filling with a color, it would make what's inside the closed vector loop visible and everything outside the loop transparent.

Thanks!!
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

User avatar
Corjan
Posts: 2967
Joined: Thu Nov 19, 2015 9:04 am

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#5 Post by Corjan »

Hi,


Did have a look at this couple of years ago, but unfortunately it is not something that can easily be added.

You can git somewhat of the functionality by drawing your own shape in canvas, and then do a fill_img. The image will only show up within the shape.


Corjan

Toddimus
Posts: 39
Joined: Wed Feb 17, 2021 6:01 pm

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#6 Post by Toddimus »

Thanks @Corjan ! The _fill_img will get me most of the way there actually, in terms of my immediate use case. For some reason, I had never noticed that method.

But, I still have a use case for the circular and arbitrary shaped viewports. I want to make glare and lighting masks move across the faces of instruments without affecting the transparent background around the instrument/panel. I hope you guys can still take a look one of these days.
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

Toddimus
Posts: 39
Joined: Wed Feb 17, 2021 6:01 pm

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#7 Post by Toddimus »

For grins, I thought I'd try to "trick" the viewport into making a circle...

This works:
my_canvas = canvas_add(0, 0, 100, 100, function()
_rect(0,0,100,100,50)
_stroke("red", 1)
end)

So I was hoping this might work:
my_image = img_add("my_image.png",0,0,100,100)
viewport_rect(my_image, 0, 0, 100, 100, 50) --- note the added "Argument id[6]", which I was hoping would be corner radius, like it is in _rect. Interestingly, it didn't error out with the added argument.
Simstrumentation Instrument developer
Check us out http://www.simstrumentation.com or https://github.com/Simstrumentation/Air-Manager

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

Re: Request: viewport_circle(x,y,radius) -- EXAMPLE ADDED

#8 Post by Keith Baxter »

Toddimus wrote: Wed Aug 28, 2024 4:04 pm For grins, I thought I'd try to "trick" the viewport into making a circle...

This works:
my_canvas = canvas_add(0, 0, 100, 100, function()
_rect(0,0,100,100,50)
_stroke("red", 1)
end)

So I was hoping this might work:
my_image = img_add("my_image.png",0,0,100,100)
viewport_rect(my_image, 0, 0, 100, 100, 50) --- note the added "Argument id[6]", which I was hoping would be corner radius, like it is in _rect. Interestingly, it didn't error out with the added argument.
Nice find. Will give it a try.
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 

Post Reply