Post Reply 

How to work with anti-aliased shapes

Jul 12, 2014, 18:42
Post: #1
How to work with anti-aliased shapes
I am creating a simple sequence of characters that is meant to convey a certain meaning.

The sequence is simply "—[......]—>" and it is meant to serve as a "more" indicator for WordPress index views that display a post 'excerpt', ie. a short summary or teaser of the full post. Without this indicator it is unclear to the visitor that the displayed excerpt is just that, an excerpt. It needs to be visually indicated that there is more to be had. A "read more" link alone is not enough.

I first set out to find the perfect colour. I started out with a "[continued..]" text. I believe I took a white and then started lowering the alpha until I found something with a good lightness. I then took a screenshot and took pixel values from the combined rendering (background + alpha white). I fed the values back into the html but without any alpha. I then started meticulously altering the colours until I got something I considered near-perfect. Then I used GIMP to turn the colour I picked into HSV and then fed it back into the html and started to iteratively improve the characteristics.

I need the text to provide enough visual information to be informative without coming across as part of the excerpt itself. I realised that I need to add an alpha to it in order to have it blend into the background once more. I first fine-tuned my alpha to a very precise number. Then I realized there was another characteristic and it is the attention that the colour receives from a viewer. This was determined by the lightness. And there was another thing called conspicuousness. And it was determined by the saturation.

Once my attention and conspicuousness were set I realized the colour was not informative enough any more. I increased the alpha and then I needed to increase the lightness and saturation as well. After that it was done.

Strangely enough, and oddly and interestingly enough, my alpha and my lightness are exactly the same value. The alpha is "informativeness" while the lightness is "attention-drawingness". Apparently you don't want it to generate more attention than it's worth. More information means you automatically will want to be more exposed. If you are more exposed than you can handle, you will get shamed. But if you are less exposed than you can handle, nobody sees you.

Also, it occurs to me that "attention-drawingness" and "conspicuousness" are feminine and masculine dimensions of the same thing. The ability to draw attention requires silence, attraction. People are drawn to beautiful, harmonious things that ease their mind. The ability to get noticed requires noise, movement. People cannot ignore things that get in their field of vision.

My attention-drawingness is 65,53815% whereas my conspicuousness is only 30,37%. It seems my text would rather passively allow people to notice it, rather than be obtuse and make a fuss for no reason. I have no idea why I fine-tuned my alpha and lightness that much but apparently I notice a difference. Hard to imagine it still changes pixel values, but yeah.

After that was done I went on the journey of perfecting the text. Initially it was easy but I realized the graphic for the (italic) greater-than-sign is not up to par for the "arrow" need I have for it.

[Image: wp-more-tag.png]

This is the text on a black background. I figured I can just turn the text into an image and restore the alpha by doing color-to-alpha on black.

As you can see the > sign doesn't fit in well with the rest. For starters, it is too small.

But it is hard to realize what to change when any change to the basic form also requires doing "anti-aliasing computations" for all the pixels at the same time.

Ideally I would just work with the basic form in just one colour. Then when I'm done I would perform the same anti-aliasing that was done on this text to get a natural looking result again.

Chrome and Opera perform the same anti-alias as they are both based on WebKit. Firefox does something different:

[Image: wp-more-tag_firefox.png]

My impression in general is that Firefox provides for a "softer" colour. Not that it matters to me all that much. Although, if I am going to provide some anti-aliased text up front, in the form of an image, perhaps it would matter.

But in any case, here is my question:

Is there a good way to work with anti-aliased output like this? Is there a way to generate unaliased text that is identical to what these browsers display and then get the same aliasing applied to it?

I know GIMP can create raw text but I'm not able to specify the decimal percentages like I do in html (let's call it mind transfer) and this shitty program won't allow me to modify any layer at this point for a reason I am not able to divine. WTF really, nothing seems to be wrong but nothing gets modified in any layer even though it gives no error whatsoever Angry.

Should GIMP stop being an asshole to me at some point ...wait maybe I know it... if only GIMP would not suddenly make my layers tab disappear.... yes it works, but now I have pixels with both value of 65% and alpha of 65% but I cannot select an actual colour that has alpha so any pencil drawing I do won't have alpha so I need to revert to the pre-alpha stage which is probably necessary anyway but rather stupendous and...

The anti-alias of GIMP does something WAY different from what the browsers do...

actually doing something that makes no sense at all?

How this could be considered anti-alias, I don't know:

[Image: gimp-anti-alias.png]

Anyway it seems to be a fruitless endeavour.

Perhaps I just need to get some WebKit sources and build environment so I can use their filters and turn them on and off at will?

I really don't know what else.
Find all posts by this user
Quote this message in a reply
Jul 12, 2014, 22:56
Post: #2
RE: How to work with anti-aliased shapes
Thank you.

I have simply allowed myself to have fun adding and removing pixels without any clear idea of what I wanted to end up with. I ended up with a very pleasing result:

[Image: morearrow-large.png]

Amazing. I just spent half an hour adding and removing pixels at will. like a painter would also work iteratively, doing layer after layer. I had to allow myself to create something ridiculous, because at a certain point I would delete all of it again and just keep going.

I made sure I had a zoomed-in view at 800% and a regular window at 100%. I just kept looking back and forth when I felt like it and while humming some music I just went wild.

I had to quit judging completely what pixel I would copy where. And this is the result. Amazing!!!!!

Here is how it looks on my site:

[Image: xenhideout-morearrow-preview.png]

The image is really magical. You cannot define it. It is hard to grasp. You can see it, but it escapes your attention. You cannot really focus on it. You register its presence, and yet you skip over it completely.

I just have to get used to it. It is so strange and yet it feels so harmonious.

This more tag will work for anyone provided they use the same font. Which is "Lucida Sans Unicode" at 0.8em of the default (apparently ending up at 13px).

Much obliged for your consideration. I will check out that pathing functionality when I have the time and energy to do it some time. I haven't had the guts yet to dive into it.

Thank you for your "how to discover what GIMP isn't telling you about why it doesn't work". I believe the reason it stopped working for me is because I had selected one or more or less channels from the 4 colour channels. It is quite annoying and also rather futile that I was not able to select "alpha lock" on the alpha channel itself. Likely my bucket fill and other tools were only operating on the alpha channel, or something of the kind.

Strangely enough the "Lucida Sans Unicode" that GIMP uses gives me a less-slanted italic than the one in the browsers... You can see that on the image I posted. So it was not useful for generating that text anyway.

Regards, Sage.
Find all posts by this user
Quote this message in a reply
Jul 13, 2014, 08:23
Post: #3
RE: How to work with anti-aliased shapes
I know but it is hard to see whether the lock has been applied because the icon doesn't really indicate whether it has been selected. I have to look at the undo history to see whether it has taken effect. But like I said, the layers tab is a bad place for placing alpha locks when there is a channels tab that sports the alpha channel itself. I guess, if those channels are not bound to individual layers... but then still, they should be.

My symbol is still in a very primitive state.

I am going to try to transform it into something more useful. Unfortunately the Tools->Transform->Scale function doesn't preserve the harmonics, introducing vastly more colours than were originally present, and a lot of mysterious dark tones as well. It has taken me a long time to adjust levels to come up with something decent and I had to increase saturation a lot. It is nowhere near what it was before...

Well saturation is down again but now I need to increase alpha to a precise value and GIMP can't do it. Basically all I need is a tool that can multiply all alpha components by a fixed precise value. I would take:

PHP Code:
$transparency $pixel->alpha;
$newtrans $transparency CONSTANT;
$newalpha $newtrans;
$pixel->alpha $newalpha

where CONSTANT is a floating point or decimal value just below 1.

Perhaps there are some sweet image manipulation libs for PHP or Python...
Already done!

Script at generates the output I desired Big Grin.

It was a tad more complicated than I had anticipated but I just copied GIMP's model:
  • PHP alpha is a value between 0 and 127
  • the lower bound is defined as [0, 64)
  • the higher bound is defined as [64, 127]
  • 127 means fully transparent, 0 means fully opaque
  • any value < 64 simply gets multiplied by the constant
  • any value >= 64 gets inverted, multiplied and inverted back
  • inverting means here to do 127 - value

So if your constant is like 0.965, then the new "middle" becomes 61.76 and everything in [0, 64) gets scaled to [0, 61.76] and everything in [64, 127] gets scaled to [61.76, 127].

I think this is identical to the "levels" tool in GIMP when you leave the black at 0 and the white at 255. And you just change the "grey".

Basic script:
PHP Code:
$file "images/morearrow11.png";
$image imagecreatefrompng($file);

for (
$x 0$x imagesx($image); $x++) {
    for (
$y 0$y imagesy($image); $y++) {
$index imagecolorat($image$x$y);
$colar imagecolorsforindex($image$index);
$alpha $colar['alpha'];
$param 0.965421789022;
        if (
$alpha 64) {
$alpha $alpha $param;
        } else {
$alpha = (127 - (127 $alpha) * $param);
$color imagecolorexactalpha $image $colar['red'], $colar['green'] , $colar['blue'], round($alpha));
imagesetpixel $image $x $y $color );

header('Content-Type: image/png');

The concept of a "colour" is rather ill-defined in this PHP library. Every function that returns a "colour" actually returns an "index" that in practice just combines RGBA into a 32-bit number. To extract the values you can do your own arithmetic or you can just call that imagecolorsforindex($image, $index) and it will return an array with the components.

So is the array the colour? Is the index the colour? They ambiguate "index" with "colour" because they are trying to use the same system for truecolour and palette images.

Same as in GTK+. Very, very, very confusing and confounding. It took me many hours to "get" it in GTK+ and I basically just ignored all the references to "index" in this PHP library. Screw indices. That imagecolorexactalpha($image, $red, $green, $blue, $alpha) does nothing other than return $red | $green << 8 | $blue << 16 | $alpha << 24; or maybe the other way around.

So most of those "image" functions are meaningless in the context of truecolour because most of them cater for cases like when a certain colour is not in the palette of the image and you have to find the nearest match, or you have to register a colour by adding it to the palette, etcetera.

Anyway, too tired now to go on. Proceed with my image tomorrow again....

Kudos, Sage.
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Saving work John Rayner 2 284 Sep 3, 2018 09:35
Last Post: John Rayner
  Can't get copy and paste to work UlyssesBlue 4 1,024 Sep 8, 2014 09:43
Last Post: UlyssesBlue
  pattern fill info doesn't work lvquiet 10 1,198 Jun 5, 2014 06:37
Last Post: lvquiet
  I want to make my wheels look like there moving but it dont work? Kizzle 5 677 Jun 3, 2014 22:47
Last Post: Kizzle
  Fade Length doesn't seem to work for me Chris.Daley 1 508 May 23, 2014 23:20
Last Post: Chris.Daley

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS