r= byte.Parse(colours[0]); = 255
g= byte.Parse(colours[1]); = 0
b = byte.Parse(colours[2]); = 0
I have the RGB values as shown above.When i try to use the variables and retrieve the color I am not getting any color in my HMI but when i pass the same values directly i am able to get the color in my silverlight HMI
zoneColour.Color = Color.FromArgb(255,r,g,b); - DOES NOT WORK
zoneColour.Color = Color.FromArgb(255,255,0,0); -WORKS
May this helps you:
//r,g and b must be in integer data type
zoneColor.Color = new SolidColorBrush(Color.FromArgb(r, g, b));
Another method is here.
Related
I'm working on a custom OSL shader for Maya. I'm adding attributes to the shape node of objects and using getattribute() in my OSL code to manipulate those attributes. I have attributes for color correct, base color, rim width and rim color. (the last 2 are for facing ratio). My OSL always compiles and I'm always able to connect it to the material I'm using. But every time I check if it's working in the Arnold render view, my sliders on my attributes don't do anything. The goal is to have an image file connected to the base color of the material and have the color correct node affect base color (which would affect the texture file)
At first I thought my problem was I was trying to do too much in a single OSL node (I was using getattribute for all of the attributes I listed above). So I tried isolating it to just the color correct attribute and still nothing. Is anyone familiar with OSL and can help me?
This is what my OSL code is for color correct:
shader
colorCorrect
(
float modifier = 1[[float min = 0, float max = 72]],
color bob = 0,
output color result = 0
)
{
color temp = transformc("rgb", "hsv", bob);
temp[0] = temp[0] * modifier;
result = transformc("hsv", "rgb", temp);
}
This is what my OSL code is for facing ratio:
shader
Velvet(
float rim_width = 0.2
[[
string label = "Rim Width",
]],
color basecolor = color(1,1,1)
[[
string label = "Base Color",
string widget = "checkBox",
]],
color rimcolor = color(1,0,0)
[[
string label = "Rim Color",
]],
output color resultRGB = 0,
output float resultF = 0)
{
vector i = normalize(I);
vector n = normalize(N);
float d = fabs(dot(-i, n));
d = smoothstep(rim_width, 1.0, d);
getattribute("base_color", resultRGB = mix(rimcolor, basecolor, d));
getattribute("rim_width", resultF = d - 0.5);
}
Please tell me so as to what should i do to solve this problem or what values should i put to solve this problem
while(True):
ret,img = source.read()
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces=face_clsfr.detectMultiScale(gray,1.3,5)
for x,y,w,h in faces:
face_img = gray[y:y+w,x:x+w]
resized = cv2.resize(face_img,(100,100))
normalized=resized/255,0
reshaped = np.reshape(normalized, (1,100,100,1))
result=model.predict(reshaped)
label=np.argmax(result,axis=1)[0]
cv2.rectangle(img,(x,y),(x+w,y+h), colordict[label],2)
cv2.rectangle(img,(x,y-40),(x+w,y), colordict[label],-1)
cv2.putText(img,labels_dict[label], (x,y-10), cv2.FONT_HERSHEY_SIMPLEX,0.8,(255,255,255),2)
cv2.imshow('Frame',img)
key=cv2.waitKey(1)
if(key=='q'):
break
cv2.destroyAllWindows()
source.release
You change the array type of image to a tuple in:
normalized = resized/255,0
change to:
normalized = resized/255
Example :
1.When i using program start int x = 5;
2.Do something until x = 10
3.Closing program
4.When a relaunch program x will be equal to 10 (not 5)
Here the Application Setting will come into play.
Proiperties -> Settings
This will strore our data as XMl formatted.
Action can be applied through both programmatically and manually.
Programmatically:
Create:
SettingsProperty property = new SettingsProperty(nameofthesetting);
property.DefaultValue = "Default";
property.IsReadOnly = false;
property.PropertyType = typeof(bool);
property.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
property.Attributes.Add(typeof(UserScopedSettingAttribute), new UserScopedSettingAttribute());
Properties.Settings.Default.Properties.Add(property);
Properties.Settings.Default.Reload();
property.DefaultValue = HereYourValue;
Update :
Settings.Default.YourSettingsName=NewValue
Settings.Default.Save();
Settings.Default.Reload();
reference,
How do I get around application scope settings being read-only?
How to update appSettings in a WPF app?
I'm trying to create a script that will automatically format a selection based on the formatting of a table in another sheet. The idea is that a user can define a table style for header, rowOdd and rowEven in the Formats sheet, then easily apply it to a selected table using the script.
I've managed to get it working, but only by applying one type of formatting (background colour).
I based my code for reading the code into an array on this article.
As you will hopefully see from my code below, I am only able to read one formatting property into my array.
What I would like to do is read all formatting properties into the array, then apply them to the range in one go. I'm new to this so sorry if my code is a mess!
function formatTable() {
var activeRange = SpreadsheetApp.getActiveSpreadsheet().getActiveRange(); //range to apply formatting to
var arr = new Array(activeRange.getNumRows());
var tableStyleSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Formats"); //location of source styles
var tableColours = {
header: tableStyleSheet.getRange(1, 1, 1).getBackground(),
rowEven: tableStyleSheet.getRange(2, 1, 1).getBackground(),
rowOdd: tableStyleSheet.getRange(3, 1, 1).getBackground()
}
for (var x = 0; x < activeRange.getNumRows(); x++) {
arr[x] = new Array(activeRange.getNumColumns());
for (var y = 0; y < activeRange.getNumColumns(); y++) {
x == 0 ? arr[x][y] = tableColours.header :
x % 2 < 1 ? arr[x][y] = tableColours.rowOdd : arr[x][y] = tableColours.rowEven;
Logger.log(arr);
}
}
activeRange.setBackgrounds(arr);
}
Thanks!
I might be wrong but based from the list of methods given in Class Range, feature to save or store formatting details currently do not exist yet.
However, you may want to try using the following:
copyFormatToRange(gridId, column, columnEnd, row, rowEnd) or copyFormatToRange(sheet, column, columnEnd, row, rowEnd) wherein it copies the formatting of the range to the given location.
moveTo(target) wherein it cuts and paste (both format and values) from this range to the target range.
Did you know that you can get all of the different formatting elements for a range straight into an array?
E.g.
var backgrounds = sheet.getRange("A1:D50").getBackgrounds();
var fonts = sheet.getRange("A1:D50").getFontFamilies();
var fontcolors = sheet.getRange("A1:D50").getFontColors();
etc.
However, there's no way to get all of the formatting in one call unfortunately, so you have to handle each element separately. Then you can apply all of the formats in one go:
targetRng.setFontColors(fontcolors);
targetRng.setBackgrounds(backgrounds);
and so on.
I'm trying to write a basic function that takes the values of 5 textboxes. I want to double the value of the first 2 Boxes to replace their former values with them and save the other 3 inside of an array. Then I want a for-loop to take the values inside of the array and get their sum in a new variable, which I want to display in a seperate TextBox.
Sorry for asking such an odd question but at the job I've just started it's tradition for apprentices to solves a bunch of these problems in FoxPro.
You could paste the following code into a new PRG, e.g. by typing Modify Command into the Command Window, and then paste it there.
LOCAL oForm as Form
oForm = CREATEOBJECT("TestForm")
oForm.Show(1)
RETURN
DEFINE CLASS TestForm as Form
AutoCenter = .T.
ADD OBJECT TextBox1 as TextBox WITH Left = 20, Top = 20, Value = 1
ADD OBJECT TextBox2 as TextBox WITH Left = 20, Top = 50, Value = 2
ADD OBJECT TextBox3 as TextBox WITH Left = 20, Top = 80, Value = 3
ADD OBJECT TextBox4 as TextBox WITH Left = 20, Top = 110, Value = 4
ADD OBJECT TextBox5 as TextBox WITH Left = 20, Top = 140, Value = 5
ADD OBJECT theOtherTextBox as TextBox WITH Left = 200, Top = 20
ADD OBJECT cmdTest as CommandButton WITH Left = 200, Top = 80
PROCEDURE cmdTest.Click
Thisform.TextBox1.Value = Thisform.TextBox1.Value * 2
Thisform.TextBox2.Value = Thisform.TextBox2.Value * 2
LOCAL ARRAY laTest[3]
STORE Thisform.TextBox3.Value TO laTest[1]
STORE Thisform.TextBox4.Value TO laTest[2]
STORE Thisform.TextBox5.Value TO laTest[3]
LOCAL lnSum, lnValue
lnSum = 0
FOR lnValue = 1 TO ALEN(laTest)
lnSum = m.lnSum + laTest[m.lnValue]
ENDFOR && or alternatively
lnSum = 0
FOR EACH lnValue IN laTest
lnSum = m.lnSum + m.lnValue
ENDFOR
Thisform.theOtherTextBox.Value = m.lnSum
ENDPROC
ENDDEFINE
FWIW, the code-as-text presentation is just for the browser demo - in a real VFP project, you'd probably rather design "visual" things in the visual Form or Class designers, good luck John Doe