Boolean checkerboardeffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { int2 newy = (Checkersize << 1) * delta / duration; MCGRectangle t_src_rect, t_dst_rect; t_src_rect = MCGRectangleMake(0, 0, drect.width, drect.height); t_dst_rect = MCGRectangleTranslate(t_src_rect, drect.x, drect.y); p_target->Composite(t_dst_rect, p_start, t_src_rect, 1.0, kMCGBlendModeCopy); bool t_odd = false; for (uint32_t x = 0; x < drect.width; x += Checkersize) { for (int32_t y = (t_odd ? -Checkersize : 0); y < drect.height; y += Checkersize * 2) { t_src_rect = MCGRectangleMake(x, y, Checkersize, newy); t_dst_rect = MCGRectangleTranslate(t_src_rect, drect.x, drect.y); p_target->Composite(t_dst_rect, p_end, t_src_rect, 1.0, kMCGBlendModeCopy); } t_odd = !t_odd; } return True; }
Boolean zoomeffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint32_t p_delta, uint32_t p_duration) { MCGFloat t_position = (MCGFloat)p_delta / (MCGFloat)p_duration; uint32_t t_width, t_height; MCGImageRef t_top, t_bottom; if (dir == VE_OUT || dir == VE_OPEN) { t_bottom = p_start; t_top = p_end; t_width = drect.width * t_position; t_height = drect.height * t_position; } else { t_bottom = p_end; t_top = p_start; t_width = drect.width * (1.0 - t_position); t_height = drect.height * (1.0 - t_position); } MCGRectangle t_src, t_dst, t_top_dst; t_src = MCGRectangleMake(0.0, 0.0, drect.width, drect.height); t_dst = MCGRectangleTranslate(t_src, drect.x, drect.y); t_top_dst = MCGRectangleMake(drect.x + (drect.width - t_width) / 2, drect.y + (drect.height - t_height) / 2, t_width, t_height); p_target->Composite(t_dst, t_bottom, t_src, 1.0, kMCGBlendModeCopy); p_target->Composite(t_top_dst, t_top, t_src, 1.0, kMCGBlendModeCopy); return True; }
Boolean stretcheffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { uint2 height = drect.height * delta / duration; uint32_t t_top, t_bottom; switch (dir) { case VE_TOP: t_top = 0; break; case VE_CENTER: t_top = (drect.height - height) / 2; break; case VE_BOTTOM: t_top = drect.height - height; break; } t_bottom = t_top + height; MCGRectangle t_start_src, t_start_dst; MCGRectangle t_end_src, t_end_dst; t_start_src = MCGRectangleMake(0.0, 0.0, drect.width, drect.height); t_start_dst = MCGRectangleTranslate(t_start_src, drect.x, drect.y); t_end_src = MCGRectangleMake(0.0, 0.0, drect.width, drect.height); t_end_dst = MCGRectangleMake(drect.x, drect.y + t_top, drect.width, height); p_target->Composite(t_start_dst, p_start, t_start_src, 1.0, kMCGBlendModeCopy); p_target->Composite(t_end_dst, p_end, t_end_src, 1.0, kMCGBlendModeCopy); return True; }
Boolean barneffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { uint32_t width, x; MCGImageRef t_top, t_bottom; MCGRectangle t_top_src, t_bottom_src; if (dir == VE_CLOSE) { width = (drect.width) * (duration - delta) / duration; x = (drect.width / 2) * delta / duration; t_top = p_start; t_bottom = p_end; } else { width = (drect.width) * delta / duration; x = (drect.width / 2) * (duration - delta) / duration; t_top = p_end; t_bottom = p_start; } t_bottom_src = MCGRectangleMake(0, 0, drect.width, drect.height); t_top_src = MCGRectangleMake(x, 0, width, drect.height); p_target->Composite(MCGRectangleTranslate(t_bottom_src, drect.x, drect.y), t_bottom, t_bottom_src, 1.0, kMCGBlendModeCopy); p_target->Composite(MCGRectangleTranslate(t_top_src, drect.x, drect.y), t_top, t_top_src, 1.0, kMCGBlendModeCopy); return True; }
Boolean revealeffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { uint2 size; if (dir == VE_LEFT || dir == VE_RIGHT) size = drect.width * delta / duration; else size = drect.height * delta / duration; MCGRectangle t_start_src, t_end_src, t_dst_rect; MCGRectangle t_start_dst, t_end_dst; t_dst_rect = MCRectangleToMCGRectangle(drect); t_start_src = MCGRectangleMake(0, 0, drect.width, drect.height); switch (dir) { case VE_LEFT: t_start_dst = MCGRectangleTranslate(t_dst_rect, -(MCGFloat)size, 0.0); t_end_src = MCGRectangleMake(t_dst_rect.size.width - size, 0.0, size, t_dst_rect.size.height); break; case VE_RIGHT: t_start_dst = MCGRectangleTranslate(t_dst_rect, size, 0.0); t_end_src = MCGRectangleMake(0.0, 0.0, size, t_dst_rect.size.height); break; case VE_UP: t_start_dst = MCGRectangleTranslate(t_dst_rect, 0.0, -(MCGFloat)size); t_end_src = MCGRectangleMake(0.0, t_dst_rect.size.height - size, t_dst_rect.size.width, size); break; case VE_DOWN: t_start_dst = MCGRectangleTranslate(t_dst_rect, 0.0, size); t_end_src = MCGRectangleMake(0.0, 0.0, t_dst_rect.size.width, size); break; } t_end_dst = MCGRectangleTranslate(t_end_src, t_dst_rect.origin.x, t_dst_rect.origin.y); p_target->Composite(t_start_dst, p_start, t_start_src, 1.0, kMCGBlendModeCopy); p_target->Composite(t_end_dst, p_end, t_end_src, 1.0, kMCGBlendModeCopy); return True; }
Boolean dissolveeffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { MCGFloat t_alpha; t_alpha = (MCGFloat)delta / (MCGFloat)duration; MCGRectangle t_src_rect, t_dst_rect; t_dst_rect = MCRectangleToMCGRectangle(drect); t_src_rect = MCGRectangleMake(0.0, 0.0, t_dst_rect.size.width, t_dst_rect.size.height); p_target->Composite(t_dst_rect, p_start, t_src_rect, 1.0, kMCGBlendModeSourceOver); p_target->Composite(t_dst_rect, p_end, t_src_rect, t_alpha, kMCGBlendModeSourceOver); return True; }
Boolean iriseffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { MCGFloat t_position = (MCGFloat) delta / (MCGFloat) duration; uint32_t width, height, x, y; MCGImageRef t_top, t_bottom; MCGRectangle t_top_src, t_bottom_src; if (dir == VE_CLOSE) { width = drect.width * (1.0 - t_position); height = drect.height * (1.0 - t_position); x = (drect.width / 2) * t_position; y = (drect.height / 2) * t_position; t_top = p_start; t_bottom = p_end; } else { width = drect.width * t_position; height = drect.height * t_position; x = (drect.width / 2) * (1.0 - t_position); y = (drect.height / 2) * (1.0 - t_position); t_top = p_end; t_bottom = p_start; } t_bottom_src = MCGRectangleMake(0, 0, drect.width, drect.height); t_top_src = MCGRectangleMake(x, y, width, height); p_target->Composite(MCGRectangleTranslate(t_bottom_src, drect.x, drect.y), t_bottom, t_bottom_src, 1.0, kMCGBlendModeCopy); p_target->Composite(MCGRectangleTranslate(t_top_src, drect.x, drect.y), t_top, t_top_src, 1.0, kMCGBlendModeCopy); return True; }
Boolean venetianeffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { int2 newy = Venetiansize * delta / duration; MCGRectangle t_src_rect, t_dst_rect; t_src_rect = MCGRectangleMake(0, 0, drect.width, drect.height); t_dst_rect = MCGRectangleTranslate(t_src_rect, drect.x, drect.y); p_target->Composite(t_dst_rect, p_start, t_src_rect, 1.0, kMCGBlendModeCopy); uint2 height = newy; int2 y = 0; while (y <= drect.height) { MCGRectangle t_end_src, t_end_dst; t_end_src = MCGRectangleMake(0, y, drect.width, height); t_end_dst = MCGRectangleTranslate(t_end_src, drect.x, drect.y); p_target->Composite(t_end_dst, p_end, t_end_src, 1.0, kMCGBlendModeCopy); y += Venetiansize; } return True; }
bool MCImageBitmapToCGImage(MCImageBitmap *p_bitmap, CGColorSpaceRef p_colorspace, bool p_copy, bool p_invert, CGImageRef &r_image) { if (p_bitmap == nil) return false; bool t_mask; t_mask = MCImageBitmapHasTransparency(p_bitmap); MCGRaster t_raster; t_raster.width = p_bitmap->width; t_raster.height = p_bitmap->height; t_raster.pixels = p_bitmap->data; t_raster.stride = p_bitmap->stride; t_raster.format = t_mask ? kMCGRasterFormat_ARGB : kMCGRasterFormat_xRGB; return MCGRasterToCGImage(t_raster, MCGRectangleMake(0, 0, p_bitmap->width, p_bitmap->height), p_colorspace, p_copy, p_invert, r_image); }
Boolean scrolleffect_step(const MCRectangle &drect, MCStackSurface *p_target, MCGImageRef p_start, MCGImageRef p_end, Visual_effects dir, uint4 delta, uint4 duration) { MCGFloat t_position = (MCGFloat)delta / (MCGFloat)duration; MCGRectangle t_end_src, t_end_dst; MCGRectangle t_start_src, t_start_dst; t_start_dst = MCRectangleToMCGRectangle(drect); t_start_src = t_end_src = MCGRectangleMake(0.0, 0.0, drect.width, drect.height); uint32_t width, height; switch (dir) { case VE_LEFT: width = drect.width * t_position; t_end_dst = MCGRectangleTranslate(t_end_src, t_end_src.size.width - width, 0.0); break; case VE_RIGHT: width = drect.width * t_position; t_end_dst = MCGRectangleTranslate(t_end_src, -t_end_src.size.width + width, 0.0); break; case VE_UP: height = drect.height * t_position; t_end_dst = MCGRectangleTranslate(t_end_src, 0.0, t_end_src.size.height - height); break; case VE_DOWN: height = drect.height * t_position; t_end_dst = MCGRectangleTranslate(t_end_src, 0.0, -t_end_src.size.height + height); break; } t_end_dst.origin.x += drect.x; t_end_dst.origin.y += drect.y; p_target->Composite(t_start_dst, p_start, t_start_src, 1.0, kMCGBlendModeCopy); p_target->Composite(t_end_dst, p_end, t_end_src, 1.0, kMCGBlendModeCopy); return True; }
void MCAndroidScrollerControl::SetContentRect(MCExecContext& ctxt, integer_t p_rect[4]) { jobject t_view; t_view = GetView(); // SN-2014-11-27: [[ Bug 14046 ]] m_content_rect stores user-pixel values m_content_rect . x = p_rect[0]; m_content_rect . y = p_rect[1]; m_content_rect . width = p_rect[2] - p_rect[0]; m_content_rect . height = p_rect[3] - p_rect[1]; // PM-2016-01-14: [[Bug 16705]] Pass the correct width and height if (t_view != nil) { // SN-2014-11-27: [[ Bug 14046 ]] Apply the fix for the bug 11485. MCGRectangle t_rect; t_rect = MCNativeControlUserRectToDeviceRect(MCGRectangleMake(p_rect[0], p_rect[1], p_rect[2], p_rect[3])); MCAndroidObjectRemoteCall(t_view, "setContentSize", "vii", nil, (integer_t)(t_rect.size.width), (integer_t)(t_rect.size.height)); } }
bool MCStackRenderInitial(MCStackSurface *p_target, MCRegionRef p_region, void *p_context) { MCStackEffectContext *context = static_cast<MCStackEffectContext*>(p_context); p_target->Composite(MCRectangleToMCGRectangle(context->effect_area), context->initial_image, MCGRectangleMake(0, 0, context->effect_area.width, context->effect_area.height), 1.0, kMCGBlendModeCopy); return true; }