|
Revision 119, 0.8 kB
(checked in by DRK, 6 years ago)
|
* Added bindings for the Glitz and Xlib backends.
* Checked in cairooo: an OO layer on top of the cairo binding.
* Added snippets directory for cairooo
* Added basic tutorial on how to use cairooo
* Added a simple demo program.
* Added scripts for building import libraries.
* Fixed several bugs.
* Drank WAAY too much coffee.
|
| Line | |
|---|
| 1 |
module snippets.imagepattern; |
|---|
| 2 |
|
|---|
| 3 |
private |
|---|
| 4 |
{ |
|---|
| 5 |
import std.math; |
|---|
| 6 |
import cairooo.all; |
|---|
| 7 |
import cairooo.png.all; |
|---|
| 8 |
import snippets.common; |
|---|
| 9 |
} |
|---|
| 10 |
|
|---|
| 11 |
void snippet_imagepattern(Context cr, int width, int height) |
|---|
| 12 |
{ |
|---|
| 13 |
auto PNGSurface image = new PNGSurface("data/romedalen.png"); |
|---|
| 14 |
int w = image.width; |
|---|
| 15 |
int h = image.height; |
|---|
| 16 |
|
|---|
| 17 |
auto SurfacePattern pattern = SurfacePattern.create(image); |
|---|
| 18 |
pattern.extend = Extend.Repeat; |
|---|
| 19 |
pattern.matrix = Matrix.initScale(w*5, h*5); |
|---|
| 20 |
|
|---|
| 21 |
cr.translate(0.5, 0.5); |
|---|
| 22 |
cr.rotate(PI/4); |
|---|
| 23 |
cr.scale(1/sqrt(2.), 1/sqrt(2.)); |
|---|
| 24 |
cr.translate(-0.5, -0.5); |
|---|
| 25 |
|
|---|
| 26 |
cr.setSource(pattern); |
|---|
| 27 |
|
|---|
| 28 |
cr.rectangle(0, 0, 1.0, 1.0); |
|---|
| 29 |
cr.fill(); |
|---|
| 30 |
} |
|---|
| 31 |
|
|---|
| 32 |
static this() |
|---|
| 33 |
{ |
|---|
| 34 |
snippets_hash["imagepattern"] = &snippet_imagepattern; |
|---|
| 35 |
} |
|---|