I am trying to show my picture as a negative, and I coded it, but it wont show the picture as a negative, did I do something wrong?
def negative(picButterfly2):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
ALSO HOW DO I DRAW HORIZONTAL LINES? Thanks!
Try with correct variables names: you have picButterfly2 NOT EQUAL TO picButterfly1:
This works:
def negative(picButterfly1):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
file = pickAFile()
picture = makePicture(file)
negative(picture)
show(picture)
Also look at:
This (for negating images).
This (for drawing lines) - or any of those.
Your variables "red", "blue", and "green" already have a function in it, change it to a single character or just a capital letter like "Red". I know this was posted in 2014 but I'll leave a comment for the future.
Related
Using the answer provided by aka863 here: How to split merged Excel cells with Python?
I can unmerge, fill values and copy the styling. My questions is how to make the value assigning/filling process configurable.
I want the user to be able to choose whether the values will be filled vertically/horizontally.
I have tried changing the last loop where we assign the top_left_cell_values to unmerged cells. However I couldn't find a way to make it horizontal/vertical configurable. (I'm planning to use radio buttons and tkinter for this)
Its certainly possible to have the code de-merge cells and fill cells in whichever direction, vertically or horizontally regardless of which way the merge was originally. Or not fill at all, so only the top left cell retains the 'value' of the previously merged cells, which is default on unmerge.
Changing the direction of the fill requires some change and re-calculation on the max row and column values in the iter_rows loop, but is simple enough.
However it seems in your last comment you just want to give the user the option to fill or not fill on horizontal merges. In that case you just need to ask the question, and then run the iter_rows loop only if the response is yes.
The code sample below is based on the answer referenced question.
I'm assuming only single line horizontal merges since you dont mention what if anything should be done with vertical merges in the comment.
The code does initially check and indicate the merge direction either vertically or horizontally so it can be included take some action if a merge is vertical.
On code run after displaying the range and direction of the merge, the question is asked to fill, yes or no. If yes the cells are de-merged and all cells filled with the top left cell value using the iter_rows loop. If answer no then the cells are just de-merged.
from openpyxl import load_workbook
from openpyxl.utils.cell import range_boundaries
wb = load_workbook(filename='foo.xlsx')
st = wb['Sheet1']
mcr_coord_list = [mcr.coord for mcr in st.merged_cells.ranges]
direction_dict = {'v': 'vertical', 'h': 'horizontal'}
for mcr in mcr_coord_list:
print('---------------------------------------------------\n')
merge_direction = ''
min_col, min_row, max_col, max_row = range_boundaries(mcr)
top_left_cell_value = st.cell(row=min_row, column=min_col).value
if min_col == max_col:
merge_direction = 'v'
elif min_row == max_row:
merge_direction = 'h'
print(f"The cell range {mcr} is merged {direction_dict[merge_direction]}ly with the data '{top_left_cell_value}'")
while True:
demerge_fill = input('Do you want the de-merge to fill all cells(y|n)? ')
if demerge_fill.lower() in ["y", "n"]:
break
else:
print('Invalid response')
st.unmerge_cells(mcr)
if demerge_fill == 'y':
for row in st.iter_rows(min_col=min_col, min_row=min_row, max_col=max_col, max_row=max_row):
for cell in row:
cell.value = top_left_cell_value
else:
print(f"Only the top left cell {mcr.split(':')[0]} will contain the data!")
wb.save('merged_tmp.xlsx')
Looking at the vscode documentation for user defined snippets, it would appear that using the regex transform, you can do if/else conditions.
However, I can't seem to find any examples of this and I'm struggling to understand the correct syntax based on the BNF alone.
Can someone explain the syntax for this?
For example,
Lets say I have a snippet like this:
"body": [
"let color = '${1|white,black|}';",
"let hex = '${???}';"
]
If color==white, I want hex to output #fff, otherwise if black #000.
This works:
"color conditional": {
"prefix": "_hex",
"body": [
"let color = '${1};",
"let hex = '${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}/}';" //works
],
"description": "conditional color"
},
However, as soon as I try it with default placeholders and choices, like
"let color = '${1|white,black|}';", // does not work
Apparently, you cannot do snippet transforms on default placeholder values. See transforms on placeholder values issues
I used the simpler if transform style, so here:
${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}
if there is a group 1 $[1} in this case white then replace that group 1 with #fff and if group 2 (black) replace with #000, etc.
You could make it just an if/else (white) or not pretty easily.
"let hex = '${1/(white)/${1:?#fff:#000}/}';" // any non-`white` entry will print `#000`.
${1:? => if group 1 (white) print #fff , else print #000
The vscode docs are not very helpful on these conditional replacements, if you have more questions on their syntax, let me know.
Is there a unicode character that signifies filtering (for example, a funnel) that is widely available on common computer operating systems?
Some of the most similar chars I've found so far:
∀, ∨, ∇, ▼, Y, Ⴤ, V, ᗊ, ⑂,
ツ
You can use search engines that allow you to draw like
http://shapecatcher.com/
http://www.mausr.com/
http://detexify.kirelabs.org/classify.html
I'm not able to find anything similar to the funnel but here are some possible results:
Turned shogi piece: ⛉ ⛊
Sector: ⌔
Down-pointing triangle with right half black: ⧩
Alchemical symbol for water: 🜄
Alchemical symbol for horse dung: 🝖
Canadian syllabics carrier hee: ᐶ
Rightwards arrow through superset ⭄
Subset above rightwards arrow ⥹
Rightwards arrow through greater-than ⭃ (probably should be rotated when display)
Greater-than above rightwards arrow ⥸
Rightwards arrow with tail ↣
Z notation range antirestriction ⩥
Excel does have a funnel shape when filtering data (see the icon in the c column above "7" in the below table) but I'm not sure whether they use an image or character for that since window inspection tools can't work out that symbol
In some cases the scissors ✀ can be used to signify "cut out unnecessary parts"
This is not really an answer, but possibly useful for anyone finding this page looking for a filter funnel icon. Here's a hack to make something look like a funnel - stack a triangle and a bar!
.filter-triangle,
.filter-bar {
position: absolute;
top: 0;
left: 0;
width: 1em;
text-align: center;
}
.filter-bar {
top: 0.1em;
}
<div class=filter-bar>❘</div>
<div class=filter-triangle>▼</div>
Alternatively this is an SVG icon I made:
<svg viewBox="0 0 80 90" focusable=false><path d="m 0,0 30,45 0,30 10,15 0,-45 30,-45 Z"></path></svg>
Both need aria attributes for accessability, amongst other problems! Both snippets are WTFPL-licenced!
Or you can use the MIT licenced filter icon from Feather.
I usually use the following:
y filter
Y active filter
¥ cancel or disable filter
Late here, but I like this ⫧
Found it by using shapecatcher.com which someone here suggested.
It works particularly well as a small placeholder in the inputs for my column filters.
(image)
https://unicode-table.com/en/2AE7/
I needed the same, and as far as I can tell there is no FUNNEL, FILTER or REDUCE symbol in Unicode.
However there is this:
⊆ U+2286 SUBSET OF OR EQUAL TO
You can use the character "X" with the Webdings Font, and it will give you a Speaker icon. Rotate it 90° and it'll be like a Funnel.
There is a proposal for a funnel (filter):
https://www.unicode.org/wg2/docs/n5181-repertoire-postAmd1.pdf
1CE08
Until it is released, the best character is the one provided by #phuclv (https://stackoverflow.com/a/51728429/5390321)
🝖 (1F756)
This is the best character I could find for myself ⊕
Unicode Character 'CIRCLED PLUS' (U+2295)
Which is by no means a funnel, but a kind of like a cross-hair insinuating "target more specific results". There are literally thousands of characters though...
In my case, I am going to use IcoMoon to replace the icon for this character, check out the IcoMoon app here
If you dont have a character map tool, you can use this quick PHP snippet to print out a range of unicode characters:
<?php
for ($i=hexdec("25ff");$i<=hexdec("26ff");$i++) echo sprintf("&#%u; ",$i);
Prints
◿ ☀ ☁ ☂ ☃ ☄ ★ ☆ ☇ ☈ ☉ ☊ ☋ ☌ ☍ ☎ ☏ ☐ ☑ ☒ ☓ ☔ ☕ ☖ ☗ ☘ ☙ ☚ ☛ ☜
☝ ☞ ☟ ☠ ☡ ☢ ☣ ☤ ☥ ☦ ☧ ☨ ☩ ☪ ☫ ☬ ☭ ☮ ☯ ☰ ☱ ☲ ☳ ☴ ☵ ☶ ☷ ☸ ☹ ☺ ☻
☼ ☽ ☾ ☿ ♀ ♁ ♂ ♃ ♄ ♅ ♆ ♇ ♈ ♉ ♊ ♋ ♌ ♍ ♎ ♏ ♐ ♑ ♒ ♓ ♔ ♕ ♖ ♗ ♘ ♙
♚ ♛ ♜ ♝ ♞ ♟ ♠ ♡ ♢ ♣ ♤ ♥ ♦ ♧ ♨ ♩ ♪ ♫ ♬ ♭ ♮ ♯ ♰ ♱ ♲ ♳ ♴ ♵ ♶ ♷ ♸ ♹
♺ ♻ ♼ ♽ ♾ ♿ ⚀ ⚁ ⚂ ⚃ ⚄ ⚅ ⚆ ⚇ ⚈ ⚉ ⚊ ⚋ ⚌ ⚍ ⚎ ⚏ ⚐ ⚑ ⚒ ⚓ ⚔ ⚕ ⚖ ⚗ ⚘
⚙ ⚚ ⚛ ⚜ ⚝ ⚞ ⚟ ⚠ ⚡ ⚢ ⚣ ⚤ ⚥ ⚦ ⚧ ⚨ ⚩ ⚪ ⚫ ⚬ ⚭ ⚮ ⚯ ⚰ ⚱ ⚲ ⚳ ⚴ ⚵ ⚶ ⚷ ⚸
⚹ ⚺ ⚻ ⚼ ⚽ ⚾ ⚿ ⛀ ⛁ ⛂ ⛃ ⛄ ⛅ ⛆ ⛇ ⛈ ⛉ ⛊ ⛋ ⛌ ⛍ ⛎ ⛏ ⛐ ⛑ ⛒ ⛓ ⛔ ⛕
⛖ ⛗ ⛘ ⛙ ⛚ ⛛ ⛜ ⛝ ⛞ ⛟ ⛠ ⛡ ⛢ ⛣ ⛤ ⛥ ⛦ ⛧ ⛨ ⛩ ⛪ ⛫ ⛬ ⛭ ⛮ ⛯ ⛰ ⛱
⛲ ⛳ ⛴ ⛵ ⛶ ⛷ ⛸ ⛹ ⛺ ⛻ ⛼ ⛽ ⛾ ⛿
Good luck
While it won't be a funnel, I would suggest to use the web symbol: 🕸
After all, a web allows to catch the resource after which its user is looking for while letting much of the rest going to some ignored places.
Ψ 03A8
ψ 03C8
¥ 00A5
⁝ 205D
⁞ 205E
⥺ 297A (Rotated to point down)
⦀ 2980
⧨ 29E8
⧩ 29E9
⧪ 29EA
⏚ 23DA
🔍 128269
🔎 1F50E
There are a lot pictured here https://www.vertex42.com/ExcelTips/unicode-symbols.html
This may help. While looking for the same thing I found that I could print a funnel using this JavaScript line:
String.fromCharCode(57710); // Prints:
But it doesn't work all the time. Most of the time I end up with a box, like: "". I'm still trying to figure out why that is.
I have a label (e.g. "A list of stuff") and some content (e.g. an actual list). When I add all of this to a PDF, I get:
A list of stuff: test A, test B, coconut, coconut, watermelons, apple, oranges, many more
fruites, carshow, monstertrucks thing
I want to change this so that the content is aligned like this:
A list of stuff: test A, test B, coconut, coconut, watermelons, apple, oranges, many more
fruites, carshow, monstertrucks thing, everything is startting on the
same point in the line now
In other words: I want the content to be aligned so that it every line starts at the same X position, no matter how many items are added to the list.
There are many different ways to achieve what you want: Take a look at the following screen shot:
This PDF was created using the IndentationOptions example.
In the first option, we use a List with the label ("A list of stuff: ") as the list symbol:
List list = new List();
list.setListSymbol(new Chunk(LABEL));
list.add(CONTENT);
document.add(list);
document.add(Chunk.NEWLINE);
In the second option, we use a paragraph of which we use the width of the LABEL as indentation, but we change the indentation of the first line to compensate for that indentation.
BaseFont bf = BaseFont.createFont();
Paragraph p = new Paragraph(LABEL + CONTENT, new Font(bf, 12));
float indentation = bf.getWidthPoint(LABEL, 12);
p.setIndentationLeft(indentation);
p.setFirstLineIndent(-indentation);
document.add(p);
document.add(Chunk.NEWLINE);
In the third option, we use a table with columns for which we define an absolute width. We use the previously calculated width for the first column, but we add 4, because the default padding (left and right) of a cell equals 2. (Obviously, you can change this padding.)
PdfPTable table = new PdfPTable(2);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.setTotalWidth(new float[]{indentation + 4, 519 - indentation});
table.setLockedWidth(true);
table.addCell(LABEL);
table.addCell(CONTENT);
document.add(table);
There may be other ways to achieve the same result, and you can always tweak the above options. It's up to you to decide which option fits best in your case.
I have a column in SSRS report. The value is "True" or "False" or "Yes" or "No" or "1" or "0"
Instead of showing that in that column, I would like to use indicator.
I placed indicator in that column but need to set start and end property. How do I go about doing it so I can show green checkmark when it's "True", "Yes", or '1" and red otherwise?
I am trying =IFF(Fields!Column_name.Value = "True", "Red", "Green") for the Start value for Green Check mark...but obviously I am wrong...
any help?
Well maybe its just a typo in your question but a couple things stand out
the function is IIF, not IFF
The True result should come first after the condition
I've never used the indicators before, but looking briefly at them, it looks like you can define ranges that are acceptable (green), unacceptable(red), or in the middle (yellow).
Start and End should probably be numeric values, "Green" and "Red" don't seem like valid values.
Try binding the indicator value expression to something like this.
=IIF(Fields!ColumnName.Value = "True" OrElse
Fields!ColumnName.Value = "Yes" OrElse
Fields!ColumnName.Value = "1", 100, 0)
Go to the Indicators properties > Values And States and put the Check's Start & End Value to 1. And the X put it's Start & End Value to 0.
Then write your expression like this:
=iif(First(Fields!YourField.Value, "YourDataSet")=True,1,0)
That should give you a Check if checked or an X if not.