Change GDI pen colour - gdi

Is it possible to change the custom pen colour attribute after creating it using this call?
HPEN hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); //Create a solid pen.
or how should i create a pen whose colour colour can be changed.

I am afraid that this is not possible using any non-esoteric approach.
I think, however, that you can use the DC_PEN stock object and the SetDCPenColor function, like so:
SelectObject(dc, GetStockObject(DC_PEN));
SetDCPenColor(dc, clGreen);
Rectangle(dc, 10, 10, 200, 200);
SetDCPenColor(dc, clRed);
Rectangle(dc, 300, 300, 500, 500);
in Delphi syntax.

Related

Change handle color of QSplitter

I am using a QSplitter, but the handle color is not changing, it has always the default color:
m_pSplitMainWin = new QSplitter;
m_pSplitMainWin->setOrientation(Qt::Horizontal);
m_pSplitMainWin->setHandleWidth(10);
m_pSplitMainWin->setStyleSheet("QSplitter::handle:background-color: rgb(55, 100, 110);");
I got some idea from previous post but I am not able to do it with m_pSplitMainWin object
Your CSS syntax is wrong. It should read
QSplitter::handle { background-color: rgb(55, 100, 110); }

How to apply the alphaMaskFilter in Flash CC using Easel.js?

I am working in a canvas document using Flash CC and have the following labeled moveclips on the stage mask_mc (which is a movieclip with a alpha gradient) and logo. The objective is to create a sheen going across the logo.
var mask_mc = this.mask_mc;
mask_mc.cache(0, 0, 232, 196);
var logo = this.logo;
logo.cache(0, 0, 271, 40);
logo.filters = [
new createjs.AlphaMaskFilter(mask_mc.cacheCanvas)
];
All I am trying to do is emulate what an alpha gradient mask used to do using AS3, but can't get it to work with the above code:
//Original AS3 code
mask_mc.cacheAsBitmap = true;
logo.cacheAsBitmap = true;
logo.mask = mask_mc;
Thanks!
You have to cache (or updateCache) after you apply the filter(s)
var logo = this.logo;
logo.filters = [
new createjs.AlphaMaskFilter(mask_mc.cacheCanvas)
];
logo.cache(0, 0, 271, 40);
Your second example will not work because the mask property requires a Shape, and will not work with a canvas/cache.

JavaFX - What is the correct way to give a Shape subclass object like Rectangle no Color

I found out that a way to do this is to simply just pass null to setFill(Color color) but that seems like a hacker solution to me. I am wondering if there is a better/proper way to do this?
CubicCurve cubicCurve = new CubicCurve(
50,
75,
80,
-25,
110,
175,
140,
75);
cubicCurve.setStrokeType(StrokeType.CENTERED);
cubicCurve.setStroke(Color.BLACK);
cubicCurve.setStrokeWidth(3);
cubicCurve.setFill(null); //this is in my opinion a hacker solution
That also brings me to my second question, why is the default fill color white for any shape? Is there an efficiency reason for this? What is the point?
A more elegant way to write it would be to assign the fill as TRANSPARENT for a similar effect.
cubicCurve.setFill(Color.TRANSPARENT);
As far as your other questions are concerned, the default fill is Black and not White. I have no idea about the reason behind it. This is how the JavaFX developers decided it to be.
In the Shape.java :
public final Paint getFill() {
return fill == null ? Color.BLACK : fill.get();
}

When using AlivePDF library in Flex the beginFill method sets font colour rather than background colour

Code sample:
var headerRowBackground:RGBColor = new RGBColor(0);
headerRowBackground.b = 58;
headerRowBackground.g = 28;
headerRowBackground.r = 255;
printPDF.beginFill(headerRowBackground);
printPDF.addCell(30, 20, "Room");
The word "Room" is in red, as is the rest of the text in the PDF. I actually want to make the cell background colour red. Anybody know why this doesn't work?
You should look at the API more:
printPDF.addCell(30, 20, 'Room', 0, 0, '1', 0xFF0000);
The documentation is wrong, the fill parameter is described as "Link can be internal to do document level navigation (InternalLink) or external (HTTPLink)".
The code to get this working is:
printPDF.beginFill(new RGBColor(0xFF0718));
printPDF.textStyle(new RGBColor(0x000000));
printPDF.addCell(30, 10, "Room", 0, 0, Align.LEFT, 1);
A couple of things about the code:
The fill parameter should be 0 or 1
rather than the fill value. It just
either switches on or off the fill
value previously set.
The text style
should be set too otherwise the text
and background will use the same
colour

Visual Studio 2010 Chart control - line color

How do I change the color of the horizonal and vertical lines? I'd like to make them a little lighter, yet leave the X and Y axis black, probably.
Edited:
indyfromoz suggestion resulted in this:
The effect I want is this:
(Subtler horiz and vertical lines, maybe even no vertical lines.)
VB
Chart1.ChartAreas(0).AxisY.MajorGrid.LineColor = Color.FromArgb(&H50, &H9C, &H9A, &H95)
Chart1.ChartAreas(0).AxisX.MajorGrid.LineColor = Color.FromArgb(&H50, &H9C, &H9A, &H95)
C#
Chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);
Chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(50, 200, 200, 200);
You have two options - use the Axis.IsInterlaced property or the Axis.StripLines property. This page is a handy reference for customization of the grid lines in a chart.
Here is some sample C# code (from the above reference) -
chart1.ChartAreas[0].AxisY.StripLines.Add(new StripLine());
chart1.ChartAreas[0].AxisY.StripLines[0].BackColor = Color.FromArgb(80, 252, 180, 65);
chart1.ChartAreas[0].AxisY.StripLines[0].StripWidth = 40;
chart1.ChartAreas[0].AxisY.StripLines[0].Interval = 10000;
chart1.ChartAreas[0].AxisY.StripLines[0].IntervalOffset **
HTH, indyfromoz

Resources