When describing paths in SVG, online examples often separate values with commas, while others don't.
The paths tutorial from the Mozilla Developer Network SVG Tutorial uses both notations to describe arcs:
A 30 50 0 0 1 162.55 162.45
and
A 45 45, 0, 0, 0, 125 125
Elsewhere, I have also seen:
A30,50 0 0,1 100,100
When and where do SVG path descriptions need commas?
Commas are mostly optional and whitespace is also mostly optional. You need one or the other in some cases to say when something ends and the next thing begins i.e. so that 1,1 or 1 1 is not parsed as 11.
You can put a single comma between any two numbers so A, 30 50 0 0 1 162.55 162.45 is invalid as is A 30,, 50 0 0 1 162.55 162.45
The W3C SVG Recommendation states that:
Superfluous white space and separators such as commas can be eliminated (e.g., "M 100 100 L 200 200" contains unnecessary spaces and could be expressed more compactly as "M100 100L200 200").
Related
I'm trying to find information on how file marks are stored in the 'viminfo' file. For example, here is an entry I have:
'0 3 11 ~/.vim/hello
|4,48,3,11,1592944829,"~/.vim/hello"
The only obvious things from the above seem to be the filepath the mark is saved, ~/.vim/hello and the timestamp it was created 1592944829. What are the other items, and why are some of the items listed multiple times (3, 11, filename).
you are reading the wrong block.
In the viminfo file, search for the lines beginning with >, they are mark histories.
And there is usually comment in the file.
For example:
# History of marks within files (newest to oldest):
> /tmp/test/whatevertestfile.txt
* 1592998167 0
" 4 0
^ 1 0
. 1 0
+ 1 0
a 4 0
b 9 0
update
Oh, I just noticed you mentioned file marks in the question. Then you are looking at the right block.
The positions in the two lines are always the same because the write_one_filemark() function reads the same values for the two lines.
The first 4 is an index in the viminfo file, it indicates the mark type.
The 48 is the ascii code of the numbered mark 0 .
Then come the position + ts + filename
If you want to know more detailed, why it is so defined and so on, you can read the related part of this file
https://github.com/vim/vim/blob/master/src/viminfo.c
In my logs trials are coded like this:
12_120_20_120_1
The only indicator of the trial type is the second last number between the underscores.
I would like matlab to search for a given number, in a given position.
I tried coding it as 'star_star_star_120_star'
But it does not work.
In fact, looking for strings with '* *' does not work for me at all, when I am using code like:
if length (strfind (logs{nl,4}, '9_220_20_120_2'))>0
(the above code works, it does not feature stars and it will only find one trial, I want it to find all trials in 120 in position star_star_star_120_star)
I cannot just search for 120 within a string,
[if length (strfind (logs{nl,4}, '120'))>0]
cause it will also appear in different positions of possible strings in that column, so it will also return what i am NOT looking for
(e.g. '9_120_20_160_2').
(by 'star' I mean the star symbol, it dissapears when I type it here)
I am ready to clarify, if this is not unclear.
here are a few lines of my typical log:
Subject Trial Event Type Code Time TTime Uncertainty Duration Uncertainty ReqTime ReqDur Stim Type Pair Index
MROT_PILOT_09_03_M6 222 Picture INSTRUKACJA_PRT2 37667 0 1 111167 1 0 next other 0
MROT_PILOT_09_03_M6 222 Pulse 111 148743 111076 0
MROT_PILOT_09_03_M6 223 Picture PRZERWA 148834 0 1 100167 1 0 next other 0
MROT_PILOT_09_03_M6 223 Pulse 111 173703 24868 0
MROT_PILOT_09_03_M6 223 Pulse 111 198743 49909 0
MROT_PILOT_09_03_M6 223 Pulse 111 223702 74868 0
MROT_PILOT_09_03_M6 223 Pulse 111 248663 99829 0
MROT_PILOT_09_03_M6 224 Picture FIX 249002 0 1 10167 1 0 next other 0
MROT_PILOT_09_03_M6 225 Picture 11_60_80_20_2 259168 0 1 50167 1 0 50000 hit 11
MROT_PILOT_09_03_M6 225 Pulse 111 273703 14534 0
MROT_PILOT_09_03_M6 225 Response 2 292049 32880 1
(Idk how to format this better, sorry)
here is the important part of my code:
MRIpulse= find (strcmp (logs (:,3) , 'Pulse'));
firstMRIpulse =MRIpulse(1)
for nl = firstMRIpulse:length (logs (:,1))
%HARD2
if length (strfind (logs{nl,4}, '9_220_20_160_2'))>0
if length (strfind (logs {nl,12}, 'hit'))>0
HARD2SCORE (end +1) = 1;
else HARD2SCORE (end +1) = 0;
for nextrow = nl+1:length (logs (:,1))
if length (strfind (logs{nextrow,3}, 'Response'))>0
HARD2RT(end +1) = str2num (logs{nextrow,6})
break
end
end
end
end
I found an answer to this problem. I modified the code in the following way:
instead of:
if length (strfind (logs{nl,4}, '9_220_20_160_2'))>0
I have:
if strfind (logs{nl,4},'_')
ind=strfind(logs{nl,4},'_')
if strcmp (logs{nl,4} (ind (3)+1:ind(4)-1), '40')>0
So basically I create indexes for each underscore in my trial code (which is always formatted like this: 'number_number_number_number_number'), and I look for the number (which is actually formally a string) between the 3th and 4th underscore.
I also changed strfind to strcmp, cause e.g. if my trial name is '9_220_20_160_2', and I used strfind the result would be positive for both '160' and '60', however if I use strcmp it will be positive for '160' only (so it makes my search more precise).
The rest of the code stays the same.
If anyone's interested I can further clarify this.
I would use strsplit. I find it easier to understand and very easy to change what you search for.
spst = strsplit(logs{n1,4}); % Assuming logs{n1,4} is that x_y_z_XXX_w
numBeforeLast = str2double(spst{4}); % Number before the last underscore - XXX you are searching for.
if (numBeforeLast == number_you_are_searching_for)
% You found the case, do whatever you want with it.
end
I have a web page I have designed with a specific color scheme, and I want to have 4 specific colors from that scheme to be the only hues present in my images. Essentially, I want to collapse four ranges of hues to four discrete hues. Within one hue I want to maintain the existing tints/brightness variation.
I would like to perform this shift using CSS filters.
I believe I would use feColorMatrix or feComponenentTransfer, however I cannot find an example that shows how to do this kind of shift with 4 or more colors (I only see examples of shifting rgb to either 2 colors, or shifting individually red, green, and blue, so that you go from a certain three color structure to a different three color distribution).
I would like to shift the images so that they only contains these 4 hues:
rgb(82, 79, 161)
rgb(0, 173, 220)
rgb(242,235,22)
rgb(183, 36, 103)
To clarify, this is a visual representation about I would like to see things shift:
You can use this example image:
Here's some basic code/snippet to get you started:
.four_colors {
/*insert filter here */
}
<img class ="four_colors" src="http://i.stack.imgur.com/FGKUX.png">
If you can help, I'd appreciate it greatly!
This is not possible. The SVG Filter primitives that underly CSS Filters do not have HSL-aware primitives (although they should IMHO). Even the hue-rotate filter is a (bad) RGB approximation.
It is not possible to take hue ranges and posterize them. It IS possible to take RGB or brightness ranges and posterize them, so if you want to restate your question in that way, there are solutions. If you really want hue manipulation, you'll have to write that from scratch in Canvas.
By way of inspiration, here is an example of selective color selection using RGB in a filter:
http://codepen.io/mullany/pen/ApInK
<filter id="redselect" color-interpolation-filters="linearRGB">
<feColorMatrix in="SourceGraphic" result="BigRed"type="matrix" values="0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
3.8 -4 -4 0 -0.5" >
</feColorMatrix>
<feColorMatrix type="saturate" values="0" in="SourceGraphic" result="GreySource"/>
<feComposite operator="in" in="SourceGraphic" in2="BigRed" result="RedOriginal"/>
<feComposite operator="atop" in="RedOriginal" in2="GreySource" result="final"/>
</filter>
I have large matrices of data that look something like this:
DataOut' = [34 1 0.0 -4.75343000000000 0.0291776000000000 5.32835000000000 1.23598000000000 0.890008000000000;
7 1 0.0902364000000000 -4.74065000000000 0.0 1.97133000000000 9.49706000000000 16.1658000000000]
The first two columns are IDs and always integers and the remaining 6 columns are 2 pairs of (X,Y,Z) coordinates (Floats) for each respective ID.
I'm writing the data to a file using the following syntax:
fprintf(' %u %u %-6.12g %-6.12g %-6.12g %-6.12g %-6.12g %-6.12g \r\n', DataOut)
>> 34 1 0 -4.75343 0.0291776 5.32835 1.23598 0.890008
7 1 0.0902364 -4.74065 0 1.97133 9.49706 16.1658
This format is fine in almost all cases except the one highlighted above, where the insignificant trailing zeros are replaced with spaces, leading to a big gap between some columns instead of the single space. The software reading this data really doesn't like all theses spaces and breaks when it finds more than the expected one.
My desired output is to only have a single space between each column:
>> 34 1 0 -4.75343 0.0291776 5.32835 1.23598 0.890008
7 1 0.0902364 -4.74065 0 1.97133 9.49706 16.1658
Does anyone know how to get fprintf do just leave one space after removing the insignificant trailing zeros? Using fprintf is nice because I don't need any loops and when you have several thousand of these matrices to be written out I guess that would be quite slow if I had to do some checking in a loop?
The format spec that you have used for floating point numbers (%-6.12g) species that you want to remove trailing zeros that are non-significant (with a maximum of 12 numbers after the decimal). However, the -6 specifies that you want each field to be at least 6 characters wide. In the case of your 0, it has a width of 1 so fprintf will pad it to be 6 characters wide (hence all the whitespace). If you simply remove the -6 from the beginning of each of your format specifiers you will get the output you desire.
fprintf(' %u %u %.12g %.12g %.12g %.12g %.12g %.12g \r\n', DataOut)
% 34 7 1 1 0 0.0902364 -4.75343 -4.74065
% 2.917760e-02 0 5.32835 1.97133 1.23598 9.49706 0.890008 16.1658
I am attempting to format a string in such a way, that I can make a repeating sequence of numbers an arbitrary length.
I've been looking at these examples: How do I format a number with a variable number of digits in Python? and String Formatting in Python 3.
Here's what I tried to do:
print("{0:{1}{2}d}".format(0, 0, 8))
will result in eight pretty 0's all in a row like so: 00000000
but attempting to change the second argument from 0 to 25
print("{0:{1}{2}d}".format(0, 25, 8))
Results in an a single 0 that is as far right as it can go in my console instead of 25252525 So I think the issue is using a string with more than one character as filler instead of a single character.
The specification for string formatting goes like this:
format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]
In this case, we're only interested in the [0][width] part. [0] is an optional parameter which pads numbers with zeros, so you can format 4 as '004'. [width] specifies the total width of the field.
When you write:
print("{0:{1}{2}d}".format(0, 0, 8))
It becomes:
print("{0:08d}".format(0))
Which is a 0 padded with zeroes up to a length of 8: 00000000.
However, your other example:
print("{0:{1}{2}d}".format(0, 25, 8))
Becomes:
print("{0:258d}".format(0))
Which is a 0 padded with spaces (because there is no 0 in the formatter) up to a length of 258.
I think string formatting is not suited to solve your problem. You can use other fill characters than 0 (using the [fill] option in the formatting spec), but it can't be more than one character.
The simplest way to get what you want is probably this:
>>> print((str(25) * 8)[:8])
25252525