Setting (intern) variable for color - colors

I'm trying to create a variable so I can use it across my app. I've put the "code" in OnVisible in my first screen with the following code:
Set(LayoutSettings, {
colorHR : RGBA(55, 207, 177, 1)
})
To test it, I simply used a rectangle and in Fill I use have:
LayoutSettings.colorHR
So basically I have:
HomeScreen.OnVisible = Set(LayoutSettings, {colorHR : RGBA(55, 207, 177, 1)})
Rectangle.Fill = LayoutSettings.colorHR
But somehow my rectangle is still black. What am I doing wrong?

Related

How to change shape color in excel using powershell

I need to automatically import a picture into excel and add a red circle. I am just starting to get the create a shape part but I cannot seem to figure out how to modify it. I have:
$WS = $workbook.worksheets.add()
$WS.select()
$ws.Activate()
$ws.Shapes.AddShape(9, 0, 0, 50, 50)
$circle = $ws.Shapes.AddShape(18, 50, 50, 50, 50)
#$Circle = $ws.Shapes[2]
write-host "fill: " $circle.fill
This adds an oval and a donut, but just outputs "system comobject" and I can't seem to access any of the methods that should be there (like fill/fillform.forecolor). What is the correct way to play with and modify the shape?
I can't test at the moment but try $circle.ShapeRange.Fill.ForeColor.RGB = RGB(255,0,0). Change the RGB values to your preference.

How to get the proper position of a SVG element using Snap SVG - getBBox()

We're trying to get the position of a svg element using getbbox().
For example, we have an elementLogo at x y = 484, 247.
When I use this:
var logoSnapNew = Snap(elementLogo); var cBoxLogoNew = logoSnapNew.getBBox();
it returns 247, 117 instead and the elementLogo is placed a different location. Appreciate any suggestions.

Best place to call a method to adjust layout in iOS

I am having a problem modifying my layout when switching from portrait to landscape. The layouts are as shown below. As you can see, the switch requires repositioning the two inner panels (light grey) relative to one another. The view controller is embedded in a navigation controller and the panels contain buttons which fire segues to further view controllers.
All the resizing is nicely taken care of by AutoLayout, but the repositioning requires using CGRect. On screen rotation is dealt with by
- (void) willAnimateRotationToInterfaceOrientation: (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) {
self.topImagePanel.frame = CGRectMake(44, 16, 196, 392);
self.bottomImagePanel.frame = CGRectMake(44, 407, 196, 392);
} else {
self.topImagePanel.frame = CGRectMake(72, 64, 196, 392);
self.bottomImagePanel.frame = CGRectMake(268, 64, 196, 392);
}
}
And the following method deals with startup and navigating back to the home screen.
- (void) adjustLayoutToOrientation
{
UIInterfaceOrientation deviceOrientation = [[UIApplication sharedApplication] statusBarOrientation];
if (UIDeviceOrientationIsLandscape(deviceOrientation)){
self.topImagePanel.frame = CGRectMake(72, 64, 196, 392);
self.bottomImagePanel.frame = CGRectMake(268, 64, 196, 392);
} else if (UIDeviceOrientationIsPortrait(deviceOrientation)) {
self.topImagePanel.frame = CGRectMake(44, 16, 196, 392);
self.bottomImagePanel.frame = CGRectMake(44, 407, 196, 392);
}
}
The most effective place to call this method from seems to be viewDidAppear. The problem is that whenever the view appears in landscape mode. It appears first as laid out in the storyboard (i.e. in portrait mode) for a brief interval before being replaced by the correct layout.
I have tried calling from viewWillAppear but although the method is called, the landscape layout simply never appears.I have also tried calling from viewDidLayoutSubviews. The landscape layout appears (when navigating back although not on start up) but with the same glitch as described above. One more thing I have tried is using different view controllers for the different layouts but it really seems to be overkill and causes more problems than it solves. Help appreciated.

JFreeChart Bar Charts - Draw plot without gradient fill

My Bar chart is always drawn with a gradient fill. I have a code to fill each bar in a series with a different color. I just want the colors without any effect. I looked at a previous thread but that did not help since it seems to be designed for a default standard code.
Here is my code:
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.WHITE);
CategoryItemRenderer renderer = new MyRenderer();
plot.setRenderer(renderer);
class MyRenderer extends BarRenderer
{
private Paint[] barColors;
public MyRenderer()
{
this.barColors = new Paint[] { new Color( 21, 104, 156), new Color( 25, 149, 104), new Color( 237, 179,20),
new Color( 72, 181, 163) };
}
public Paint getItemPaint(final int row, final int column)
{
// returns color for each column
return (this.barColors[column % this.barColors.length]);
}
}
Any help will be appreciated.
Thanks.
In the BarRenderer class you will find this method:
public static void setDefaultBarPainter(BarPainter painter);
It allows you to change the default bar painter (pass a StandardBarPainter to this method before creating any charts and your charts will have bars without the gradient).

Change backcolor of shape

I'm trying to update the backcolor of all of the labels that I have on a worksheet. I'd like to indicate the color using the RGB values, but I'm stuck in two places. Here is the code that I have right now:
Sheet2.Shapes("Label 2").Fill.BackColor.RGB = RGB(220, 105, 0)
This code will run without error, but it seems to have no effect. My label starts out white (or maybe transparent) and never changes. Can anyone tell me what I need to do to make this work? I also added this but it did nothing:
shp.Fill.Solid
Next, I'd like to capture this RGB value in a variable so that I don't have to re-type of repeatedly. Essentially, I'm looking for something like this:
dim col as Color
col = RGB(220,105,0)
Sheet2.Shapes("Label 2").Fill.BackColor.RGB = col
I know that there is no variable type called Color, but I think you can see what I am trying to do.
Try setting the ForeColor instead:
Sheet2.Shapes("Label 2").Fill.ForeColor.RGB = RGB(220, 105, 0)
A good way to figure out what to do is to record a macro while you make the adjustment yourself. You can examine the generated code afterward and use it as a starting point.
Here is an example of a procedure that will add a rectangle to the activesheet, add some text to it, and then color it with your RGB values:
Public Sub AddRectangleWithText()
Dim textRectangle As Shape
Set textRectangle = ActiveSheet.Shapes & _
.AddShape(msoShapeRectangle, 10, 80, 250, 50)
' add your text
textRectangle.TextFrame.Characters.Text = "Your mother was a hamster."
' fill the shape with the rgb color of your choice
textRectangle.Fill.ForeColor.RGB = RGB(220, 105, 0)
End Sub
ForeColor actually controls the backcolor of comment/textbox(s) in Excel as follows;
Activecell.Comment.Shape.Fill.ForeColor.RGB = RGB(240, 255, 250)
'Mint Green
as the Comment/TextBox ForeColor is a foreground fill over the Applicatoin background color.
I needed to add
textRectangle.Fill.Visible = msoTrue
in Office 2016 for
textRectangle.Fill.ForeColor.RGB = RGB(220, 105, 0)
to have an effect.

Resources