Set region icon tint color without defining scope - sublimetext2

So I'm currently working on a Sublime Text plugin [my firt] that displays pips in the gutter that match colors in lines of css. Similar to what JetBrains does:
I have a bit of a problem though. As far as I can tell when adding a region I can only give the region a scope which the template then themes. Now I could write out a template file that defines every hex code as a scope and a theme to match but that sounds ghastly. Is there a better way to do this? Is it possible to color a region separately from the theme? I'm very new to ST plugins so if there's a crucial piece of the docs I've missed let me know :)
Here's a very stripped down version of my plugin to show how I'm achieving this currently:
import sublime, sublime_plugin
class FooCommand(sublime_plugin.TextCommand):
def run(self, edit):
regions = [s for s in self.view.sel()]
for region in regions:
lines = self.view.split_by_newlines(region)
for index, line in enumerate(lines):
self.view.add_regions("csspip-{0}".format(index), [line], "csspip", "dot",
sublime.HIDDEN | sublime.PERSISTENT)
Make a selection and run view.run_command('foo') from the console to see what it does currently [not much].

So it turns out someone has already done what I was trying to do, and I was searching for the wrong things. It's called Gutter Color.
They're actually calling imagemagick to create a custom icon file for every color sublime sees. Which sounds insane, but is the only way to do it [apparently]. I wont quote the code because context is required, but if you got the following line you can work out what they did to make it work:
https://github.com/ggordan/GutterColor/blob/master/line.py#L88

Related

Dynamically change line color dcc.Graph Plotly Dash between annotations

I'm writing a 'template creation' app using the dcc.Graph image annotation features in Plotly Dash.
The user adds multiple rectangles for specific features in the image (an invoice) and my callback captures the coordinates of each rectangle via the relayoutData variable. I want to use a different color for each rectangle, but can't figure out how to do it.
It seems like the only way to change the newshapes fillcolor
property is to replace the whole figure, but then I lose all previous shapes
All and any help appreciated.
Andrew
I have just found the following demo that does exactly what I am trying to do:
https://dash-gallery.plotly.host/dash-image-annotation/
Now to unpack the logic and adapt it to my context ... Happy 2021!
Andrew

How to prevent mxGraph GraphEditor automatically applying blue colouring to loaded diagrams

I've got a customised instance of GraphEditor in a view in an ASP.NET MVC app and I've got it set to use a database for diagram persistence. When opening, I've programmed it to create a new model to initialise the graph using the model data stored in the database. This works, except that vertexes and edges that were black and white when saved become blue when loaded. I'm guessing there's some default mxGraph style variable that's responsible for this, but I'm not sure. Anyone have any ideas? Thanks!
So, in case it's useful to anyone else, I actually found the solution. The default colours are defined in mxClient as hexadecimals and can be replaced with whatever you want to use.

How to make functions appear purple

So from just learning how to make functions, I thought of if I could turn the function purple, just like a normal print() or str() function. And with that in mind, it may seem pretty obvious that I am still a beginner when it comes to coding. From what I know, it may have something to do with sys.stdin.write, but I don't know. This will help me to make different languages for others who don't speak or write English.
In Options => Configure IDLE => Settings => Highlights there is a highlight setting for builtin names (default purple), including a few non-functions like Ellipsis. There is another setting for the names in def (function) and class statements (default blue). You can make def (and class) names be purple also.
This will not make function names purple when used because the colorizer does not know what the name will be bound to when the code is run.
Colors for Python
Use Atom and use this theme: https://atom.io/themes/darkpython-syntax
There are more themes here: https://atom.io/themes/search?utf8=✓&q=keyword:python
You can install Atom from: https://atom.io

Custom GitHub badges with dynamic color

I struggle with creating a shields.io badge which changes color dynamically.
I am able to use the JSON response to parse a text into a badge and set the color to orange:
https://img.shields.io/badge/dynamic/json.svg?label=custom&url=https://jsonplaceholder.typicode.com/posts&query=$[1].id&colorB=orange
Works well...
However, I want to change the color according to a rule. I might return the HEX color in JSON as well to be parsed into the badge. I tried the public API to get a random color and test the behavior:
http://www.colr.org/json/color/random
I get the first randomly get color with JsonPath $.colors[0].hex and place it o the badge URL as both as the dynamic value and color:
https://img.shields.io/badge/dynamic/json.svg?label=custom&url=http://www.colr.org/json/color/random&query=$.colors[0].hex&colorB=$.colors[0].hex
Regardless of the randomly chosen color, the result is always somehow green (the last generated result was #D0BB79:
I would expect something like this which correctly matches the #D0BB79 color:
How to make the color dynamic as well? The sample dynamically colorful badges are provided with Coveralls.io, Codecov.io or SonarCloud.io.
I had similar trouble, and ended up using a command line tool called anybadge which takes thresholds as parameters. This allows you to generate a badge with dynamic color in one command:
anybadge -l pylint -v 2.22 -f pylint.svg 2=red 4=orange 8=yellow 10=green
Colors can be defined by hex color code or a pre-defined set of color names.
The main difference here is that this isn't done by referencing a URL, so can't be embedded in the same way. I use this in my CI pipeline to generate various badges, then store them as project artifacts and reference them in my project README.md.

Flex 4.5 , How to create generic skinning library and dynamically change the theme of my AIR application?

I'm working on enterprise level AIR application, i need to change my application UI for multiple clients,it has a complex UI with more that 250 MXML skin files for all display objects such as buttons, combo box, containers, etc., Is it possible to create a generic skin library for managing skins and assets through CSS or i have to create a separate library for each of the clients?
Currently i'm duplicating the skin files for each client and changing the color values (styles) in CSS (which is the default.css for skin library) and Path data in skins.
Is there any easy way to create a skinning themes in flex 4.5 and managing assets(icons, fxg) in library?
Thanks in advance
Create a custom theme
I suppose you already know this, but creating a custom theme is simply a matter of:
creating a custom skin for every component
creating defaults.css file to assign those skins and perhaps provide some additional styling information
making sure that css file is included in the swc
applying the theme with the --theme compiler flag (or through whatever means your IDE provides)
Applying different colour schemes
You can use chromeColor and some other predefined styles to address this issue, but this approach may prove limiting. I solved this by substituting the Spark skin base classes with my own more elaborate versions. There's too much code to paste here, but it comes down to this:
I created an interface like this:
public interface IColorizedSkin {
function colorizeBorder(color:uint, lowLight:uint, highLight:uint):void;
function colorizeBackground(color:uint, lowLight:uint, highLight:uint):void;
function colorizeShadow(color:uint):void;
}
and I implemented this interface in my custom versions of:
SparkSkin
SparkButtonSkin
ColorizedItemRenderer
These three functions are called from an overridden updateDisplayList and use custom CSS style names like chromeBorderColor (which is an array of colours that expresses the base colour, the lowligth colour and the highlight colour of the border of a component).
All skins that need colorizing extend these base classes.
The defaults.css in the theme library comes with a default colour scheme, but you can override it by adding another css file with different colorizing directives to the client application.
Note that since these custom style names were not added as metadata to the components, you will only be able to assign these colours through CSS or through ActionScript, not through MXML attributes.
Colorizing icons
If you have an icon set that uses sufficiently neutral colours (for instance all icons are dark grey, or perhaps a grey gradient), you can colorize these too.
The simplest approach which works for solid colors is something like this:
if (iconDisplay) {
var colorTrans:ColorTransform = new ColorTransform();
colorTrans.color = getStyle("color");
iconDisplay.transform.colorTransform = colorTrans;
}
If you need something more finegrained, you'll have to work with a transform matrix.
Using different icons
I wouldn't bake icons into the skins, because that would reduce flexibility. I tend to include icons in the library swc, so one can access them from there.
If you need different icon sets for different client applications, simply create a swc including only these assets (i.e. no compiled code) for each set. As long as the names and paths inside those swc's are the same, you should be able to substitute one for the other.