Reverse function for libGDX Color.toFloatBits - colors

The method Color.toFloatBits
com.badlogic.gdx.graphics.Color#toFloatBits(float, float, float, float)
packs any RGBA color into a single float in libGDX.
Is there any ready-to-use reverse function available?

Nevermind, I think I found the answer.
It should be
new Color(NumberUtils.floatToIntColor(floatBits));

Related

Directx12- Texture always returns ZERO when the texture format is UINT

Recently,I am learning the SAT(summed area table) Varinance Shadow Mapping.It is suggested in the paper that I can use uint format SAT to prevent precision loss.So I change my SAT format from DXGI_FORMAT_R32G32_FLOAT to DXGI_FORMAT_R32G32_UINT.However, with the same code and shader except the texture format is different, the float format texture works fine, but the uint format texture always returns ZERO(I find this problem by using RenderDoc pixel debugger).This problem persists when I use Sample() method , Load() method and even compute shader!
I have tried many ways but nothing works.Please help me!!!!!!!!!
And I do not show any code here,because I have no idea about which part of code to show.
I am a Rookie just like my name.
So if you need some code,please tell me.Thanks a lot!!
If possible,please tell me some possible solutions of this problem. Thank you very much for your answers!

In Haskell, how to get 0.03, instead of 3.0e-2?

Basically the title. I'm trying to display floats in a string, but the result ends up being "3.0e-2" (In the example of the float "0.03"). How do I get in decimal form in Haskell? Thanks to anyone who answers.
For pretty formatting values of built-in types, use printf:
> printf "%f" (0.03 :: Float)
0.03
See the linked docs for a full explanation and all possible formatting options.

How do I document rtype when a function returns multiple values

I've just started using PyCharm and it is teaching me quite a bit about the correct ways to document things. That documentation then makes the IDE more productive. But, it's raised a question for me.
I see that there are a couple of ways to document the data type of the value returned by a function.
In the function definition use -> type
In the function comments use :rtype: type
But, how does this work for functions that return multiple values? For example, if a function returns both a boolean AND a float, how do you document this?
Thanks!
It is really simple using type annotation:
def func(i: int) -> (bool, float):
You would do something similar in the docstring.

Can a TextEncoding be converted to a String?

It is possible to convert a string to a TextEncoding using
mkTextEncoding :: String -> IO TextEncoding
Is there any way to do do the reverse? Or, given a TextEncoding, any way to find out any information about that encoding? There doesn't even seem to be an Eq instance for TextEncoding to allow comparing against the defined encodings in System.IO.
Am I missing something, or is there a technical reason why this should not be possible?
TextEncoding will be a member of the Show class in GHC 7.0.1. See ticket #4273.

How can I draw a bitmap rotated in wxPython?

How do I draw a bitmap to a DC, while rotating it by a specified angle?
I agree with Al - he deserves the answer, but this (admittedly untested) code fragment should do what you asked for:
def write_bmp_to_dc_rotated( dc, bitmap, angle ):
'''
Rotate a bitmap and write it to the supplied device context.
'''
img = bitmap.ConvertToImage()
img_centre = wx.Point( img.GetWidth()/2, img.GetHeight()/2 )
img = img.Rotate( angle, img_centre )
dc.WriteBitmap( img.ConvertToBitmap(), 0, 0 )
One thing to note though from the docs:
...using wxImage is the preferred way to load images in wxWidgets, with the exception of resources...
Was there a particular reason to load it as a bitmap rather than a wx.Image?
I'm not sure that this is the best way of doing it, but one option would be to convert it to a wx.Image with ConvertToImage (wxWidgets help) and then use the rotate function (wxWidgets help). You could then (if necessary) convert it back with ConvertToBitmap (wxWidgets help).
I couldn't see an obvious function that could be used to apply a coordinate transform to the drawing context (DC), but there may be one in there somewhere...
Hope that helps.
Better way would be to use Graphics context if you want a generic rotation e.g. rotate bitmap or text or any other drawing path
gc = wx.GCDC(dc)
gc.Rotate(angle)
gc.DrawText("anurag", 100, 100)

Resources