Created
November 25, 2016 21:37
-
-
Save Zamlox/5d78d5a7b6a47acf0b8d30c2ee44bc82 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C++ CODE | |
========================================= | |
VOID Example_SetInterpColors(HDC hdc) | |
{ | |
Graphics graphics(hdc); | |
GraphicsPath path; | |
path.AddEllipse(100, -100, 600, 600); | |
PathGradientBrush pthGrBrush(&path); | |
Color col[] = { | |
Color(255, 0, 255, 0), // green | |
Color(255, 0, 0, 255), // blue | |
Color(255, 255, 0, 0), // red | |
Color(255, 255, 0, 0) // red | |
}; | |
REAL pos[] = { | |
0.0f, // green at the boundary | |
0.2f, // blue 80 percent of the way from the boundary to the center | |
0.9f, // red at the center | |
1.0f}; // red at the center | |
pthGrBrush.SetInterpolationColors(col, pos, 4); | |
SolidBrush brush(Color(255, 0, 255, 0)); | |
graphics.FillRectangle(&brush, 100, 100, 600, 200); | |
graphics.FillRectangle(&pthGrBrush, 100, 100, 600, 200); | |
} | |
========================================= | |
RED CODE (with fix) | |
========================================= | |
view [base 800x500 draw [fill-pen green box 100x100 700x300 fill-pen radial 400x200 0 300 red 0.1 blue 0.8 green 1.0 box 100x100 700x300 ] ] | |
========================================= | |
SVG | |
========================================= | |
<?xml version="1.0" standalone="no"?> | |
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" | |
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> | |
<svg width="800" height="400" version="1.1" | |
xmlns="http://www.w3.org/2000/svg"> | |
<desc>Example radgrad01 - fill a rectangle by referencing a | |
radial gradient paint server</desc> | |
<g> | |
<defs> | |
<radialGradient id="MyGradient" gradientUnits="userSpaceOnUse" | |
cx="400" cy="200" r="300" fx="400" fy="200"> | |
<stop offset="10%" stop-color="red" /> | |
<stop offset="80%" stop-color="blue" /> | |
<stop offset="100%" stop-color="lime" /> | |
</radialGradient> | |
</defs> | |
<!-- Outline the drawing area in blue --> | |
<rect fill="none" stroke="blue" | |
x="1" y="1" width="798" height="398"/> | |
<!-- The rectangle is filled using a radial gradient paint server --> | |
<rect fill="url(#MyGradient)" stroke="black" stroke-width="5" | |
x="100" y="100" width="600" height="200"/> | |
</g> | |
</svg> | |
========================================= | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment