本文整理汇总了C++中cairo_matrix_init_scale函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_matrix_init_scale函数的具体用法?C++ cairo_matrix_init_scale怎么用?C++ cairo_matrix_init_scale使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_matrix_init_scale函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: _cairo_type3_glyph_surface_create
cairo_surface_t *
_cairo_type3_glyph_surface_create (cairo_scaled_font_t *scaled_font,
cairo_output_stream_t *stream,
cairo_type3_glyph_surface_emit_image_t emit_image,
cairo_scaled_font_subsets_t *font_subsets)
{
cairo_type3_glyph_surface_t *surface;
cairo_matrix_t invert_y_axis;
surface = malloc (sizeof (cairo_type3_glyph_surface_t));
if (surface == NULL)
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
_cairo_surface_init (&surface->base, &cairo_type3_glyph_surface_backend,
CAIRO_CONTENT_COLOR_ALPHA);
surface->scaled_font = scaled_font;
surface->stream = stream;
surface->emit_image = emit_image;
/* Setup the transform from the user-font device space to Type 3
* font space. The Type 3 font space is defined by the FontMatrix
* entry in the Type 3 dictionary. In the PDF backend this is an
* identity matrix. */
surface->cairo_to_pdf = scaled_font->scale_inverse;
cairo_matrix_init_scale (&invert_y_axis, 1, -1);
cairo_matrix_multiply (&surface->cairo_to_pdf, &surface->cairo_to_pdf, &invert_y_axis);
_cairo_pdf_operators_init (&surface->pdf_operators,
surface->stream,
&surface->cairo_to_pdf,
font_subsets);
return &surface->base;
}
开发者ID:jwmcglynn,项目名称:Gadgets,代码行数:35,代码来源:cairo-type3-glyph-surface.c
示例2: cairo_matrix_init_scale
cairo_surface_t* Win32UIBinding::ScaleCairoSurface(
cairo_surface_t* oldSurface, int newWidth, int newHeight)
{
cairo_matrix_t scaleMatrix;
cairo_matrix_init_scale(&scaleMatrix,
(double) cairo_image_surface_get_width(oldSurface) / (double) newWidth,
(double) cairo_image_surface_get_height(oldSurface) / (double) newHeight);
cairo_pattern_t* surfacePattern = cairo_pattern_create_for_surface(oldSurface);
cairo_pattern_set_matrix(surfacePattern, &scaleMatrix);
cairo_pattern_set_filter(surfacePattern, CAIRO_FILTER_BEST);
cairo_surface_t* newSurface = cairo_surface_create_similar(
oldSurface, CAIRO_CONTENT_COLOR_ALPHA, newWidth, newHeight);
cairo_t* cr = cairo_create(newSurface);
cairo_set_source(cr, surfacePattern);
/* To avoid getting the edge pixels blended with 0 alpha, which would
* occur with the default EXTEND_NONE. Use EXTEND_PAD for 1.2 or newer (2) */
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REFLECT);
/* Replace the destination with the source instead of overlaying */
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
/* Do the actual drawing */
cairo_paint(cr);
cairo_destroy(cr);
return newSurface;
}
开发者ID:JamesHayton,项目名称:titanium_desktop,代码行数:30,代码来源:win32_ui_binding.cpp
示例3: redraw_command
static void
redraw_command(I7Node *self, double width, double height)
{
I7_NODE_USE_PRIVATE;
cairo_matrix_t matrix;
char *path;
/* Calculate the scale for the pattern gradients */
cairo_matrix_init_scale(&matrix, 0.5 / width, 1.0 / height);
cairo_pattern_set_matrix(priv->node_pattern[NODE_UNPLAYED_UNBLESSED], &matrix);
cairo_pattern_set_matrix(priv->node_pattern[NODE_UNPLAYED_BLESSED], &matrix);
cairo_pattern_set_matrix(priv->node_pattern[NODE_PLAYED_UNBLESSED], &matrix);
cairo_pattern_set_matrix(priv->node_pattern[NODE_PLAYED_BLESSED], &matrix);
/* Draw the text background */
path = g_strdup_printf(
"M %.1f -%.1f " /* Move-to (w/2, -h/2) */
"a %.1f,%.1f 0 0,1 0,%.1f " /* Arc r=(h/2, h/2) rot=0 large=0 dir=1 rel-to (0, h) */
"h -%.1f " /* Horizontal-line-rel-to (-w) */
"a %.1f,%.1f 0 0,1 0,-%.1f " /* Arc r=(h/2, h/2) rot=0 large=0 dir=1 rel-to (0, -h) */
"Z", /* Close-path */
width / 2, height / 2,
height / 2, height / 2, height,
width,
height / 2, height / 2, height);
g_object_set(priv->command_shape_item, "data", path, NULL);
g_free(path);
priv->command_width = width;
priv->command_height = height;
}
开发者ID:sffej,项目名称:gnome-inform7,代码行数:31,代码来源:node.c
示例4: m_font
FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
: m_font(0)
, m_size(size)
, m_fontFace(fontFace)
, m_scaledFont(0)
, m_syntheticBold(bold)
, m_syntheticOblique(oblique)
, m_useGDI(false)
{
cairo_matrix_t fontMatrix;
cairo_matrix_init_scale(&fontMatrix, size, size);
cairo_matrix_t ctm;
cairo_matrix_init_identity(&ctm);
cairo_font_options_t* options = cairo_font_options_create();
// We force antialiasing and disable hinting to provide consistent
// typographic qualities for custom fonts on all platforms.
#if PLATFORM(APOLLO)
// In Apollo use the anti-aliasing mode selected by the user. See bug 2404418.
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_DEFAULT);
#else
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
#endif
m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
cairo_font_options_destroy(options);
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:28,代码来源:FontPlatformDataCairoWin.cpp
示例5: m_font
FontPlatformData::FontPlatformData(cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
: m_font(0)
, m_size(size)
, m_orientation(Horizontal)
, m_textOrientation(TextOrientationVerticalRight)
, m_widthVariant(RegularWidth)
, m_scaledFont(0)
, m_isColorBitmapFont(false)
, m_syntheticBold(bold)
, m_syntheticOblique(oblique)
, m_useGDI(false)
{
cairo_matrix_t fontMatrix;
cairo_matrix_init_scale(&fontMatrix, size, size);
cairo_matrix_t ctm;
cairo_matrix_init_identity(&ctm);
cairo_font_options_t* options = cairo_font_options_create();
// We force antialiasing and disable hinting to provide consistent
// typographic qualities for custom fonts on all platforms.
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options);
cairo_font_options_destroy(options);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:26,代码来源:FontPlatformDataCairoWin.cpp
示例6: redraw_label
static void
redraw_label(I7Node *self, double width, double height)
{
I7_NODE_USE_PRIVATE;
cairo_matrix_t matrix;
char *path;
/* Calculate the scale for the pattern gradient */
cairo_matrix_init_scale(&matrix, 0.5 / width, -1.0 / height);
cairo_pattern_set_matrix(priv->label_pattern, &matrix);
path = g_strdup_printf(
"M %.1f,%.1f " /* Move-to (w/2+h, h/2) */
"a %.1f,%.1f 0 0,0 -%.1f,-%.1f " /* Arc r=(h, h) rot=0 large=0 dir=0 rel-to (-h, -h) */
"h -%.1f " /* Horizontal-line-rel-to (-w) */
"a %.1f,%.1f 0 0,0 -%.1f,%.1f " /* Arc r=(h, h) rot=0 large=0 dir=0 rel-to (-h, h) */
"Z",
width / 2 + height, height / 2,
height, height, height, height,
width,
height, height, height, height);
g_object_set(priv->label_shape_item,
"data", path,
"visibility", GOO_CANVAS_ITEM_VISIBLE,
NULL);
g_free(path);
priv->label_width = width;
priv->label_height = height;
}
开发者ID:sffej,项目名称:gnome-inform7,代码行数:30,代码来源:node.c
示例7: m_font
FontPlatformData::FontPlatformData(GDIObject<HFONT> font, cairo_font_face_t* fontFace, float size, bool bold, bool oblique)
: m_font(SharedGDIObject<HFONT>::create(WTFMove(font)))
, m_size(size)
, m_syntheticOblique(oblique)
{
cairo_matrix_t fontMatrix;
cairo_matrix_init_scale(&fontMatrix, size, size);
cairo_matrix_t ctm;
cairo_matrix_init_identity(&ctm);
cairo_font_options_t* options = cairo_font_options_create();
// We force antialiasing and disable hinting to provide consistent
// typographic qualities for custom fonts on all platforms.
cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_BEST);
if (syntheticOblique()) {
static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
cairo_matrix_multiply(&fontMatrix, &skew, &fontMatrix);
}
m_scaledFont = adoptRef(cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options));
cairo_font_options_destroy(options);
}
开发者ID:eocanha,项目名称:webkit,代码行数:25,代码来源:FontPlatformDataCairoWin.cpp
示例8: font_fc
explicit font_fc(cairo_t* cairo, FcPattern* pattern, double offset, double dpi_x, double dpi_y) : font(cairo, offset), m_pattern(pattern) {
cairo_matrix_t fm;
cairo_matrix_t ctm;
cairo_matrix_init_scale(&fm, size(dpi_x), size(dpi_y));
cairo_get_matrix(m_cairo, &ctm);
auto fontface = cairo_ft_font_face_create_for_pattern(m_pattern);
auto opts = cairo_font_options_create();
m_scaled = cairo_scaled_font_create(fontface, &fm, &ctm, opts);
cairo_font_options_destroy(opts);
cairo_font_face_destroy(fontface);
auto status = cairo_scaled_font_status(m_scaled);
if (status != CAIRO_STATUS_SUCCESS) {
throw application_error(sstream() << "cairo_scaled_font_create(): " << cairo_status_to_string(status));
}
auto lock = make_unique<utils::ft_face_lock>(m_scaled);
auto face = static_cast<FT_Face>(*lock);
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) == FT_Err_Ok) {
return;
} else if (FT_Select_Charmap(face, FT_ENCODING_BIG5) == FT_Err_Ok) {
return;
} else if (FT_Select_Charmap(face, FT_ENCODING_SJIS) == FT_Err_Ok) {
return;
}
lock.reset();
}
开发者ID:JBouron,项目名称:polybar,代码行数:30,代码来源:font.hpp
示例9: gnm_soi_draw_cairo
static void
gnm_soi_draw_cairo (SheetObject const *so, cairo_t *cr,
double width, double height)
{
GdkPixbuf *pixbuf;
GOImage *img;
cairo_pattern_t *cr_pattern;
int w, h;
cairo_matrix_t cr_matrix;
pixbuf = soi_get_pixbuf (SHEET_OBJECT_IMAGE (so), 1.);
if (!pixbuf || width == 0. || height == 0.)
return;
cairo_save (cr);
img = go_image_new_from_pixbuf (pixbuf);
cr_pattern = go_image_create_cairo_pattern (img);
w = gdk_pixbuf_get_width (pixbuf);
h = gdk_pixbuf_get_height (pixbuf);
cairo_matrix_init_scale (&cr_matrix,
w / width,
h / height);
cairo_pattern_set_matrix (cr_pattern, &cr_matrix);
cairo_rectangle (cr, 0., 0., width, height);
cairo_set_source (cr, cr_pattern);
cairo_fill (cr);
/*
* We need to unset the source before we destroy the pattern.
* cairo_restore will do that. See #632439.
*/
cairo_restore (cr);
cairo_pattern_destroy (cr_pattern);
g_object_unref (img);
g_object_unref (pixbuf);
}
开发者ID:arcean,项目名称:gnumeric-for-maemo-5,代码行数:35,代码来源:sheet-object-image.c
示例10: locker
void wxGISDisplay::DrawRaster(cairo_surface_t *surface, const OGREnvelope& Envelope, bool bDrawEnvelope)
{
wxCriticalSectionLocker locker(m_CritSect);
cairo_pattern_t *pattern = cairo_pattern_create_for_surface (surface);
cairo_matrix_t matrix;
cairo_matrix_init_scale (&matrix, m_dScale, -m_dScale);
cairo_matrix_translate(&matrix, -Envelope.MinX, -Envelope.MaxY);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (m_saLayerCaches[m_nCurrentLayer].pCairoContext, pattern);
cairo_paint (m_saLayerCaches[m_nCurrentLayer].pCairoContext);
if(bDrawEnvelope)
{
//TODO:
//SetLineWidth( m_dLineWidth );
//SetColor(m_FillColour);
cairo_move_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MinY);
cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MaxX, Envelope.MinY);
cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MaxX, Envelope.MaxY);
cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MaxY);
cairo_line_to(m_saLayerCaches[m_nCurrentLayer].pCairoContext, Envelope.MinX, Envelope.MinY);
cairo_stroke (m_saLayerCaches[m_nCurrentLayer].pCairoContext);
}
cairo_pattern_destroy (pattern);
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:28,代码来源:gisdisplay.cpp
示例11: cairo_pattern_set_extend
bool GlyphLayerBitmap::render(
cairo_t* c,
cairo_glyph_t* glyph,
unsigned int width,
unsigned int height
) {
if(cairo_status(c) || !glyph || !_bitmap || cairo_pattern_status(_pattern)) return false;
double bw = _bitmap->getSurfaceWidth();
double bh = _bitmap->getSurfaceHeight();
if(_repeatX > 1 || _repeatY > 1) cairo_pattern_set_extend(_pattern, CAIRO_EXTEND_REPEAT);
else cairo_pattern_set_extend(_pattern, CAIRO_EXTEND_PAD);
cairo_matrix_t matrix;
cairo_matrix_init_scale(&matrix, bw / width * _repeatX, bh / height * _repeatY);
cairo_pattern_set_matrix(_pattern, &matrix);
cairo_set_source(c, _pattern);
cairo_glyph_path(c, glyph, 1);
cairo_fill(c);
return true;
}
开发者ID:cubicool,项目名称:osgpango,代码行数:27,代码来源:Bitmap.cpp
示例12: draw_from_gradient
static cairo_surface_t *
draw_from_gradient (cairo_pattern_t *pattern)
{
cairo_surface_t *surface;
cairo_matrix_t matrix;
cairo_t *cr;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
DEFAULT_SURFACE_SIZE, DEFAULT_SURFACE_SIZE);
cr = cairo_create (surface);
/* scale the gradient points to the user space coordinates */
cairo_matrix_init_scale (&matrix,
1. / (double) DEFAULT_SURFACE_SIZE,
1. / (double) DEFAULT_SURFACE_SIZE);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_arc (cr, DEFAULT_SURFACE_SIZE / 2., DEFAULT_SURFACE_SIZE / 2.,
DEFAULT_RADIUS, 0., 2 * G_PI);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_destroy (cr);
return surface;
}
开发者ID:BoozzyAmdJin,项目名称:gtk-,代码行数:28,代码来源:gtknumerableicon.c
示例13: pattern_value_parse
static gboolean
pattern_value_parse (GtkCssParser *parser,
GFile *base,
GValue *value)
{
if (_gtk_css_parser_begins_with (parser, '-'))
{
g_value_unset (value);
g_value_init (value, GTK_TYPE_GRADIENT);
return gradient_value_parse (parser, base, value);
}
else
{
GError *error = NULL;
gchar *path;
GdkPixbuf *pixbuf;
GFile *file;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr;
cairo_matrix_t matrix;
file = _gtk_css_parse_url (parser, base);
if (file == NULL)
return FALSE;
path = g_file_get_path (file);
g_object_unref (file);
pixbuf = gdk_pixbuf_new_from_file (path, &error);
g_free (path);
if (pixbuf == NULL)
{
_gtk_css_parser_take_error (parser, error);
return FALSE;
}
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
cr = cairo_create (surface);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
pattern = cairo_pattern_create_for_surface (surface);
cairo_matrix_init_scale (&matrix,
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
cairo_pattern_set_matrix (pattern, &matrix);
cairo_surface_destroy (surface);
cairo_destroy (cr);
g_object_unref (pixbuf);
g_value_take_boxed (value, pattern);
}
return TRUE;
}
开发者ID:nacho,项目名称:gtk-,代码行数:59,代码来源:gtkcssstringfuncs.c
示例14: _paint_page
static cairo_int_status_t
_paint_page (cairo_paginated_surface_t *surface)
{
cairo_surface_t *analysis;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_status_t status;
analysis = _cairo_analysis_surface_create (surface->target,
surface->width, surface->height);
if (analysis == NULL)
return CAIRO_STATUS_NO_MEMORY;
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
status = _cairo_meta_surface_replay (surface->meta, analysis);
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);
if (status || analysis->status) {
if (status == CAIRO_STATUS_SUCCESS)
status = analysis->status;
cairo_surface_destroy (analysis);
return status;
}
if (_cairo_analysis_surface_has_unsupported (analysis))
{
double x_scale = surface->base.x_fallback_resolution / 72.0;
double y_scale = surface->base.y_fallback_resolution / 72.0;
cairo_matrix_t matrix;
image = _cairo_paginated_surface_create_image_surface (surface,
surface->width * x_scale,
surface->height * y_scale);
_cairo_surface_set_device_scale (image, x_scale, y_scale);
status = _cairo_meta_surface_replay (surface->meta, image);
if (status)
goto CLEANUP_IMAGE;
pattern = cairo_pattern_create_for_surface (image);
cairo_matrix_init_scale (&matrix, x_scale, y_scale);
cairo_pattern_set_matrix (pattern, &matrix);
status = _cairo_surface_paint (surface->target, CAIRO_OPERATOR_SOURCE, pattern);
cairo_pattern_destroy (pattern);
CLEANUP_IMAGE:
cairo_surface_destroy (image);
}
else
{
status = _cairo_meta_surface_replay (surface->meta, surface->target);
}
cairo_surface_destroy (analysis);
return status;
}
开发者ID:achellies,项目名称:ISeeBrowser,代码行数:59,代码来源:cairo-paginated-surface.c
示例15: _doc_page_get_matrix
static void _doc_page_get_matrix (CtkDocPage *self,
gdouble scale,
gint rotation,
cairo_matrix_t *ctm)
{
cairo_matrix_init_scale (ctm, scale, scale);
cairo_matrix_rotate (ctm, rotation * G_PI / 180.0);
}
开发者ID:tomnotcat,项目名称:clue,代码行数:8,代码来源:ctkdocpage.c
示例16: m_cairo_matrix_init_scale
static int m_cairo_matrix_init_scale(lua_State * L)
{
cairo_matrix_t * matrix = luaL_checkudata(L, 1, MT_NAME_CAIRO_MATRIX);
double sx = luaL_checknumber(L, 2);
double sy = luaL_checknumber(L, 3);
cairo_matrix_init_scale(matrix, sx, sy);
return 0;
}
开发者ID:qioixiy,项目名称:xboot,代码行数:8,代码来源:l_cairo_matrix.c
示例17: redraw_handler
static void
redraw_handler(struct widget *widget, void *data)
{
struct image *image = data;
struct rectangle allocation;
cairo_t *cr;
cairo_surface_t *surface;
double width, height, doc_aspect, window_aspect, scale;
cairo_matrix_t matrix;
cairo_matrix_t translate;
surface = window_get_surface(image->window);
cr = cairo_create(surface);
widget_get_allocation(image->widget, &allocation);
cairo_rectangle(cr, allocation.x, allocation.y,
allocation.width, allocation.height);
cairo_clip(cr);
cairo_push_group(cr);
cairo_translate(cr, allocation.x, allocation.y);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba(cr, 0, 0, 0, 1);
cairo_paint(cr);
if (!image->initialized) {
image->initialized = true;
width = cairo_image_surface_get_width(image->image);
height = cairo_image_surface_get_height(image->image);
doc_aspect = width / height;
window_aspect = (double) allocation.width / allocation.height;
if (doc_aspect < window_aspect)
scale = allocation.height / height;
else
scale = allocation.width / width;
image->width = width;
image->height = height;
cairo_matrix_init_scale(&image->matrix, scale, scale);
clamp_view(image);
}
matrix = image->matrix;
cairo_matrix_init_translate(&translate, allocation.x, allocation.y);
cairo_matrix_multiply(&matrix, &matrix, &translate);
cairo_set_matrix(cr, &matrix);
cairo_set_source_surface(cr, image->image, 0, 0);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_paint(cr);
cairo_pop_group_to_source(cr);
cairo_paint(cr);
cairo_destroy(cr);
cairo_surface_destroy(surface);
}
开发者ID:abhijitpotnis,项目名称:weston,代码行数:58,代码来源:image.c
示例18: rala_glyph_set_arrow_cb_night
void rala_glyph_set_arrow_cb_night(void* v, affine_t t) {
struct cl* cl = (struct cl*)(((set_cell_cb_t*)v)->cl);
cairo_t *cr = cl->cr;
static cairo_pattern_t* memoized_pattern[ARROW_TYPE_MAX];
static int cell_width, cell_height; //in pixels
static cairo_matrix_t scale_matrix;
//Make sure width and height are the same as before
double temp_width = 1.0, temp_height = 1.0;
cairo_user_to_device_distance(cr, &temp_width, &temp_height);
if((int)temp_width != cell_width || (int)temp_height != cell_height) {
cell_width = (int)temp_width;
cell_height = (int)temp_height;
memset(memoized_pattern, 0, sizeof(cairo_pattern_t*)*ARROW_TYPE_MAX);
cairo_matrix_init_scale(&scale_matrix, temp_width, temp_height);
}
//Mark dirty
if(cl->w == 0) {
cl->x = 2*t.wx-1;
cl->y = -(2*t.wy)-1;
cl->w = 3;
cl->h = 3;
} else {
cl->w = -1;
}
cairo_save(cr);
cairo_translate(cr,2*t.wx, -2*t.wy);
setup_arrow(cr,arrow_rotate(t, ((set_arrow_cb_t*)v)->arrow_dir));
arrow_type_t arrow_type = ((set_arrow_cb_t*)v)->arrow_type;
if(!memoized_pattern[arrow_type]) {
cairo_surface_t* memoizer_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, cell_width, cell_height);
cairo_t* m_cr = cairo_create(memoizer_surface);
cairo_scale(m_cr, cell_width, cell_height);
switch(arrow_type) {
case ARROW_TYPE_NONE:
arrow_none_glyph_night(m_cr);
break;
case ARROW_TYPE_X:
arrow_x_glyph_night(m_cr);
break;
case ARROW_TYPE_0:
arrow_0_glyph_night(m_cr);
break;
case ARROW_TYPE_1:
arrow_1_glyph_night(m_cr);
break;
}
memoized_pattern[arrow_type] = cairo_pattern_create_for_surface(memoizer_surface);
cairo_pattern_set_matrix(memoized_pattern[arrow_type], &scale_matrix);
}
cairo_set_source(cr, memoized_pattern[arrow_type]);
cairo_paint(cr);
cairo_restore(cr);
}
开发者ID:davidad,项目名称:rala_util,代码行数:56,代码来源:rala_glyph_cb.c
示例19: cairo_type1_font_create
static cairo_status_t
cairo_type1_font_create (cairo_scaled_font_subset_t *scaled_font_subset,
cairo_type1_font_t **subset_return,
cairo_bool_t hex_encode)
{
cairo_type1_font_t *font;
cairo_font_face_t *font_face;
cairo_matrix_t font_matrix;
cairo_matrix_t ctm;
cairo_font_options_t font_options;
cairo_status_t status;
font = calloc (1, sizeof (cairo_type1_font_t));
if (font == NULL)
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
font->widths = calloc (scaled_font_subset->num_glyphs,
sizeof (int));
if (font->widths == NULL) {
free (font);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
font->scaled_font_subset = scaled_font_subset;
font->hex_encode = hex_encode;
font_face = cairo_scaled_font_get_font_face (scaled_font_subset->scaled_font);
cairo_matrix_init_scale (&font_matrix, 1000, -1000);
cairo_matrix_init_identity (&ctm);
_cairo_font_options_init_default (&font_options);
cairo_font_options_set_hint_style (&font_options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_hint_metrics (&font_options, CAIRO_HINT_METRICS_OFF);
font->type1_scaled_font = cairo_scaled_font_create (font_face,
&font_matrix,
&ctm,
&font_options);
status = font->type1_scaled_font->status;
if (status)
goto fail;
_cairo_array_init (&font->contents, sizeof (unsigned char));
font->output = NULL;
*subset_return = font;
return CAIRO_STATUS_SUCCESS;
fail:
free (font->widths);
free (font);
return status;
}
开发者ID:jwmcglynn,项目名称:Gadgets,代码行数:56,代码来源:cairo-type1-fallback.c
示例20: adg_path_reflect
/**
* adg_path_reflect:
* @path: an #AdgPath
* @vector: (allow-none): the slope of the axis
*
* Reflects the first segment or @path around the axis passing
* throught (0, 0) and with a @vector slope. The internal segment
* is duplicated and the proper transformation (computed from
* @vector) to mirror the segment is applied on all its points.
* The result is then reversed with cpml_segment_reverse() and
* appended to the original path with adg_path_append_segment().
*
* For convenience, if @vector is <constant>NULL</constant> the
* path is reversed around the x axis <constant>(y = 0)</constant>.
*
* Since: 1.0
**/
void
adg_path_reflect(AdgPath *path, const CpmlVector *vector)
{
AdgModel *model;
cairo_matrix_t matrix;
CpmlSegment segment, *dup_segment;
g_return_if_fail(ADG_IS_PATH(path));
g_return_if_fail(vector == NULL || vector->x != 0 || vector->y != 0);
model = (AdgModel *) path;
if (vector == NULL) {
cairo_matrix_init_scale(&matrix, 1, -1);
} else {
CpmlVector slope;
gdouble cos2angle, sin2angle;
cpml_pair_copy(&slope, vector);
cpml_vector_set_length(&slope, 1);
if (slope.x == 0 && slope.y == 0) {
g_warning(_("%s: the axis of the reflection is not known"),
G_STRLOC);
return;
}
sin2angle = 2. * vector->x * vector->y;
cos2angle = 2. * vector->x * vector->x - 1;
cairo_matrix_init(&matrix, cos2angle, sin2angle,
sin2angle, -cos2angle, 0, 0);
}
if (!adg_trail_put_segment((AdgTrail *) path, 1, &segment))
return;
/* No need to reverse an empty segment */
if (segment.num_data == 0 || segment.num_data == 0)
return;
dup_segment = cpml_segment_deep_dup(&segment);
if (dup_segment == NULL)
return;
cpml_segment_reverse(dup_segment);
cpml_segment_transform(dup_segment, &matrix);
dup_segment->data[0].header.type = CPML_LINE;
adg_path_append_segment(path, dup_segment);
g_free(dup_segment);
_adg_dup_reverse_named_pairs(model, &matrix);
}
开发者ID:bert,项目名称:adg,代码行数:72,代码来源:adg-path.c
注:本文中的cairo_matrix_init_scale函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论