Page 2 of 3

Re: Canvas Textures

Posted: Thu Apr 29, 2021 9:21 pm
by JackZ
Yes, the canvas feature has been a huge improvement introduced in AM v3.x (remember my lame attempt at an interim graphic library anyone?) thanks Corjan!

It is not a real war TBH, As said previously, the key here is « the right tool for the right task ».

Jacques

Re: Canvas Textures

Posted: Thu Apr 29, 2021 10:05 pm
by Keith Baxter
Jacques,

Some nice work bud.

@Corjan Jacques and I have an understanding and all this is for the benefit of all peeps to get an Idea of what can and cannot be done on each approach. Both approaches have their pro's and cons. This will give peeps an idea of when to use what approach. Yes we are spoiled and can mix and match.

Just have to get this one in :mrgreen: Is 3D on the radar anytime soon?

I am sure both of us would love that.

Keith

Re: Canvas Textures

Posted: Mon Aug 16, 2021 3:53 pm
by Keith Baxter
Hi

:D :D :D
I have been thinking about switch shadows and a hack towards 3D .

Having done some work regarding maps and the manipulation of data this is possible. Expensive though.

@Corjan I do not want to spend weeks on this if there is something coming soon.

I have something in mind and will work on it.

I suppose that the graphic data from the sim frame needs to be had some how? Is that data available?

Keith

Re: Canvas Textures

Posted: Mon Aug 16, 2021 8:45 pm
by Keith Baxter
Peeps i am inquisitive, and <Canvas Textures> is not far of the challenge to create shadows and graphic movement.

I can manipulate a polygon within canvas_draw() to simulate a switch and a fixed shadow. Even stretch or compress.

I am just thinking here @Corjan , From an automation point of view. A camera function.

This camera function could be... Manipulation of the node.

I think this could work.

The node is added to the... camera_id=camera_add(node_id..)

effects would need to be along the lines of turnstile, roller etc....

Keith

Re: Canvas Textures

Posted: Tue Aug 17, 2021 7:01 am
by Keith Baxter
Hi,

Here you go @JackZ Something you will love.




Keith

Code: Select all

my_canvas=canvas_add(0,0,500,200)
   canvas_draw(my_canvas, function()
     _rect(0,0,500,200)
     _fill("yellow")
     _circle(15,15,15)
     _fill("red")  
     _rect(0,80,350,80)
     _fill_img("switch_small_down.png",0,80,350,80)
   end)

val1=10
val2=5
function dial_callback(dir)
  val1=val1+(dir*20)
  val2=val2-(dir*10)
   canvas_draw(my_canvas, function()
     _rect(0,0,500,200)
     _fill("yellow")
     _circle(15,15,15)
     _fill("red")   
     _rect(0+val2,80,350+val1,80)
     _fill_img("switch_small_down.png",0+val2,80,350+val1,80)
   end)
end

my_dial=dial_add(nil,0,0,30,30,dial_callback)

Re: Canvas Textures

Posted: Tue Aug 17, 2021 7:38 am
by Keith Baxter
Hi,

It might be that this concept could be used to create a joy stick. ??


Keith

Re: Canvas Textures

Posted: Tue Aug 17, 2021 7:51 am
by jph
Hi Keith,
What about a different approach ?. If the switch visible area is a 'view window', then could you not use a strip image with a long series of fixed progressive switch images for the movement and then progress that 'strip' image behind the window ?. Done at the appropriate speed it would give you a progressive movement view of the switch change. - or a rotary disk - whatever.
It is the same idea as the old 'flipbook animation' used more than 150 years ago (some historical example go back more than 600 years) only that the changing images would be on a strip or circular continuous png that was moved along - or 'around' behind the view window.

https://en.wikipedia.org/wiki/Flip_book

try a quick search on flipbook animation on YT for examples. It would be the same principle with a strip of images that were stepped along in a way that would be one frame per step.
I believe there are even on line tools that can create progressions --

Joe.

Re: Canvas Textures

Posted: Tue Aug 17, 2021 8:02 am
by Sling
Nice one Keith. Interesting concept. Is the switch a png added to the canvas or is it all pure vector graphics.

Re: Canvas Textures

Posted: Tue Aug 17, 2021 8:16 am
by Keith Baxter
Sling wrote: Tue Aug 17, 2021 8:02 am Nice one Keith. Interesting concept. Is the switch a png added to the canvas or is it all pure vector graphics.
Yes Tony,

It is a .png in a canvas. One could also manipulate a vector graphic in the same way.

@jph Thanks for the heads up. I will take a look.

Keith

Re: Canvas Textures

Posted: Tue Aug 17, 2021 11:02 am
by JackZ
Nice find @Keith Baxter !
I doubt it would be really useful for a switch or a joystick where the transition from one position to another is almost instant due to the spring loaded nature of the switch, so the good old image swap is still my favorite, but I sure could find usages for animation of this, maybe for shadows.

Will have to experiment

Jacques