Nice way of tweening CCLabelTTF? - animation

Is there something to tween the font size CCLabelTTF in a nice way?
I guess using CCScaleTo does not really recreate the font every iteration now does it?

[label setFontSize:newFontSize];

There is no ("nice") way of tweening CCLabelTTF, as per the answer of LearnCocos2D.
So what I did, I just scale the rasterized version and on scale done I recreate it with font size scaled same, and also scale the node itself to 1 again.

Related

How to obtain "jagged" edges on silhouette images?

I am trying to replicate a paper in which silhouette images are transformed in order to have jagged edge:
Unfortunately, the paper doesn't provide any detail about how these were generated. Do you guys have any idea how could I go around it? Doesn't need to be exactly the same, the important bit is to mess up with the local features of each object. Ideally I would like to do it in python with OpenCV/PIL/PyTorch, but anything is ok really.
Thanks.
Just scale the silhouettes down to say 10% of their original size then scale them back up again. Optionally, threshold the result at 50% if you want pure bi-level... or use "Nearest Neighbour" when scaling to avoid introducing shades of grey in the first place. Scale to a smaller percentage for more jaggies.
Your top half scaled down to 10% then back up:
And to 20%:

Rotation Without Resizing

I'm creating a skin (possibly a set of skins) which I plan to publish at some point. As I was working I ran into an issue with rotating an image meter. Its size is dynamic to a scale variable.
The image is resized when it is rotated. I believe this is due to the diagonal of the image not fitting within the frame of the meter. Although I'm not sure how I can solve the issue.
The Following is the code of the Image Meter:
[icon0]
Meter=Image
ImageName=#Resources\images\gear.png
W=(50*#scale#)
H=(50*#scale#)
X=(5*#scale#)
Y=(5*#scale#)
ImageRotate=90
When the value of "ImageRotate" is changed from 90 to 45 the icon scales down.
I tried to look at an example which created the effect that I wanted, but I couldn't figure it out. I also looked for a forum, or information in the "Rainmeter Manual" to find some useful information. I found something about the ScaleMargin, but it didn't seem to have the effect I wanted.
Thank you in advance for any help that I get.
I think you need to calculate the maximum possible W/H after rotation yourself. Possibly change X/Y too, if you want it to rotate around origin.
There is an example shown here. It uses Rotator meter .
Looking at that example, your code would be like:
[icon0]
Meter=Image
ImageName=#Resources\images\gear.png
W=(SQRT((50*#scale#) ** 2 + (50*#scale#) ** 2))
H=(SQRT((50*#scale#) ** 2 + (50*#scale#) ** 2))
X=(5*#scale#)
Y=(5*#scale#)
ImageRotate=90
Haven't tested it myself, you may need DynamicVariables=1 for #scale#s, and you probably need to calculate X and Y if you want to rotate around the center of the image. Not sure what you want though, I'll leave it to you.
Edit:
You may also need DynamicWindowSize=1 under [Rainmeter] section as well. Otherwise it will crop the image after rotation, if it doesn't fit the initial size of the skin.

PNG images look blurry when scaled

I'm a visual/UI designer working on a project/product which has been designed by another designer. This designer provided the front-end dev with good quality PNG icons, but when the front-end dev sets the images scale to 0.7, they look blurry.
I've noticed that if we set the image's scale to 0.5, they don't look blurry at all:
0.7: [1]: http://i.stack.imgur.com/jQNYG.png
0.5: [2]: http://i.stack.imgur.com/hBShu.png
Anyone knows why does that happen?
I personally always work with 0.5 scales because I was taught so. Is there any logical reason for this?
Sorry if the answer is obvious. I am really curious about that. Thanks in advance.
What is happening largely depends upon the software that you are using to shrink the image. There is a major different between reducing by 0.5 and 0.7.
If you shrink by 0.5, you are combining 4 pixels into one.
If you shrink by 0.7 you are doing fractional sampling. 10 pixels in each direction get reduced to 7.
In 0.5 sampling, you read two pixels across, read two pixels down.
In 0.7 sampling you read 1.42857142857143 pixels in each direction. In order to do that you have to weight pixel values. That is going to create blurriness in a drawing.
It's because when you halve an image's size (in both dimensions), you effectively are combining exactly 4 pixels into one. However when you do a slightly off scale (such as 0.7) you have one and a fraction of a pixel going into one pixel (in each dimension). This means the data from one pixel is being used in up to 4 pixels, instead of one, causing a blurry effect.
Sorry, making an example image would be quite difficult for me, but I hope you get the concept.
I think this has to do with interpolation, when you resize an image there is no way of knowing what is supposed to be in-between the two pixels that are essentially being merged. What the computer tries to do is guess what the new pixel is supposed to look like by looking at the pixel around it and combining the values.
So for example in the image above it will go what is in between white and orange? a less bright orange. OK lets make the merged pixel look like that. When you get to a corner there might be more orange so the new pixel will look more orangey, you get the point.
Now when you scale by 0.5 the computer looks at the pixels and merges all the pixels together at a constant rate. What I mean by that is if you look at an image and try to divide it in half you will always merge 4 pixels together however if you scale by 0.7 your merging an irregular amount of pixels resulting in different concentrations of pixels as the image is scaled which results in a blurry image.
If you don't understand this I understand, I kinda went off on a tangent.... if you need more clarification comment bellow :)
Add an .img-crisp class to the image:
.img-crisp {
image-rendering: -moz-crisp-edges; /* Firefox */
image-rendering: -o-crisp-edges; /* Opera */
image-rendering: -webkit-optimize-contrast; /* Webkit (non-standard naming) */
image-rendering: crisp-edges;
-ms-interpolation-mode: nearest-neighbor; /* IE (non-standard property) */
}
The image-rendering CSS property sets an image scaling algorithm. The
property applies to an element itself, to any images set in its other
properties, and to its descendants.
Source.

CAShapeLayer Multiple Drawing At Once Swift 2.0

I want to create a visual representation of 3 different numbers that relate to how much of something a user has. I know it's probably best to use CAShapeLayer.
So I need to draw one circle radius at 40%, another(different color) at 65%, and another(diff color) at say 90%. They all need to be on top of each either. Similar to the image below.
Are there any Github classes to help with this? Also, can I animate the radiuss being filled concurrently?
Thanks!

Cocos2d v3 repeat texture

I was wondering how I should repeat a texture in Cocos2d 3. I have a background and I want to “tile” it across the screen. I have found this which is using ccTexParams with GL_REPEAT but those have been made private in version 3 of cocos.
I have found another solution which can be found here it creates a loop and positions a new child node based on the size of the texture and the size you want. But is that performant? Because when you have a 1px wide background texture and want to repeat that on a iPad retina, you have more than 2000 child nodes.
What is the best way to repeat a texture.
Well since there was no method for repeating without having a POT texture I made something of my own which takes care of it.
Might be useful for someone who has this same question. The code can be found here on Github.
CCTexture2D class has setTexParameters: method to set repeat mode. Also pay attention that the texture must have power-of-two width and height, otherwise repeating mode will be disabled.

Resources