The Big Bad G'MIC Thread of Silly Questions

Ah thanks. I don’t know what echo pass does though.

In any case i’ll rename it because I like shortcuts to be … short, and I don’t want to see my name everywhere in my files xD dab could cause problems later so I’ll go for pr_dab, or maybe pr_d.
Maybe I’ll ut this in the repo too, If someone needs it.
TBH I had totally forgot about the .gmic file, there was some old lost scripts in there…

That’s a CLI test thing. it prints pass. You can remove it.

Checking conditions?

Yep, that is what I use it for. I can also use echo something_else_here to check for individual lines of code as debugging.

Yes I usually do that with Bash. But with Gmic I usually insert a d in a condition, It’s very easy to see if it worked. Also, I was confused because there is a pass command in g’mic…

I modified it a little bit so that it doesn’t try to blend if there’s only one image in the list.

#@cli pr_dab: image_1,image_2,...
#@cli : Create alpha-blended images using existing images and insert onto the last list. If no arguments are specified, all images are blended as a new layer.
pr_dab:
if $!>1
  if $#>1 echo TEST +blend[$*] alpha
  else +blend alpha
  fi
fi
display

BTW it never echoed TEST , so I really don’t know how this if $#>1 thing work I guess?

1 Like

If you have two or more arguments, then it’ll echo TEST. Here, a throwback for me, and something for you to read:

Hi,

how can i draw lines inside a circle, going from the center and stopping at the edge?


You’re going too far, kids.

A bit of maths :slight_smile:

foo :
  400,400,1,3
  radius=150
  circle 50%,50%,$radius,0.25,255,255,255

  360,1,1,1,"
    const w2 = w#-1/2;
    const h2 = h#-1/2;
    const R = $radius;
    theta = x*2*pi/w;
    X = w2 + R*cos(theta);
    Y = h2 + R*sin(theta);
    RGB = u([100,100,100],[255,255,255]);
    polygon(#-1,2,w2,h2,X,Y,1,RGB)"
  rm.

1 Like

…and a lot of aspirin for me :face_with_head_bandage:

my example was just this test:
gmic run '800,800,1,3 circle 50%,50%,200,1,255,120,120 repeat 360 thickline 400,400,10*{200*cos($>)},10*{200*sin($>)},2,0.9,${-rgb} done '

At least I got them going in the right direction…

Thanks!

Does this mean I don’t need to use floor() when setting random RGB values with u? What happens when RGB values are floats? Are they automatically rounded?

They are not rounded, but “casted” (in the C/C++ sense) to integers, if the output format doesnt support float-valued pixels (so, basically jpg or png).

Oh, So it just drops the ".xxx… "
In that case, I think I have a lot of floors to… clean.

My opinion on this : there are no reasons to limit yourself to integer-valued pixels when generating images, at least until you save them.
You should consider that an image is a float-valued array, then ask yourself about the value range and type only when you want to export your image in some way (output a file, or display it in an unnormalized display).
That will surely simplify your scripts a lot !

I see. I didn’t like to see all these floats like 1.487638764875, and thought that maybe they would slow down things a bit. But I’ll do a code clean up when I can. Thanks for the advice.

No, images in G’MIC are all stored in float-valued format.
Having floats that are actually integers does not speed things up.
The only thing to avoid when possible, is having floats that are NaN or +-inf, as doing arithmetic with such values is indeed generally a bit slower in the CPUs.

Even worse in much more rare case, a BSOD error. I actually have if(xn==inf||yn==inf||xn==-inf||yn==-inf,break()); code just to stop BSOD from showing up in one of my CLI filters.

I don’t think i’ve run into this yet. Let’s hope I won’t :slight_smile:

About circle and lines :
Which one do you like? Each uses a different way of tracing the lines.
BTW I don’t know how to increase the polygon width in your example (I was using thickline in mine)



Don’t worry, I’m not there yet. I’ll just save that line just ine case though :slight_smile:

1 Like

Building this thing piece by piece… Will probably need a full rewrite though.

3 Likes

Looks good! Bravo :slight_smile:

Hi,

is there any way to make flower (or transform_polar) behave more erraticaly (without bursting the maths)? I find it a bit too regular here (pupil), i want to have some long spikes here and there, irreglarly.
Or maybe i should draw some (very) thin ellipses here and there to break the monotony?

1 Like