How do I change a class or module color in ruby mode for emacs 24? - emacs24

I want to able to change colors of methods, classes, modules, etc. I don't know how to do it in an easy way.
Thanks,

Place the point (cursor) on a method, M-x customize-face will allow you to change features of the font, just press enter and the Customize Face buffer will pop up. Move the point to Foreground and change the colour. M-<TAB> will give you a list of available colours. When you have chosen a colour, enter C-c C-c and close the buffer. Now you should be done.

Related

HomeKit - Changing Lightbulb Color Without Transition

I am making an app that uses HomeKit enabled lights for notifications. When I write a new value to the hue characteristic of a lightbulb, the color is transitioned from it's current hue to the hue written. So instead of going from it's currently color (let's say Red) immediately to the written color (let's say Purple) it goes from Red, Pink to Purple as well as all the "in between" colors.
How can I immediately change the color of a HomeKit Enabled lightbulb from one color to the next without this transition?
It's the accessory that receives the notification from the HomeKit server that the value of hue changed and it decides how to transition from one to another. The app itself cannot 'immediately' transition the color. It is up to the lightbulb itself.
If there is indeed a hard-coded into the light bulb logic board way of changing the hue, and it's only by cycling through the colors, then there is little to do about it.
I can only think of hacks in such case: for example, you might turn the bulb off, then change the hue, then turn it back on, and see if this results in a better transition (I have no idea if this should work at all, but it is worth a try).

How does clDefault color work?

I noticed some unusual behaviors using clDefault color.
clDefault = TColor($20000000); //536870912
As an example (http://wiki.freepascal.org/Colors):
Using it for Brush will use the normal background brush of the target
DC (device context).
On a Form's canvas a FillRect will paint a
rectangular area filled with the normal background of a standard
window. This is whatever the widgetset and theme defines. This might
be the color gray or a gradient or a picture.
Using clDefault on the
Canvas of a TListBox will paint with the normal background, which is
normally white on Windows. So in a TListBox clDefault is the same as
clWindow.
Using it as Pen color will use the default line color for
the device context.
Using it as Font color will use the normal text
color of the device context.
Could someone tell me how clDefault works?
I mean, is it interpreted by the OS or by the VCL code and how?
You provide a link to FPC documentation, but then talk about the VCL and tag the question Delphi. I'm going to assume that you are asking about Delphi VCL and just ignore your linked documentation which does not apply.
In the VCL, for pens, fonts, and brushes, the default color is black. That's because $20000000 has 0 for R, G and B channels. The alpha channel is $20, but is ignored, certainly for methods like LineTo, FillRect, etc. This is quite different from the FPC documentation you linked to.
If you use clDefault for the Color of a TListBox, then it will again be black. Again, different from the FPC documentation you linked to.
Certainly the value $20000000 has no special meaning to GDI. For pens, fonts, brushes etc. the value is passed down to GDI which interprets it as black.
If you study the VCL source code you will find a variety of places where clDefault is used. In the main clDefault is used as a sentinel value. The VCL code checks whether or not a specified color property is equal to clDefault, and then takes special action if it is.
So far as I can tell, that's all there is to it. Some parts of the VCL treat clDefault as a sentinel, otherwise it is black.

Highcharts: backgroundColour "layers"?

At present I'm generating a chart based on a bunch of user-selected options, and this is rendered on the server to generate a png output file. The generated png chart is then displayed on the user's system, over an underlying system background.
Where the plotBackgroundColor of the chart has some opacity, the user's underlying system background will of course show through, and will influence how the chart appears.
That's all fine, because the user has complete control over both the highcharts plotBackgroundColor and the system background colour.
But now I want to generate a chart that is "free standing", with a solid background colour (no opacity) which represents exactly how the chart appears when over the system background. That way, I can display that chart on any system, to give a true picture of what the user is seeing, regardless of the system background colour in the target device.
I do have access to the user's system background colour (it's either a bitmap, or I can just extract the "dominant" colour somehow and use that as a solid colour instead if it's easier).
So using the concept of layers, this would be like merging the highcharts plotBackgroundColor with a solid colour that represents the system background colour, and using that as plotBackgroundColor instead.
Or maybe there's a way to change an underlying background "browser" colour that is used in the highcharts renderer, independent of plotBackgroundColor?
I'm sure this must be possible somehow?
One way of doing this, and it's what I'm doing until someone posts a better answer, is just to manually combine each backgroundColor value with the underlying system canvas colour, using the method described at https://stackoverflow.com/a/10782314/4070848. This is basically just laying one colour over the other, and using an algorithm to determine the combined colour based on the respective opacities and rgb values.
I check whether the backgroundColor is a plain colour or a linear/radial gradient, and if the latter then I combine each of the stop colours separately with the underlying colour and reconstruct the gradient based on the merged stop colours.
Seems to work OK, but maybe there's an off-the-shelf method, or maybe someone can tell me how to do it better...!

iOs draw an intereactive map

I need to draw an interactive map for an iOs application. For example it can be the map of the US showing the states. It will need to show all the states in different colors ( I'll get this from a delegate colorForStateNo: ) It will need to allow the user to select a state by touching it, when the color will change, and a "stick out" effect should be shown, maybe even a symbol animated to appear over the selected state. Also the color of some states will need to change depending on external events. This color change will mean an animation like a circle starting in the middle of the state and progressing towards the edges changing the color from the current one to the one inside the circle.
Can this be done ,easily in core-graphics? Or is it only possible with Open GL ES? What is the easiest way to do this? I have worked with core graphics and it doesn't seem to handle animation very well, I just redraw the entire screen when something needed to move... Also how could I use an external image to draw the map? Setting up a lot of drawLineToPoint seems like , a lot of work to draw only one state let alone the whole map ...
You could create the map using vector graphics and then have that converted to OpenGL calls.
Displaying SVG in OpenGL without intermediate raster
EDIT: The link applies to C++, but you may be able to find a similar solution.

Partial re-colorizing a Bitmap at runtime

I'm drawing some cars. They're Bitmap's, loaded from PNG's in the library. I need to be able to color the cars-- red ones and green ones and blue ones, whatever. However, when you paint the car green, the tires should stay black, and the windows stay window-color.
I know of two ways to handle this, neither one of which makes me happy. First, I could have two bitmaps for each car; one underneath for the body color, and one on top for detail bits. The underneath bitmap gets its transform.colorTransform set to turn the white car-body into whatever color I need. Not great, because I end up with twice as many Bitmap's running around on screen at runtime.
Second, I could programmatically search-and-replace "white" with "car-body" color when I load the bitmap for each car. Not great either, because the amount of memory I take up multiplies by however many colors I need.
What I would LIKE would be a way to say "draw this Bitmap with JUST THE WHITE PARTS turned into this other color" at runtime. Is there anything like this available? I will be less than surprised if the answer is "no," but I figure it's worth asking.
You might have answered the question yourself.
I think your first approach would need only two transparent images: one with pixels of the parts that need to change colour, one with the rest of the image. You will use colorTransform or ColorMatrix filter by case. It might even work with having the pixels the need the colour change covered with Sprite with a flat colour set on overlay ?
The downside would be that you will need to create a 'colour map'/set of pixels to replace for each different item that will need colour replacement.
For the second approach:
You might isolate the areas using something like threshold().
For speed, you might want either to store the indices of the pixels you need to replace in an Vector.<int> object that could be used in conjuction with BitmapData's getVector() method. (You would loop once to fetch the pixel indices that need to be replaced)
Since you will use the same image(same dimensions) to fill the same content with a different colour, you'll always loop through the same pixels. Also keep in mind that you will gain a bit of speed by using lock() before your loop to setPixel() and unlock() after the loop.
Alternatively you could use Pixel Bender and try some green screen/background subtraction techniques. It should be fast and wouldn't delay the execution of the rest of your as3 code as Pixel Bender code runs in it's own thread.
Also check out Lee's Pixel Bender subtraction technique too.
Although it's a bit old now, you can use some knowledge from #Quasimondo's article too.
HTH
I'm a little confused where you see the difference between your second approach and the one you would like to have. You can go over your loaded bitmap pixel by pixel and read out the color. If it turns out to be white replace it with another color. I do not see occurence of multiplied memory consumption.
You might want to try my selective color transform: http://www.quasimondo.com/archives/000614.php - it's from 2006, so some parts of it could probably be replaced by a pixel bender filter now.
Why not just load the pieces separately, perform the color transform on the one you want to change, then do a BitmapData.copyPixels() with the result? The blit routine runs in machine code, so is wicked fast. Doing it pixel by pixel in ActionScript would be glacially slow in comparison.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html#copyPixels()

Resources