svirjee fractal

Started by johnno56, June 28, 2021, 22:17:41

Previous topic - Next topic

johnno56

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.

jsalai

#1
Quote from: johnno56 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

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

max can have a list of numbers or variables as argument:


x=408:y=920
?max(123,y,567,x,345,890)


gives 920

another remark:
athough SB correctly handle the line


hot = if(max(red,green,blue)<255,max(red,green,blue),0)


it should be


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!
I won't belong to any organization that would have people like me as members.
[Groucho Marx]

johnno56

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.

jsalai

#3
Quote from: johnno56 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

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

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...
I won't belong to any organization that would have people like me as members.
[Groucho Marx]

johnno56

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.