本文整理匯總了C++中CGAffineTransformMake函數的典型用法代碼示例。如果您正苦於以下問題:C++ CGAffineTransformMake函數的具體用法?C++ CGAffineTransformMake怎麽用?C++ CGAffineTransformMake使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CGAffineTransformMake函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CGBitmapContextCreateImage
void GiCanvasIos::endPaint(bool draw)
{
if (m_draw->getContext())
{
if (draw && m_draw->_buffctx && m_draw->_context) {
CGContextRef context = m_draw->_context;
CGImageRef image = CGBitmapContextCreateImage(m_draw->_buffctx);
CGRect rect = CGRectMake(0, 0, m_draw->width(), m_draw->height()); // 邏輯寬高點數
if (image) {
CGAffineTransform af = CGAffineTransformMake(1, 0, 0, -1, 0, m_draw->height());
CGContextConcatCTM(context, af); // 圖像是朝上的,上下文坐標係朝下,上下顛倒顯示
CGInterpolationQuality old = CGContextGetInterpolationQuality(context);
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
CGContextDrawImage(context, rect, image);
CGContextSetInterpolationQuality(context, old);
CGContextConcatCTM(context, CGAffineTransformInvert(af)); // 恢複成坐標係朝下
CGImageRelease(image);
}
}
if (m_draw->_buffctx) {
CGContextRelease(m_draw->_buffctx);
m_draw->_buffctx = NULL;
}
m_draw->_context = NULL;
if (owner())
owner()->_endPaint();
}
}
示例2: drawSkewedCoordinateSystem
void drawSkewedCoordinateSystem(CGContextRef context)
{
// alpha is 22.5 degrees and beta is 15 degrees.
float alpha = M_PI/8, beta = M_PI/12;
CGAffineTransform skew;
// Create a rectangle that is 72 units on a side
// with its origin at (0,0).
CGRect r = CGRectMake(0, 0, 72, 72);
CGContextTranslateCTM(context, 144, 144);
// Draw the coordinate axes untransformed.
drawCoordinateAxes(context);
// Fill the rectangle.
CGContextFillRect(context, r);
// Create an affine transform that skews the coordinate system,
// skewing the x-axis by alpha radians and the y-axis by beta radians.
skew = CGAffineTransformMake(1, tan(alpha), tan(beta), 1, 0, 0);
// Apply that transform to the context coordinate system.
CGContextConcatCTM(context, skew);
// Set the fill and stroke color to a dark blue.
CGContextSetRGBStrokeColor(context, 0.11, 0.208, 0.451, 1);
CGContextSetRGBFillColor(context, 0.11, 0.208, 0.451, 1);
// Draw the coordinate axes again, now transformed.
drawCoordinateAxes(context);
// Set the fill color again but with a partially transparent alpha.
CGContextSetRGBFillColor(context, 0.11, 0.208, 0.451, 0.7);
// Fill the rectangle in the transformed coordinate system.
CGContextFillRect(context, r);
}
示例3: CGImageGetWidth
bool GiCanvasIos::drawImage(CGImageRef image, const Point2d& centerM, bool autoScale)
{
CGContextRef context = m_draw->getContext();
bool ret = false;
if (context && image) {
Point2d ptD = centerM * m_draw->xf().modelToDisplay();
float w = CGImageGetWidth(image);
float h = CGImageGetHeight(image);
if (autoScale) {
w *= m_draw->xf().getViewScale();
h *= m_draw->xf().getViewScale();
}
CGAffineTransform af = CGAffineTransformMake(1, 0, 0, -1, 0, m_draw->height());
af = CGAffineTransformTranslate(af, ptD.x - w * 0.5f,
m_draw->height() - (ptD.y + h * 0.5f));
CGContextConcatCTM(context, af);
CGContextDrawImage(context, CGRectMake(0, 0, w, h), image);
CGContextConcatCTM(context, CGAffineTransformInvert(af));
ret = true;
}
return ret;
}
示例4: _cairo_matrix_to_unit_quartz_matrix
static inline cairo_status_t
_cairo_matrix_to_unit_quartz_matrix (const cairo_matrix_t *m, CGAffineTransform *txout,
double *xout, double *yout)
{
CGAffineTransform transform;
double xscale, yscale;
cairo_status_t status;
status = _cairo_matrix_compute_basis_scale_factors (m, &xscale, &yscale, 1);
if (status)
return status;
transform = CGAffineTransformMake (m->xx, - m->yx,
- m->xy, m->yy,
0.0f, 0.0f);
if (xout)
*xout = xscale;
if (yout)
*yout = yscale;
if (xscale)
xscale = 1.0 / xscale;
if (yscale)
yscale = 1.0 / yscale;
*txout = CGAffineTransformScale (transform, xscale, yscale);
return CAIRO_STATUS_SUCCESS;
}
示例5: CGRectMake
bool GiCanvasIos::drawCachedBitmap2(const GiCanvas* p, float x, float y, bool secondBmp)
{
bool ret = false;
if (p && p->getCanvasType() == getCanvasType()) {
GiCanvasIos* gs = (GiCanvasIos*)p;
int index = secondBmp ? 1 : 0;
CGImageRef image = gs->m_draw->_cacheserr[index] ? NULL : gs->m_draw->_caches[index];
CGContextRef context = m_draw->getContext();
if (context && image) {
CGRect rect = CGRectMake(x, y, m_draw->width(), m_draw->height());
CGAffineTransform af = CGAffineTransformMake(1, 0, 0, -1, 0, m_draw->height());
CGContextConcatCTM(context, af);
CGInterpolationQuality oldQuality = CGContextGetInterpolationQuality(context);
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
CGContextDrawImage(context, rect, image);
CGContextSetInterpolationQuality(context, oldQuality);
CGContextConcatCTM(context, CGAffineTransformInvert(af));
ret = true;
}
}
return ret;
}
示例6: TransformHIViewToCG
static void TransformHIViewToCG(CGContextRef ctx, HIViewRef theView)
{
// Undo the HIView coordinate flipping
HIRect bounds;
HIViewGetBounds(theView, &bounds);
CGContextConcatCTM(ctx, CGAffineTransformMake(1, 0, 0, -1, 0, bounds.size.height));
}
示例7: addOvalToPath
void addOvalToPath(CGContextRef context, CGRect r)
{
CGAffineTransform matrix;
// Save the context's state because we are going to transform and scale it
CGContextSaveGState(context);
// Create a transform to scale the context so that a radius of 1
// is equal to the bounds of the rectangle, and transform the origin
// of the context to the center of the bounding rectangle. The
// center of the bounding rectangle will now be the center of
// the oval.
matrix = CGAffineTransformMake((r.size.width)/2, 0,
0, (r.size.height)/2,
r.origin.x + (r.size.width)/2,
r.origin.y + (r.size.height)/2);
// Apply the transform to the context
CGContextConcatCTM(context, matrix);
// Signal the start of a path
CGContextBeginPath(context);
// Add a circle to the path. After the circle is transformed by the
// context's transformation matrix, it will become an oval lying
// just inside the bounding rectangle.
CGContextAddArc(context, 0, 0, 1, 0, 2*pi, true);
// Restore the context's state. This removes the translation and scaling but leaves
// the path, since the path is not part of the graphics state.
CGContextRestoreGState(context);
}
示例8: CGAffineTransformMake
void Path::translate(const FloatSize& size)
{
CGAffineTransform translation = CGAffineTransformMake(1, 0, 0, 1, size.width(), size.height());
CGMutablePathRef newPath = CGPathCreateMutable();
CGPathAddPath(newPath, &translation, m_path);
CGPathRelease(m_path);
m_path = newPath;
}
示例9: CGAffineTransform
AffineTransform::operator CGAffineTransform() const
{
return CGAffineTransformMake(narrowPrecisionToCGFloat(a()),
narrowPrecisionToCGFloat(b()),
narrowPrecisionToCGFloat(c()),
narrowPrecisionToCGFloat(d()),
narrowPrecisionToCGFloat(e()),
narrowPrecisionToCGFloat(f()));
}
示例10: CATransform3DSkew
CATransform3D CATransform3DSkew (CATransform3D t,CGFloat angleX, CGFloat angleY)
{
CGAffineTransform affineTransform = CGAffineTransformMake(1, tanf(-angleX*M_PI/180.0f), tanf(-angleY*M_PI/180.0f), 1, 0, 0);
CATransform3D skewTransform = CATransform3DMakeAffineTransform(affineTransform);
return CATransform3DConcat(t, skewTransform);
}
示例11: CGContextSetFont
FX_BOOL CQuartz2D::drawGraphicsString(void* graphics,
void* font,
FX_FLOAT fontSize,
FX_WORD* glyphIndices,
CGPoint* glyphPositions,
FX_INT32 charsCount,
FX_ARGB argb,
CFX_AffineMatrix* matrix )
{
if (!graphics) {
return FALSE;
}
CGContextRef context = (CGContextRef) graphics;
CGContextSetFont(context, (CGFontRef)font);
CGContextSetFontSize(context, fontSize);
if (matrix) {
CGAffineTransform m = CGContextGetTextMatrix(context);
m = CGAffineTransformConcat(m,
CGAffineTransformMake(matrix->a,
matrix->b,
matrix->c,
matrix->d,
matrix->e,
matrix->f));
CGContextSetTextMatrix(context, m);
}
FX_INT32 a, r, g, b;
ArgbDecode(argb, a, r, g, b);
CGContextSetRGBFillColor(context,
r / 255.f,
g / 255.f,
b / 255.f,
a / 255.f);
CGContextSaveGState(context);
#if CGFLOAT_IS_DOUBLE
CGPoint* glyphPositionsCG = new CGPoint[charsCount];
if (!glyphPositionsCG) {
return FALSE;
}
for (int index = 0; index < charsCount; ++index) {
glyphPositionsCG[index].x = glyphPositions[index].x;
glyphPositionsCG[index].y = glyphPositions[index].y;
}
#else
CGPoint* glyphPositionsCG = (CGPoint*)glyphPositions;
#endif
CGContextShowGlyphsAtPositions(context,
(CGGlyph *) glyphIndices,
glyphPositionsCG,
charsCount);
#if CGFLOAT_IS_DOUBLE
delete[] glyphPositionsCG;
#endif
CGContextRestoreGState(context);
return TRUE;
}
示例12: TEST
TEST(AffineTransform, CGAffineTransformConstruction)
{
CGAffineTransform cgTransform = CGAffineTransformMake(6.0, 5.0, 4.0, 3.0, 2.0, 1.0);
WebCore::AffineTransform test(cgTransform);
testValueConstruction(test);
testGetAndSet(test);
ASSERT_FALSE(test.isIdentity());
}
示例13: SaveState
FX_BOOL CFX_QuartzDeviceDriver::DrawPath(const CFX_PathData* pathData,
const CFX_AffineMatrix* matrix,
const CFX_GraphStateData* graphState,
FX_DWORD fillArgb,
FX_DWORD strokeArgb,
int fillMode,
int alpha_flag,
void* pIccTransform,
int blend_type
)
{
SaveState();
CGBlendMode mode = GetCGBlendMode(blend_type);
if (mode != kCGBlendModeNormal) {
CGContextSetBlendMode(_context, mode);
}
CGAffineTransform m = CGAffineTransformIdentity;
if (matrix) {
m = CGAffineTransformMake(matrix->GetA(), matrix->GetB(), matrix->GetC(), matrix->GetD(), matrix->GetE(), matrix->GetF());
}
m = CGAffineTransformConcat(m, _foxitDevice2User);
CGContextConcatCTM(_context, m);
int pathMode = 0;
if (graphState && strokeArgb) {
CGContextSetMiterLimit(_context, graphState->m_MiterLimit);
FX_FLOAT lineWidth = getLineWidth(graphState, m);
setStrokeInfo(graphState, strokeArgb, lineWidth);
pathMode |= 4;
}
if (fillMode && fillArgb) {
setFillInfo(fillArgb);
if ((fillMode & 3) == FXFILL_WINDING) {
pathMode |= 1;
} else if ((fillMode & 3) == FXFILL_ALTERNATE) {
pathMode |= 2;
}
}
setPathToContext(pathData);
if (fillMode & FXFILL_FULLCOVER) {
CGContextSetShouldAntialias(_context, false);
}
if (pathMode == 4) {
CGContextStrokePath(_context);
} else if (pathMode == 1) {
CGContextFillPath(_context);
} else if (pathMode == 2) {
CGContextEOFillPath(_context);
} else if (pathMode == 5) {
CGContextDrawPath(_context, kCGPathFillStroke);
} else if (pathMode == 6) {
CGContextDrawPath(_context, kCGPathEOFillStroke);
}
RestoreState(FALSE);
return TRUE;
}
示例14: _cairo_quartz_init_glyph_path
static cairo_int_status_t
_cairo_quartz_init_glyph_path (cairo_quartz_scaled_font_t *font,
cairo_scaled_glyph_t *scaled_glyph)
{
cairo_quartz_font_face_t *font_face = _cairo_quartz_scaled_to_face(font);
CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);
CGAffineTransform textMatrix;
CGPathRef glyphPath;
cairo_path_fixed_t *path;
if (glyph == INVALID_GLYPH) {
_cairo_scaled_glyph_set_path (scaled_glyph, &font->base, _cairo_path_fixed_create());
return CAIRO_STATUS_SUCCESS;
}
textMatrix = CGAffineTransformMake (font->base.scale.xx,
-font->base.scale.yx,
-font->base.scale.xy,
font->base.scale.yy,
font->base.scale.x0,
font->base.scale.y0);
textMatrix = CGAffineTransformConcat (textMatrix, CGAffineTransformMake (1.0, 0.0, 0.0, -1.0, 0.0, 0.0));
glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix, 0, glyph);
if (!glyphPath)
return CAIRO_INT_STATUS_UNSUPPORTED;
path = _cairo_path_fixed_create ();
if (!path) {
CGPathRelease (glyphPath);
return _cairo_error(CAIRO_STATUS_NO_MEMORY);
}
CGPathApply (glyphPath, path, _cairo_quartz_path_apply_func);
CGPathRelease (glyphPath);
_cairo_scaled_glyph_set_path (scaled_glyph, &font->base, path);
return CAIRO_STATUS_SUCCESS;
}
示例15: OS_NATIVE
JNIEXPORT void JNICALL OS_NATIVE(CGAffineTransformMake)
(JNIEnv *env, jclass that, jfloat arg0, jfloat arg1, jfloat arg2, jfloat arg3, jfloat arg4, jfloat arg5, jfloatArray arg6)
{
jfloat *lparg6=NULL;
OS_NATIVE_ENTER(env, that, CGAffineTransformMake_FUNC);
if (arg6) if ((lparg6 = (*env)->GetFloatArrayElements(env, arg6, NULL)) == NULL) goto fail;
*(CGAffineTransform *)lparg6 = CGAffineTransformMake(arg0, arg1, arg2, arg3, arg4, arg5);
fail:
if (arg6 && lparg6) (*env)->ReleaseFloatArrayElements(env, arg6, lparg6, 0);
OS_NATIVE_EXIT(env, that, CGAffineTransformMake_FUNC);
}