Skip to content

Instantly share code, notes, and snippets.

C++ CODE
=========================================
VOID Example_SetInterpColors(HDC hdc)
{
Graphics graphics(hdc);
GraphicsPath path;
path.AddEllipse(100, -100, 600, 600);
PathGradientBrush pthGrBrush(&path);
@Zamlox
Zamlox / gist:b835c4856058192827e0445f646e2e9d
Last active November 10, 2016 14:18
SVG transformations
Let's take an SVG sample:
```
<?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="10cm" height="10cm" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x=".1" y=".1" width="99.8" height="99.8" fill="none" stroke="blue" stroke-width=".2" />
<!-- Start of generated content. Replaces 'use' -->
<g transform="translate(45, 10) scale(1.5) ">
<rect x="1" y="1" width="8" height="8"/>
<g transform="translate(15, 10) scale(1.5) ">
void draw(SkCanvas* canvas) {
const SkScalar scale = 256.0f;
const SkScalar R = 0.45f * scale;
const SkScalar TAU = 6.2831853f;
SkPath path;
path.moveTo(R, 0.0f);
for (int i = 1; i < 7; ++i) {
SkScalar theta = 3 * i * TAU / 7;
path.lineTo(R * cos(theta), R * sin(theta));
}