mirror of
https://github.com/googlefonts/noto-emoji.git
synced 2025-06-08 07:47:59 +00:00
Merge pull request #88 from dougfelt/waveflag_update
Update waveflag.c from upstream.
This commit is contained in:
commit
312ceac1f7
1 changed files with 21 additions and 24 deletions
39
waveflag.c
39
waveflag.c
|
@ -17,7 +17,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <libgen.h> // basename
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -34,17 +33,18 @@ static unsigned int debug;
|
||||||
#define std_aspect (5./3.)
|
#define std_aspect (5./3.)
|
||||||
#define top 21
|
#define top 21
|
||||||
#define bot 128-top
|
#define bot 128-top
|
||||||
#define B 27
|
#define B 21
|
||||||
|
#define C 4
|
||||||
static struct { double x, y; } mesh_points[] =
|
static struct { double x, y; } mesh_points[] =
|
||||||
{
|
{
|
||||||
{ 1, top},
|
{ 1, top+C},
|
||||||
{ 43, top-B},
|
{ 43, top-B+C},
|
||||||
{ 85, top+B},
|
{ 85, top+B-C},
|
||||||
{127, top},
|
{127, top-C},
|
||||||
{127, bot},
|
{127, bot-C},
|
||||||
{ 85, bot+B},
|
{ 85, bot+B-C},
|
||||||
{ 43, bot-B},
|
{ 43, bot-B+C},
|
||||||
{ 1, bot},
|
{ 1, bot+C},
|
||||||
};
|
};
|
||||||
#define M(i) \
|
#define M(i) \
|
||||||
x_aspect (mesh_points[i].x, aspect), \
|
x_aspect (mesh_points[i].x, aspect), \
|
||||||
|
@ -138,9 +138,9 @@ static cairo_surface_t *
|
||||||
load_scaled_flag (const char *filename, double *aspect)
|
load_scaled_flag (const char *filename, double *aspect)
|
||||||
{
|
{
|
||||||
cairo_surface_t *flag = cairo_image_surface_create_from_png (filename);
|
cairo_surface_t *flag = cairo_image_surface_create_from_png (filename);
|
||||||
|
cairo_surface_t *scaled = scale_flag (flag);
|
||||||
*aspect = (double) cairo_image_surface_get_width (flag) /
|
*aspect = (double) cairo_image_surface_get_width (flag) /
|
||||||
(double) cairo_image_surface_get_height (flag);
|
(double) cairo_image_surface_get_height (flag);
|
||||||
cairo_surface_t *scaled = scale_flag (flag);
|
|
||||||
cairo_surface_destroy (flag);
|
cairo_surface_destroy (flag);
|
||||||
return scaled;
|
return scaled;
|
||||||
}
|
}
|
||||||
|
@ -342,22 +342,18 @@ wave_flag (const char *filename, const char *out_prefix)
|
||||||
|
|
||||||
// Paint shade gradient
|
// Paint shade gradient
|
||||||
{
|
{
|
||||||
cairo_save (cr);
|
|
||||||
cairo_pattern_t *gradient = wave_mesh_create (aspect, 1);
|
cairo_pattern_t *gradient = wave_mesh_create (aspect, 1);
|
||||||
|
cairo_pattern_t *w = cairo_pattern_create_for_surface (waved_flag);
|
||||||
|
|
||||||
|
cairo_save (cr);
|
||||||
cairo_set_source (cr, gradient);
|
cairo_set_source (cr, gradient);
|
||||||
|
|
||||||
if (border_transparent)
|
|
||||||
{
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_ATOP);
|
|
||||||
cairo_paint_with_alpha (cr, .3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cairo_set_operator (cr, CAIRO_OPERATOR_SOFT_LIGHT);
|
cairo_set_operator (cr, CAIRO_OPERATOR_SOFT_LIGHT);
|
||||||
cairo_paint (cr);
|
cairo_mask (cr, w);
|
||||||
}
|
|
||||||
|
|
||||||
cairo_restore (cr);
|
cairo_restore (cr);
|
||||||
|
|
||||||
|
cairo_pattern_destroy (w);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
|
@ -411,6 +407,7 @@ wave_flag (const char *filename, const char *out_prefix)
|
||||||
|
|
||||||
*out = '\0';
|
*out = '\0';
|
||||||
strcat (out, out_prefix);
|
strcat (out, out_prefix);
|
||||||
|
// diff from upstream. we call this a bit differently, filename might not be in cwd.
|
||||||
strcat (out, basename(filename));
|
strcat (out, basename(filename));
|
||||||
|
|
||||||
cairo_surface_write_to_png (cairo_get_target (cr), out);
|
cairo_surface_write_to_png (cairo_get_target (cr), out);
|
||||||
|
|
Loading…
Add table
Reference in a new issue