summaryrefslogtreecommitdiff
path: root/nanosvg/altsvgrast.diff
blob: 83cdc6d06a638192512b39860db9097677bde3a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
1,6d0
< //
< // "$Id$"
< //
< 
< /* Modified by FLTK from original sources to support non-square X,Y axes scaling */
< 
31d24
< 
51,53d43
< 
< 	// For non-square X,Y scaling, use
< 	nsvgAltRasterize(rast, image, 0,0,1,1, img, w, h, w*4);
63c53
< //   scale - image scale (assumes square aspect ratio)
---
> //   scale - image scale
72,77d61
< // As above, but allow X and Y axes to scale independently for non-square aspects
< void nsvgAltRasterize(NSVGrasterizer* r,
< 				   NSVGimage* image, float tx, float ty,
< 				   float sx, float sy,
< 				   unsigned char* dst, int w, int h, int stride);
< 
382c366
< static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
---
> static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
390c374
< 		nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
---
> 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
393c377
< 			nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, 0);
---
> 			nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
396c380
< 		nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, 0);
---
> 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
746c730
< static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float sx, float sy)
---
> static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
754,755c738
< 	const float sw = (sx + sy) / 2; // average scaling factor
< 	const float lineWidth = shape->strokeWidth * sw; // FIXME (?)
---
> 	float lineWidth = shape->strokeWidth * scale;
760c743
< 		nsvg__addPathPoint(r, path->pts[0]*sx, path->pts[1]*sy, NSVG_PT_CORNER);
---
> 		nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
763c746
< 			nsvg__flattenCubicBez(r, p[0]*sx,p[1]*sy, p[2]*sx,p[3]*sy, p[4]*sx,p[5]*sy, p[6]*sx,p[7]*sy, 0, NSVG_PT_CORNER);
---
> 			nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
809c792
< 			dashLen = (shape->strokeDashArray[idash] - dashOffset) * sw;
---
> 			dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
831c814
< 					dashLen = shape->strokeDashArray[idash] * sw;
---
> 					dashLen = shape->strokeDashArray[idash] * scale;
1000c983
< 								float tx, float ty, float sx, float sy, NSVGcachedPaint* cache)
---
> 								float tx, float ty, float scale, NSVGcachedPaint* cache)
1041,1043c1024,1026
< 		fx = ((float)x - tx) / sx;
< 		fy = ((float)y - ty) / sy;
< 		dx = 1.0f / sx;
---
> 		fx = ((float)x - tx) / scale;
> 		fy = ((float)y - ty) / scale;
> 		dx = 1.0f / scale;
1086,1088c1069,1071
< 		fx = ((float)x - tx) / sx;
< 		fy = ((float)y - ty) / sy;
< 		dx = 1.0f / sx;
---
> 		fx = ((float)x - tx) / scale;
> 		fy = ((float)y - ty) / scale;
> 		dx = 1.0f / scale;
1127c1110
< static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float sx, float sy, NSVGcachedPaint* cache, char fillRule)
---
> static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
1209c1192
< 			nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, sx, sy, cache);
---
> 			nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
1377,1379c1360,1361
< void nsvgAltRasterize(NSVGrasterizer* r,
< 				   NSVGimage* image, float tx, float ty,
< 				   float sx, float sy,
---
> void nsvgRasterize(NSVGrasterizer* r,
> 				   NSVGimage* image, float tx, float ty, float scale,
1410c1392
< 			nsvg__flattenShape(r, shape, sx, sy);
---
> 			nsvg__flattenShape(r, shape, scale);
1427c1409
< 			nsvg__rasterizeSortedEdges(r, tx,ty, sx, sy, &cache, shape->fillRule);
---
> 			nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
1429c1411
< 		if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * sx) > 0.01f) {
---
> 		if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
1434c1416
< 			nsvg__flattenShapeStroke(r, shape, sx, sy);
---
> 			nsvg__flattenShapeStroke(r, shape, scale);
1453c1435
< 			nsvg__rasterizeSortedEdges(r, tx,ty,sx, sy, &cache, NSVG_FILLRULE_NONZERO);
---
> 			nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
1465,1477c1447
< void nsvgRasterize(NSVGrasterizer* r,
< 				   NSVGimage* image, float tx, float ty, float scale,
< 				   unsigned char* dst, int w, int h, int stride)
< {
< 	nsvgAltRasterize(r,image, tx, ty, scale, scale, dst, w, h, stride);
< }
< 
< #endif // NANOSVGRAST_IMPLEMENTATION
< 
< 
< //
< // End of "$Id$".
< //
---
> #endif