September 28, 2021, 05:49:10

Author Topic: svirjee fractal  (Read 327 times)

Offline johnno56

  • Jr. Member
  • **
  • Posts: 49
  • Logic is the beginning of Wisdom.
svirjee fractal
« on: June 28, 2021, 22:17:41 »
One small question.

Within the SB examples there is svirjee_fractal_1.bas...

There is one line of code I do not understand... "hot = if(max(red,green,blue)<255,max(red,green,blue),0)"

Could some explain what this means?  I am familiar with "max()" only having two parameters... How does it work with three?

Just curious.

J
May your journey be free of incident.

Live long and prosper.

Offline jsalai

  • Jr. Member
  • **
  • Posts: 41
Re: svirjee fractal
« Reply #1 on: June 29, 2021, 00:19:28 »
One small question.

Within the SB examples there is svirjee_fractal_1.bas...

There is one line of code I do not understand... "hot = if(max(red,green,blue)<255,max(red,green,blue),0)"

Could some explain what this means?  I am familiar with "max()" only having two parameters... How does it work with three?

Just curious.

J

https://smallbasic.github.io/reference/739.html

max can have a list of numbers or variables as argument:
 
Code: [Select]
x=408:y=920
?max(123,y,567,x,345,890)

gives 920

another remark:
athough SB correctly handle the line

Code: [Select]
hot = if(max(red,green,blue)<255,max(red,green,blue),0)

it should be

Code: [Select]
hot = iff(max(red,green,blue)<255,max(red,green,blue),0)

just to make a difference between if and iff (someday may this be separated in sources)

cheers!
« Last Edit: June 29, 2021, 00:37:40 by jsalai »
I won't belong to any organization that would have me as a member.
[Groucho Marx]

Offline johnno56

  • Jr. Member
  • **
  • Posts: 49
  • Logic is the beginning of Wisdom.
Re: svirjee fractal
« Reply #2 on: June 29, 2021, 00:57:10 »
Ok. I am familiar with the principles of max(). The three variables threw me off.

I am trying to understand the format of the condition. I am guessing that the comma in the equation is like a 'then'?

So, in a nutshell, if the largest of the three variables in max() is less than 255 then the largest of the three variables equals 0?

Am I getting warm?

J
May your journey be free of incident.

Live long and prosper.

Offline jsalai

  • Jr. Member
  • **
  • Posts: 41
Re: svirjee fractal
« Reply #3 on: June 29, 2021, 07:12:07 »
Ok. I am familiar with the principles of max(). The three variables threw me off.

I am trying to understand the format of the condition. I am guessing that the comma in the equation is like a 'then'?

So, in a nutshell, if the largest of the three variables in max() is less than 255 then the largest of the three variables equals 0?

Am I getting warm?

J

https://smallbasic.github.io/reference/638.html

Code: [Select]
hot = iff(max(red,green,blue)<255,max(red,green,blue),0)
it means literary:

if the "largest of these three color components" is less than 255, then set the "hot" variable to that value (the "largest of these three color components"), otherwise, set the "hot" to zero.

This only affects (changes) the "hot" variable...
« Last Edit: June 29, 2021, 07:31:19 by jsalai »
I won't belong to any organization that would have me as a member.
[Groucho Marx]

Offline johnno56

  • Jr. Member
  • **
  • Posts: 49
  • Logic is the beginning of Wisdom.
Re: svirjee fractal
« Reply #4 on: June 29, 2021, 13:53:39 »
Cool... Thanks for the explanation. I was only used to max() having two parameters.

J
May your journey be free of incident.

Live long and prosper.

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal