您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ Canvas函数代码示例

51自学网 2021-06-01 20:09:24
  C++
这篇教程C++ Canvas函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中Canvas函数的典型用法代码示例。如果您正苦于以下问题:C++ Canvas函数的具体用法?C++ Canvas怎么用?C++ Canvas使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了Canvas函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OvalToPoint

	/* ARGSUSED */static doubleOvalToPoint(    Tk_Canvas canvas,		/* Canvas containing item. */    Tk_Item *itemPtr,		/* Item to check against point. */    double *pointPtr)		/* Pointer to x and y coordinates. */{    RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr;    double width;    int filled;    Tk_State state = itemPtr->state;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    width = (double) ovalPtr->outline.width;    if (Canvas(canvas)->currentItemPtr == itemPtr) {	if (ovalPtr->outline.activeWidth>width) {	    width = (double) ovalPtr->outline.activeWidth;	}    } else if (state == TK_STATE_DISABLED) {	if (ovalPtr->outline.disabledWidth>0) {	    width = (double) ovalPtr->outline.disabledWidth;	}    }    filled = ovalPtr->fillGC != None;    if (ovalPtr->outline.gc == None) {	width = 0.0;	filled = 1;    }    return TkOvalToPoint(ovalPtr->bbox, width, filled, pointPtr);}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:35,


示例2: RectToArea

	/* ARGSUSED */static intRectToArea(    Tk_Canvas canvas,		/* Canvas containing item. */    Tk_Item *itemPtr,		/* Item to check against rectangle. */    double *areaPtr)		/* Pointer to array of four coordinates (x1,				 * y1, x2, y2) describing rectangular area. */{    RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;    double halfWidth;    double width;    Tk_State state = itemPtr->state;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    width = rectPtr->outline.width;    if (Canvas(canvas)->currentItemPtr == itemPtr) {	if (rectPtr->outline.activeWidth > width) {	    width = rectPtr->outline.activeWidth;	}    } else if (state == TK_STATE_DISABLED) {	if (rectPtr->outline.disabledWidth > 0) {	    width = rectPtr->outline.disabledWidth;	}    }    halfWidth = width/2.0;    if (rectPtr->outline.gc == None) {	halfWidth = 0.0;    }    if ((areaPtr[2] <= (rectPtr->bbox[0] - halfWidth))	    || (areaPtr[0] >= (rectPtr->bbox[2] + halfWidth))	    || (areaPtr[3] <= (rectPtr->bbox[1] - halfWidth))	    || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) {	return -1;    }    if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None)	    && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth))	    && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth))	    && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth))	    && (areaPtr[3] <= (rectPtr->bbox[3] - halfWidth))) {	return -1;    }    if ((areaPtr[0] <= (rectPtr->bbox[0] - halfWidth))	    && (areaPtr[1] <= (rectPtr->bbox[1] - halfWidth))	    && (areaPtr[2] >= (rectPtr->bbox[2] + halfWidth))	    && (areaPtr[3] >= (rectPtr->bbox[3] + halfWidth))) {	return 1;    }    return 0;}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:54,


示例3: Canvas

void DebugRenderer::renderBlobs(unsigned char* image, Blobber* blobber, int width, int height) {	Canvas canvas = Canvas();	canvas.data = image;	canvas.width = width;	canvas.height = height;	for (int i = 0; i < blobber->getColorCount(); i++) {		Blobber::Color* color = blobber->getColor(i);		if (color == NULL) {			continue;		}		if (			strcmp(color->name, "ball") != 0			&& strcmp(color->name, "yellow-goal") != 0			&& strcmp(color->name, "blue-goal") != 0		) {			continue;		}		Blobber::Blob* blob = blobber->getBlobs(color->name);		while (blob != NULL) {			canvas.drawBoxCentered(				(int)blob->centerX, (int)blob->centerY,				blob->x2 - blob->x1, blob->y2 - blob->y1,				color->color.red, color->color.green, color->color.blue			);			blob = blob->next;		}	}}
开发者ID:Sean3Don,项目名称:soccervision,代码行数:35,


示例4: DisplayWindow

FullScreen::FullScreen(){#ifdef WIN32	clan::D3DTarget::set_current();#else	clan::OpenGLTarget::set_current();#endif	DisplayWindowDescription window_description;	window_description.set_title("ClanLib FullScreen Example");	window_description.set_size(Size(700, 600), true);	window_description.set_allow_resize(true);	window = DisplayWindow(window_description);	sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));	sc.connect(window.get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));	canvas = Canvas(window);	spr_logo = Sprite(canvas, "../Basic2D/Resources/logo.png");	spr_background = Sprite(canvas, "../../Display/Path/Resources/lobby_background2.png");	font = clan::Font("tahoma", 24);	game_time.reset();}
开发者ID:doughdemon,项目名称:ClanLib,代码行数:25,


示例5: TextToPoint

static doubleTextToPoint(    Tk_Canvas canvas,		/* Canvas containing itemPtr. */    Tk_Item *itemPtr,		/* Item to check against point. */    double *pointPtr)		/* Pointer to x and y coordinates. */{    TextItem *textPtr;    Tk_State state = itemPtr->state;    double value, px, py;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    textPtr = (TextItem *) itemPtr;    px = pointPtr[0] - textPtr->drawOrigin[0];    py = pointPtr[1] - textPtr->drawOrigin[1];    value = (double) Tk_DistanceToTextLayout(textPtr->textLayout,	    (int) (px*textPtr->cosine - py*textPtr->sine),	    (int) (py*textPtr->cosine + px*textPtr->sine));    if ((state == TK_STATE_HIDDEN) || (textPtr->color == NULL) ||	    (textPtr->text == NULL) || (*textPtr->text == 0)) {	value = 1.0e36;    }    return value;}
开发者ID:tcltk,项目名称:tk,代码行数:26,


示例6: SCOPED_DRAW_EVENT

void FRCPassPostProcessVisualizeLPV::Process(FRenderingCompositePassContext& Context){	SCOPED_DRAW_EVENT(Context.RHICmdList, VisualizeLPV);	const FSceneView& View = Context.View;	const FSceneViewFamily& ViewFamily = *(View.Family);	//	const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);	const TRefCountPtr<IPooledRenderTarget> RenderTarget = GetInput(ePId_Input0)->GetOutput()->PooledRenderTarget;	const FSceneRenderTargetItem& DestRenderTarget = RenderTarget->GetRenderTargetItem();	// Set the view family's render target/viewport.	SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());	{		FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);		FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, View.GetFeatureLevel());		float X = 30;		float Y = 28;		const float YStep = 14;		const float ColumnWidth = 250;		Canvas.DrawShadowedString( X, Y += YStep, TEXT("VisualizeLightPropagationVolume"), GetStatsFont(), FLinearColor(0.2f, 0.2f, 1));		Y += YStep;		const FLightPropagationVolumeSettings& Dest = View.FinalPostProcessSettings.BlendableManager.GetSingleFinalDataConst<FLightPropagationVolumeSettings>();#define ENTRY(name)/		Canvas.DrawShadowedString( X, Y += YStep, TEXT(#name) TEXT(":"), GetStatsFont(), FLinearColor(1, 1, 1));/		Canvas.DrawShadowedString( X + ColumnWidth, Y, *FString::Printf(TEXT("%g"), Dest.name), GetStatsFont(), FLinearColor(1, 1, 1));		ENTRY(LPVIntensity)		ENTRY(LPVVplInjectionBias)		ENTRY(LPVSize)		ENTRY(LPVSecondaryOcclusionIntensity)		ENTRY(LPVSecondaryBounceIntensity)		ENTRY(LPVGeometryVolumeBias)		ENTRY(LPVEmissiveInjectionIntensity)		ENTRY(LPVDirectionalOcclusionIntensity)		ENTRY(LPVDirectionalOcclusionRadius)		ENTRY(LPVDiffuseOcclusionExponent)		ENTRY(LPVSpecularOcclusionExponent)		ENTRY(LPVDiffuseOcclusionIntensity)		ENTRY(LPVSpecularOcclusionIntensity)#undef ENTRY		Canvas.Flush_RenderThread(Context.RHICmdList);	}	Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());		// to satify following passws	FRenderingCompositeOutput* Output = GetOutput(ePId_Output0);		Output->PooledRenderTarget = RenderTarget;}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:58,


示例7: create_window

bool FullScreen::update(){	const float virtual_screen_width = 800.0f;	const float virtual_screen_height = 600.0f;	game_time.update();	// Check for fullscreen switch	if (fullscreen_requested != is_fullscreen)	{		is_fullscreen = fullscreen_requested;		create_window();	}	if (window.get_gc() != canvas.get_gc()) 	{		canvas = Canvas(window); // Always get the graphic context, the window may have been recreated	}	canvas.clear(Colorf(0.0f,0.0f,0.2f));	int font_size = 28;	font_size *= canvas.get_width() / virtual_screen_width;	font.set_height(font_size);	canvas.set_transform(Mat4f::identity());	if (is_fullscreen)	{		font.draw_text(canvas, 16, font_size, "Full Screen Mode. Press 'F' to switch to resizable window.");	}	else	{		font.draw_text(canvas, 16, font_size, "Resizable Window. Press 'F' to switch to full screen mode.");	}	// Scale the drawing to the screen to a virtual screen size	Mat4f matrix = Mat4f::scale( (float) canvas.get_width() / virtual_screen_width, (float) canvas.get_height() /virtual_screen_height, 1.0f);	canvas.set_transform(matrix);	spr_logo.draw(canvas, virtual_screen_width-spr_logo.get_width(), virtual_screen_height-spr_logo.get_height());	spr_background.set_scale(0.5f, 0.5f);	spr_background.draw(canvas, 100, 100);	// Show a few alpha-blending moving rectangles that moves in circles	float x = cos(sin_count)*120.0f;	float y = sin(sin_count)*120.0f;	sin_count += 2.0f * game_time.get_time_elapsed();	canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300.0f + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(0.0f, 1.0f, 0.0, 0.5f));	x = cos(sin_count+3.14159f)*120.0f;	y = sin(sin_count+3.14159f)*120.0f;	canvas.fill_rect(Rectf( 320.0f + x -30.0f, 300 + y -30.0f, Sizef(60.0f, 60.0f)), Colorf(1.0f, 1.0f, 0.0, 0.5f));	window.flip(1);	return !quit;}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:56,


示例8: DisplayImage

static voidDisplayImage(    Tk_Canvas canvas,		/* Canvas that contains item. */    Tk_Item *itemPtr,		/* Item to be displayed. */    Display *display,		/* Display on which to draw item. */    Drawable drawable,		/* Pixmap or window in which to draw item. */    int x, int y, int width, int height)/* Describes region of canvas that must be * redisplayed (not used). */{    ImageItem *imgPtr = (ImageItem *) itemPtr;    short drawableX, drawableY;    Tk_Image image;    Tk_State state = itemPtr->state;    if (state == TK_STATE_NULL) {        state = Canvas(canvas)->canvas_state;    }    image = imgPtr->image;    if (Canvas(canvas)->currentItemPtr == itemPtr) {        if (imgPtr->activeImage != NULL) {            image = imgPtr->activeImage;        }    } else if (state == TK_STATE_DISABLED) {        if (imgPtr->disabledImage != NULL) {            image = imgPtr->disabledImage;        }    }    if (image == NULL) {        return;    }    /*     * Translate the coordinates to those of the image, then redisplay it.     */    Tk_CanvasDrawableCoords(canvas, (double) x, (double) y,                            &drawableX, &drawableY);    Tk_RedrawImage(image, x - imgPtr->header.x1, y - imgPtr->header.y1,                   width, height, drawable, drawableX, drawableY);}
开发者ID:FreddieAkeroyd,项目名称:TkTclTix,代码行数:43,


示例9: return

RenderTechnique::PassElm RenderTechnique::addPass( NameID& name, unsigned int texCount, Effect* effect, int width, int height, bool flipH, bool flipV, bool renderToCanvas ){	for( PassElm p = m_passes.FirstPointer(); !p.IsEmpty(); p.Next() )		if( p() && name == p()->name )			return( PassElm() );	if( static_cast<int>(texCount) > Global::use().engine->getTextureUnitsCount() )		return( PassElm() );	Engine::WindowRect wr;	Global::use().engine->getWindowRect( wr );	if( width <= 0 )		width = wr.width;	if( height <= 0 )		height = wr.height;	Pass* p = new Pass( name );	PassElm pass = m_passes.AddPointer( p );	if( pass.IsEmpty() )	{		DELETE_OBJECT( p );		return( PassElm() );	}	p->inputTextures.Reserve( texCount );	p->inputTexturesMine.Reserve( texCount );	for( unsigned int i = 0; i < p->inputTextures.Size(); i++ )	{		p->inputTextures[ i ] = 0;		p->inputTexturesMine[ i ] = false;	}	p->outputMaterial = xnew Material();	p->outputMaterial->setEffect( effect );	p->outputScene = xnew SpriteBatch( 1 );	p->outputScene->setCamera( xnew Camera2D( 0.0f, 0.0f, static_cast<float>(width), static_cast<float>(height), 0.0f ) );	p->outputQuad = xnew SpriteBatch::Sprite();	p->outputQuad->setMaterial( p->outputMaterial );	p->outputQuad->setWidth( static_cast<float>(width) );	p->outputQuad->setHeight( static_cast<float>(height) );	if( flipH )		p->outputQuad->flip( SpriteBatch::Sprite::ftHorizontal );	if( flipV )		p->outputQuad->flip( SpriteBatch::Sprite::ftVertical );	p->outputScene->attach( p->outputQuad );	if( renderToCanvas )	{		p->outputCanvas = xnew Canvas( width, height );		p->outputScene->setCanvas( p->outputCanvas );		p->outputCanvas->setClearOnActivate( true );	}	return( pass );}
开发者ID:PsichiX,项目名称:XenonCore2,代码行数:48,


示例10: window_view

	WindowView_Impl::WindowView_Impl(WindowView *view, const DisplayWindowDescription &desc) : window_view(view), window(desc)	{		canvas = Canvas(window);		slots.connect(window.sig_lost_focus(), clan::bind_member(this, &WindowView_Impl::on_lost_focus));		slots.connect(window.sig_got_focus(), clan::bind_member(this, &WindowView_Impl::on_got_focus));		slots.connect(window.sig_resize(), clan::bind_member(this, &WindowView_Impl::on_resize));		slots.connect(window.sig_paint(), clan::bind_member(this, &WindowView_Impl::on_paint));		slots.connect(window.sig_window_close(), clan::bind_member(this, &WindowView_Impl::on_window_close));		slots.connect(window.get_ic().get_keyboard().sig_key_down(), clan::bind_member(this, &WindowView_Impl::on_key_down));		slots.connect(window.get_ic().get_keyboard().sig_key_up(), clan::bind_member(this, &WindowView_Impl::on_key_up));		slots.connect(window.get_ic().get_mouse().sig_key_down(), clan::bind_member(this, &WindowView_Impl::on_mouse_down));		slots.connect(window.get_ic().get_mouse().sig_key_dblclk(), clan::bind_member(this, &WindowView_Impl::on_mouse_dblclk));		slots.connect(window.get_ic().get_mouse().sig_key_up(), clan::bind_member(this, &WindowView_Impl::on_mouse_up));		slots.connect(window.get_ic().get_mouse().sig_pointer_move(), clan::bind_member(this, &WindowView_Impl::on_mouse_move));	}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:16,


示例11: DisplayWindow

HSV::HSV(){	clan::OpenGLTarget::set_current();	window = DisplayWindow("ClanLib HSV Sprite", 1024, 768);	sc.connect(window.sig_window_close(), clan::bind_member(this, &HSV::on_close));	sc.connect(window.get_keyboard().sig_key_up(), clan::bind_member(this, &HSV::on_input_up));	canvas = Canvas(window);	font = clan::Font("Tahoma", 11);	sprite_batcher = std::make_shared<HSVSpriteBatch>(canvas);	car1 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/spaceshoot_body_moving1.png");	car2 = std::make_shared<HSVSprite>(canvas, sprite_batcher.get(), "Resources/ferrari_maranello.png");	last_fps_update = System::get_time();	last_time = last_fps_update;}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:18,


示例12: DisplayWindow

void FullScreen::create_window(){	DisplayWindowDescription window_description;	window_description.set_title("ClanLib FullScreen Example");	window_description.set_size(Size(700, 600), true);	if (is_fullscreen)	{		window_description.set_fullscreen(true);		window_description.show_caption(false);	}	else	{		window_description.set_allow_resize(true);	}	window = DisplayWindow(window_description);	sc.connect(window.sig_window_close(), clan::bind_member(this, &FullScreen::on_window_close));	sc.connect(window.get_ic().get_keyboard().sig_key_down(), clan::bind_member(this, &FullScreen::on_input_down));	canvas = Canvas(window);}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:22,


示例13: TextToArea

static intTextToArea(    Tk_Canvas canvas,		/* Canvas containing itemPtr. */    Tk_Item *itemPtr,		/* Item to check against rectangle. */    double *rectPtr)		/* Pointer to array of four coordinates				 * (x1,y1,x2,y2) describing rectangular				 * area. */{    TextItem *textPtr;    Tk_State state = itemPtr->state;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    textPtr = (TextItem *) itemPtr;    return TkIntersectAngledTextLayout(textPtr->textLayout,	    (int) ((rectPtr[0] + 0.5) - textPtr->drawOrigin[0]),	    (int) ((rectPtr[1] + 0.5) - textPtr->drawOrigin[1]),	    (int) (rectPtr[2] - rectPtr[0] + 0.5),	    (int) (rectPtr[3] - rectPtr[1] + 0.5),	    textPtr->angle);}
开发者ID:tcltk,项目名称:tk,代码行数:23,


示例14: CenterButtonImage

//---------------------------------------------------------------------------void __fastcall CenterButtonImage(TButton * Button){  UncenterButtonImage(Button);  // with themes disabled, the text seems to be drawn over the icon,  // so that the padding spaces hide away most of the icon  if (UseThemes())  {    Button->ImageAlignment = iaCenter;    int ImageWidth = Button->Images->Width;    std::unique_ptr<TControlCanvas> Canvas(new TControlCanvas());    Canvas->Control = Button;    UnicodeString Caption = Button->Caption;    UnicodeString Padding;    while (Canvas->TextWidth(Padding) < ImageWidth)    {      Padding += L" ";    }    Caption = Padding + Caption;    Button->Caption = Caption;    int CaptionWidth = Canvas->TextWidth(Caption);    // The margins seem to extend the area over which the image is centered,    // so we have to set it to a double of desired padding.    // Note that (CaptionWidth / 2) - (ImageWidth / 2)    // is approximatelly same as half of caption width before padding.    Button->ImageMargins->Left = - 2 * ((CaptionWidth / 2) - (ImageWidth / 2) + ScaleByTextHeight(Button, 2));  }  else  {    // at least do not draw it so near to the edge    Button->ImageMargins->Left = 1;  }}
开发者ID:mpmartin8080,项目名称:winscp,代码行数:37,


示例15: Canvas

CanvasTopCanvas::Lock(){  return Canvas(buffer);}
开发者ID:jaaaaf,项目名称:LK8000,代码行数:5,


示例16: SCOPED_DRAW_EVENT

void FRCPassPostProcessVisualizeShadingModels::Process(FRenderingCompositePassContext& Context){	SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessVisualizeShadingModels);	const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);	const FSceneView& View = Context.View;	const FViewInfo& ViewInfo = Context.View;	const FSceneViewFamily& ViewFamily = *(View.Family);		FIntRect SrcRect = View.ViewRect;	FIntRect DestRect = View.ViewRect;	FIntPoint SrcSize = InputDesc->Extent;	const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);	// Set the view family's render target/viewport.	SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());	Context.SetViewportAndCallRHI(DestRect);	// set the state	Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());	Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());	Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());	TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());	TShaderMapRef<FPostProcessVisualizeShadingModelsPS> PixelShader(Context.GetShaderMap());	static FGlobalBoundShaderState BoundShaderState;		SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);	PixelShader->SetPS(Context, ((FViewInfo&)View).ShadingModelMaskInView);	// Draw a quad mapping scene color to the view's render target	DrawRectangle(		Context.RHICmdList,		DestRect.Min.X, DestRect.Min.Y,		DestRect.Width(), DestRect.Height(),		SrcRect.Min.X, SrcRect.Min.Y,		SrcRect.Width(), SrcRect.Height(),		DestRect.Size(),		SrcSize,		*VertexShader,		EDRF_UseTriangleOptimization);	FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);	FCanvas Canvas(&TempRenderTarget, NULL, 0, 0, 0, Context.GetFeatureLevel());	float X = 30;	float Y = 28;	const float YStep = 14;	const float ColumnWidth = 250;	FString Line;	Canvas.DrawShadowedString( X, Y += YStep, TEXT("Visualize ShadingModels (mostly to track down bugs)"), GetStatsFont(), FLinearColor(1, 1, 1));	Y = 160 - YStep - 4;		uint32 Value = ((FViewInfo&)View).ShadingModelMaskInView;	Line = FString::Printf(TEXT("View.ShadingModelMaskInView = 0x%x"), Value);	Canvas.DrawShadowedString( X, Y, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f));	Y += YStep;	UEnum* Enum = FindObject<UEnum>(NULL, TEXT("Engine.EMaterialShadingModel"));	check(Enum);	Y += 5;	for(uint32 i = 0; i < MSM_MAX; ++i)	{		FString Name = Enum->GetEnumName(i);		Line = FString::Printf(TEXT("%d.  %s"), i, *Name);		bool bThere = (Value & (1 << i)) != 0;		Canvas.DrawShadowedString(X + 30, Y, *Line, GetStatsFont(), bThere ? FLinearColor(1, 1, 1) : FLinearColor(0, 0, 0) );		Y += 20;	}	Line = FString::Printf(TEXT("(On CPU, based on what gets rendered)"));	Canvas.DrawShadowedString( X, Y, *Line, GetStatsFont(), FLinearColor(0.5f, 0.5f, 0.5f)); Y += YStep;	Canvas.Flush_RenderThread(Context.RHICmdList);	Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());	// AdjustGBufferRefCount(1) call is done in constructor	FSceneRenderTargets::Get(Context.RHICmdList).AdjustGBufferRefCount(Context.RHICmdList, -1);}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:91,


示例17: SCOPED_DRAW_EVENT

//.........这里部分代码省略.........	// Draw a quad mapping scene color to the view's render target	DrawRectangle(		0, 0,		DestRect.Width(), DestRect.Height(),		SrcRect.Min.X, SrcRect.Min.Y,		SrcRect.Width(), SrcRect.Height(),		DestRect.Size(),		SrcSize,		EDRF_UseTriangleOptimization);	// Now draw the requested tiles into the grid	TShaderMapRef<FPostProcessVS> VertexShader(GetGlobalShaderMap());	TShaderMapRef<FPostProcessVisualizeBufferPS<true> > PixelShader(GetGlobalShaderMap());	RHISetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_SourceAlpha, BF_InverseSourceAlpha>::GetRHI());	static FGlobalBoundShaderState BoundShaderState;	SetGlobalBoundShaderState(BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);	PixelShader->SetPS(Context);	// Track the name and position of each tile we draw so we can write text labels over them	struct LabelRecord	{		FString Label;		int32 LocationX;		int32 LocationY;	};	TArray<LabelRecord> Labels;	const int32 MaxTilesX = 4;	const int32 MaxTilesY = 4;	const int32 TileWidth = DestRect.Width() / MaxTilesX;	const int32 TileHeight = DestRect.Height() / MaxTilesY;	int32 CurrentTileIndex = 0; 	for (TArray<TileData>::TConstIterator It = Tiles.CreateConstIterator(); It; ++It, ++CurrentTileIndex)	{		FRenderingCompositeOutputRef Tile = It->Source;		if (Tile.IsValid())		{			FTextureRHIRef Texture = Tile.GetOutput()->PooledRenderTarget->GetRenderTargetItem().TargetableTexture;			int32 TileX = CurrentTileIndex % MaxTilesX;			int32 TileY = CurrentTileIndex / MaxTilesX;			PixelShader->SetSourceTexture(Texture);			DrawRectangle(				TileX * TileWidth, TileY * TileHeight,				TileWidth, TileHeight,				SrcRect.Min.X, SrcRect.Min.Y,				SrcRect.Width(), SrcRect.Height(),				DestRect.Size(),				SrcSize,				EDRF_Default);			Labels.Add(LabelRecord());			Labels.Last().Label = It->Name;			Labels.Last().LocationX = 8 + TileX * TileWidth;			Labels.Last().LocationY = (TileY + 1) * TileHeight - 19;		}	}	// Draw tile labels	// this is a helper class for FCanvas to be able to get screen size	class FRenderTargetTemp : public FRenderTarget	{	public:		const FSceneView& View;		const FTexture2DRHIRef Texture;		FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)			: View(InView), Texture(InTexture)		{		}		virtual FIntPoint GetSizeXY() const		{			return View.ViewRect.Size();		};		virtual const FTexture2DRHIRef& GetRenderTargetTexture() const		{			return Texture;		}	} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);	FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime);	FLinearColor LabelColor(1, 1, 0);	for (auto It = Labels.CreateConstIterator(); It; ++It)	{		Canvas.DrawShadowedString(It->LocationX, It->LocationY, *It->Label, GetStatsFont(), LabelColor);	}	Canvas.Flush();	RHICopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,


示例18: window

// The start of the Applicationint App::start(const std::vector<std::string> &args){	quit = false;    clan::SlotContainer cc;	DisplayWindowDescription win_desc;	win_desc.set_allow_resize(true);	win_desc.set_title("Font Example Application");	win_desc.set_size(Size( 1000, 700 ), false);	DisplayWindow window(win_desc);    cc.connect(window.sig_window_close(), std::function<void()>(this, &App::on_window_close));    cc.connect(window.get_ic().get_keyboard().sig_key_up(), std::function<void(const clan::InputEvent&)>(this, &App::on_input_up));	resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("Resources/resources.xml"));	std::string theme;	if (FileHelp::file_exists("../../../Resources/GUIThemeAero/theme.css"))		theme = "../../../Resources/GUIThemeAero";	else if (FileHelp::file_exists("../../../Resources/GUIThemeBasic/theme.css"))		theme = "../../../Resources/GUIThemeBasic";	else		throw Exception("No themes found");	gui_manager = GUIWindowManagerTexture(window);	GUIManager gui(gui_manager, theme);	canvas = Canvas(window);	GUITopLevelDescription gui_desc;	gui_desc.set_title("Options");	gui_desc.set_position(Rect(10, 10, 250, 400), false);	GUIComponent gui_window(&gui, gui_desc, "window");	int offset_x = 10;	int offset_y = 8;	int width = 200;	int height = 20;	const int gap = 26;	PushButton button_class_system(&gui_window);	button_class_system.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));	button_class_system.func_clicked() = bind_member(this, &App::on_button_clicked_class_system);	button_class_system.set_text("Class: System");	offset_y += gap;	PushButton button_class_sprite(&gui_window);	button_class_sprite.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));	button_class_sprite.func_clicked() = bind_member(this, &App::on_button_clicked_class_sprite);	button_class_sprite.set_text("Class: Sprite");	offset_y += gap;	PushButton button_typeface_tahoma(&gui_window);	button_typeface_tahoma_ptr = &button_typeface_tahoma;	button_typeface_tahoma.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));	button_typeface_tahoma.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_tahoma);	button_typeface_tahoma.set_text("Typeface: Tahoma");	offset_y += gap;	PushButton button_typeface_sans(&gui_window);	button_typeface_sans_ptr = &button_typeface_sans;	button_typeface_sans.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));	button_typeface_sans.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_sans);	button_typeface_sans.set_text("Typeface: Microsoft Sans Serif");	offset_y += gap;	PushButton button_typeface_bitstream(&gui_window);	button_typeface_bitstream_ptr = &button_typeface_bitstream;	button_typeface_bitstream.set_geometry(Rect(offset_x, offset_y, offset_x + width, offset_y + height));	button_typeface_bitstream.func_clicked() = bind_member(this, &App::on_button_clicked_typeface_bitstream);	button_typeface_bitstream.set_text("Typeface: Bitstream Vera Sans");	offset_y += gap;	CheckBox checkbox1(&gui_window);	checkbox1.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));	checkbox1.func_state_changed() = bind_member(this, &App::on_checkbox_state_underline);	checkbox1.set_text("Underline");	CheckBox checkbox2(&gui_window);	checkbox2.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));	checkbox2.func_state_changed() = bind_member(this, &App::on_checkbox_state_strikeout);	checkbox2.set_text("Strikeout");	offset_y += gap;	CheckBox checkbox3(&gui_window);	checkbox3.set_geometry(Rect(offset_x, offset_y, offset_x + 80, offset_y + height));	checkbox3.func_state_changed() = bind_member(this, &App::on_checkbox_state_italic);	checkbox3.set_text("Italic");	CheckBox checkbox4(&gui_window);	checkbox4.set_checked(true);	checkbox4.set_geometry(Rect(offset_x+100, offset_y, offset_x + 180, offset_y + height));	checkbox4.func_state_changed() = bind_member(this, &App::on_checkbox_state_antialias);	checkbox4.set_text("Anti Alias");	offset_y += gap;	CheckBox checkbox5(&gui_window);	checkbox5.set_checked(true);	checkbox5.set_geometry(Rect(offset_x, offset_y, offset_x + 120, offset_y + height));//.........这里部分代码省略.........
开发者ID:punkkeks,项目名称:ClanLib,代码行数:101,


示例19: flogger

Win32_App::Win32_App(){	SourceDLLName = "Game.dll";	//GameCode = Win32_LoadGameCode(SourceDLLName);#ifdef _DEBUG	// Дебажная консоль	FileLogger flogger("debug.log");	log_event("SYSTEM", "Logger initialized");#endif	try	{		// We support all display targets, in order listed here#ifdef WIN32		D3DTarget::enable();#endif		OpenGLTarget::enable();	}	catch (Exception exception)	{		// Create a console window for text-output if not available		ConsoleWindow console("Console", 80, 160);		Console::write_line("Exception caught: " + exception.get_message_and_stack_trace());		console.display_close_message();		quit = true;	}	// TODO: сохранять настройки графики	fullscreen = 0;	// TODO: Масштабировать окно	InitScreenSize = Sizef(1024.0f, 768.0f);	ScreenSize = InitScreenSize;	DisplayWindowDescription window_description;	window_description.set_title("Robot Game");	window_description.set_size(ScreenSize, true);	window_description.set_allow_resize(true);	//window_description.set_type(WindowType::tool);	window = DisplayWindow(window_description);	canvas = Canvas(window);	// Подключим коллбэки на слоты пользовательского ввода	keyboard = window.get_ic().get_keyboard();	sc.connect(window.sig_window_close(), bind_member(this, &Win32_App::Win32_OnWindowClose));	sc.connect(window.get_ic().get_keyboard().sig_key_up(), bind_member(this, &Win32_App::Win32_OnKeyUp));	sc.connect(window.get_ic().get_keyboard().sig_key_down(), bind_member(this, &Win32_App::Win32_OnKeyDown));	sc.connect(window.get_ic().get_mouse().sig_key_down(), bind_member(this, &Win32_App::Win32_OnMouseDown));	// Sound	SoundOutput sound_output(48000);/*	SoundBuffer sbuffer("cheer1.ogg");	sbuffer.play();*/	// Game memory	LPVOID BaseAddress = 0;	GameMemory.PermanentStorageSize = Megabytes(256);	GameMemory.TransientStorageSize = Megabytes(256);	size_t TotalStorageSize = (size_t)(GameMemory.PermanentStorageSize + GameMemory.TransientStorageSize);	GameMemory.PermanentStorage = VirtualAlloc(BaseAddress, TotalStorageSize, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);	GameMemory.TransientStorage = ((uint8*)GameMemory.PermanentStorage + GameMemory.PermanentStorageSize);	// Game state	GameState = (game_state*)GameMemory.PermanentStorage;	*GameState = {};	GameState->ScreenSize = ScreenSize;	// Resources	//OpenGLTarget::set_current();	GameState->game_resources = clan::XMLResourceManager::create(clan::XMLResourceDocument("sprites.xml"));	GameState->LoadGameSpriteFromImage = &LoadGameSpriteFromImage;	GameState->LoadGameSpriteFromResource = &LoadGameSpriteFromResource;	GameState->AddGameSpriteFrameFromImage = &AddGameSpriteFrameFromImage;	// Main display buffers	//GameState->MainDisplayBuffer = PixelBuffer(1024, 768, TextureFormat::tf_rgba8, GameMemory.TransientStorage);	// Win32 Timings	CanSleepSafe = (timeBeginPeriod(1) == TIMERR_NOERROR);	QueryPerformanceFrequency(&PerfCounterFrequencyQ);	PerfCounterFrequency = PerfCounterFrequencyQ.QuadPart;	QueryPerformanceCounter(&LastCounter);	LastCycleCount = __rdtsc();	game_time.reset();	//console.display_close_message();	//timeEndPeriod(1);}
开发者ID:MeiHouwang,项目名称:RoboGame,代码行数:98,


示例20: SCOPED_DRAW_EVENT

void FRCPassPostProcessTestImage::Process(FRenderingCompositePassContext& Context){	SCOPED_DRAW_EVENT(Context.RHICmdList, TestImage, DEC_SCENE_ITEMS);	const FSceneView& View = Context.View;	const FSceneViewFamily& ViewFamily = *(View.Family);		FIntRect SrcRect = View.ViewRect;	FIntRect DestRect = View.ViewRect;	const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);	// Set the view family's render target/viewport.	SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());	Context.SetViewportAndCallRHI(DestRect);	// set the state	Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());	Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());	Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());	TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());	TShaderMapRef<FPostProcessTestImagePS> PixelShader(Context.GetShaderMap());	static FGlobalBoundShaderState BoundShaderState;		SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);	PixelShader->SetPS(Context);	// Draw a quad mapping scene color to the view's render target	DrawRectangle(		Context.RHICmdList,		0, 0,		DestRect.Width(), DestRect.Height(),		SrcRect.Min.X, SrcRect.Min.Y,		SrcRect.Width(), SrcRect.Height(),		DestRect.Size(),		GSceneRenderTargets.GetBufferSizeXY(),		*VertexShader,		EDRF_UseTriangleOptimization);	{		// this is a helper class for FCanvas to be able to get screen size		class FRenderTargetTemp : public FRenderTarget		{		public:			const FSceneView& View;			const FTexture2DRHIRef Texture;			FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)				: View(InView), Texture(InTexture)			{			}			virtual FIntPoint GetSizeXY() const			{				return View.ViewRect.Size();			};			virtual const FTexture2DRHIRef& GetRenderTargetTexture() const			{				return Texture;			}		} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);		FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, Context.GetFeatureLevel());		float X = 30;		float Y = 8;		const float YStep = 14;		const float ColumnWidth = 250;		FString Line;		Line = FString::Printf(TEXT("Top bars:"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Moving bars using FrameTime"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Black and white raster, Pixel sized, Watch for Moire pattern"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Black and white raster, 2x2 block sized"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("Bottom bars:"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   8 bars near white, 4 right bars should appear as one (HDTV)"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   8 bars near black, 4 left bars should appear as one (HDTV)"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Linear Greyscale in sRGB from 0 to 255"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("Color bars:"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Red, Green, Blue"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("Outside:"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("   Moving bars using FrameNumber, Tearing without VSync"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Line = FString::Printf(TEXT("Circles:"));		Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));//.........这里部分代码省略.........
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:101,


示例21: SCOPED_DRAW_EVENT

void FRCPassPostProcessVisualizeHDR::Process(FRenderingCompositePassContext& Context){	SCOPED_DRAW_EVENT(PostProcessVisualizeHDR, DEC_SCENE_ITEMS);	const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);	if(!InputDesc)	{		// input is not hooked up correctly		return;	}	const FSceneView& View = Context.View;	const FSceneViewFamily& ViewFamily = *(View.Family);		FIntRect SrcRect = View.ViewRect;	FIntRect DestRect = View.ViewRect;	FIntPoint SrcSize = InputDesc->Extent;	const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);	// Set the view family's render target/viewport.	RHISetRenderTarget(DestRenderTarget.TargetableTexture, FTextureRHIRef());		Context.SetViewportAndCallRHI(DestRect);	// set the state	RHISetBlendState(TStaticBlendState<>::GetRHI());	RHISetRasterizerState(TStaticRasterizerState<>::GetRHI());	RHISetDepthStencilState(TStaticDepthStencilState<false,CF_Always>::GetRHI());	TShaderMapRef<FPostProcessVS> VertexShader(GetGlobalShaderMap());	TShaderMapRef<FPostProcessVisualizeHDRPS> PixelShader(GetGlobalShaderMap());	static FGlobalBoundShaderState BoundShaderState;	SetGlobalBoundShaderState(BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);	PixelShader->SetPS(Context);	// Draw a quad mapping scene color to the view's render target	DrawRectangle(		DestRect.Min.X, DestRect.Min.Y,		DestRect.Width(), DestRect.Height(),		SrcRect.Min.X, SrcRect.Min.Y,		SrcRect.Width(), SrcRect.Height(),		DestRect.Size(),		SrcSize,		EDRF_UseTriangleOptimization);	// this is a helper class for FCanvas to be able to get screen size	class FRenderTargetTemp : public FRenderTarget	{	public:		const FSceneView& View;		const FTexture2DRHIRef Texture;		FRenderTargetTemp(const FSceneView& InView, const FTexture2DRHIRef InTexture)			: View(InView), Texture(InTexture)		{		}		virtual FIntPoint GetSizeXY() const		{			return View.ViewRect.Size();		};		virtual const FTexture2DRHIRef& GetRenderTargetTexture() const		{			return Texture;		}	} TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);	FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime);	float X = 30;	float Y = 8;	const float YStep = 14;	const float ColumnWidth = 250;	FString Line;	Line = FString::Printf(TEXT("HDR Histogram (Logarithmic, max of RGB)"));	Canvas.DrawShadowedString( X, Y += YStep, *Line, GetStatsFont(), FLinearColor(1, 1, 1));		Y += 160;	float MinX = 64 + 10;	float MaxY = View.ViewRect.Max.Y - 64;	float SizeX = View.ViewRect.Size().X - 64 * 2 - 20;	for(uint32 i = 0; i <= 4; ++i)	{		int XAdd = (int)(i * SizeX / 4);		float HistogramPosition =  i / 4.0f;		float LogValue = FMath::Lerp(View.FinalPostProcessSettings.HistogramLogMin, View.FinalPostProcessSettings.HistogramLogMax, HistogramPosition);		Line = FString::Printf(TEXT("%.2g"), LogValue);		Canvas.DrawShadowedString( MinX + XAdd - 5, MaxY, *Line, GetStatsFont(), FLinearColor(1, 0.3f, 0.3f));		Line = LogToString(LogValue);		Canvas.DrawShadowedString( MinX + XAdd - 5, MaxY + YStep, *Line, GetStatsFont(), FLinearColor(0.3f, 0.3f, 1));	}	Y += 3 * YStep;//.........这里部分代码省略.........
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:101,


示例22: RectToPoint

	/* ARGSUSED */static doubleRectToPoint(    Tk_Canvas canvas,		/* Canvas containing item. */    Tk_Item *itemPtr,		/* Item to check against point. */    double *pointPtr)		/* Pointer to x and y coordinates. */{    RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;    double xDiff, yDiff, x1, y1, x2, y2, inc, tmp;    double width;    Tk_State state = itemPtr->state;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    width = rectPtr->outline.width;    if (Canvas(canvas)->currentItemPtr == itemPtr) {	if (rectPtr->outline.activeWidth>width) {	    width = rectPtr->outline.activeWidth;	}    } else if (state == TK_STATE_DISABLED) {	if (rectPtr->outline.disabledWidth>0) {	    width = rectPtr->outline.disabledWidth;	}    }    /*     * Generate a new larger rectangle that includes the border width, if     * there is one.     */    x1 = rectPtr->bbox[0];    y1 = rectPtr->bbox[1];    x2 = rectPtr->bbox[2];    y2 = rectPtr->bbox[3];    if (rectPtr->outline.gc != None) {	inc = width/2.0;	x1 -= inc;	y1 -= inc;	x2 += inc;	y2 += inc;    }    /*     * If the point is inside the rectangle, handle specially: distance is 0     * if rectangle is filled, otherwise compute distance to nearest edge of     * rectangle and subtract width of edge.     */    if ((pointPtr[0] >= x1) && (pointPtr[0] < x2)	    && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) {	if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) {	    return 0.0;	}	xDiff = pointPtr[0] - x1;	tmp = x2 - pointPtr[0];	if (tmp < xDiff) {	    xDiff = tmp;	}	yDiff = pointPtr[1] - y1;	tmp = y2 - pointPtr[1];	if (tmp < yDiff) {	    yDiff = tmp;	}	if (yDiff < xDiff) {	    xDiff = yDiff;	}	xDiff -= width;	if (xDiff < 0.0) {	    return 0.0;	}	return xDiff;    }    /*     * Point is outside rectangle.     */    if (pointPtr[0] < x1) {	xDiff = x1 - pointPtr[0];    } else if (pointPtr[0] > x2)  {	xDiff = pointPtr[0] - x2;    } else {	xDiff = 0;    }    if (pointPtr[1] < y1) {	yDiff = y1 - pointPtr[1];    } else if (pointPtr[1] > y2)  {	yDiff = pointPtr[1] - y2;    } else {	yDiff = 0;    }    return hypot(xDiff, yDiff);}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:97,


示例23: DisplayRectOval

static voidDisplayRectOval(    Tk_Canvas canvas,		/* Canvas that contains item. */    Tk_Item *itemPtr,		/* Item to be displayed. */    Display *display,		/* Display on which to draw item. */    Drawable drawable,		/* Pixmap or window in which to draw item. */    int x, int y, int width, int height)				/* Describes region of canvas that must be				 * redisplayed (not used). */{    RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;    short x1, y1, x2, y2;    Pixmap fillStipple;    Tk_State state = itemPtr->state;    /*     * Compute the screen coordinates of the bounding box for the item. Make     * sure that the bbox is at least one pixel large, since some X servers     * will die if it isn't.     */    Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[0],rectOvalPtr->bbox[1],	    &x1, &y1);    Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[2],rectOvalPtr->bbox[3],	    &x2, &y2);    if (x2 <= x1) {	x2 = x1+1;    }    if (y2 <= y1) {	y2 = y1+1;    }    /*     * Display filled part first (if wanted), then outline. If we're     * stippling, then modify the stipple offset in the GC. Be sure to reset     * the offset when done, since the GC is supposed to be read-only.     */    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    fillStipple = rectOvalPtr->fillStipple;    if (Canvas(canvas)->currentItemPtr == (Tk_Item *) rectOvalPtr) {	if (rectOvalPtr->activeFillStipple != None) {	    fillStipple = rectOvalPtr->activeFillStipple;	}    } else if (state == TK_STATE_DISABLED) {	if (rectOvalPtr->disabledFillStipple != None) {	    fillStipple = rectOvalPtr->disabledFillStipple;	}    }    if (rectOvalPtr->fillGC != None) {	if (fillStipple != None) {	    Tk_TSOffset *tsoffset;	    int w = 0, h = 0;	    tsoffset = &rectOvalPtr->tsoffset;	    if (tsoffset) {		int flags = tsoffset->flags;		if (flags & (TK_OFFSET_CENTER|TK_OFFSET_MIDDLE)) {		    Tk_SizeOfBitmap(display, fillStipple, &w, &h);		    if (flags & TK_OFFSET_CENTER) {			w /= 2;		    } else {			w = 0;		    }		    if (flags & TK_OFFSET_MIDDLE) {			h /= 2;		    } else {			h = 0;		    }		}		tsoffset->xoffset -= w;		tsoffset->yoffset -= h;	    }	    Tk_CanvasSetOffset(canvas, rectOvalPtr->fillGC, tsoffset);	    if (tsoffset) {		tsoffset->xoffset += w;		tsoffset->yoffset += h;	    }	}	if (rectOvalPtr->header.typePtr == &tkRectangleType) {	    XFillRectangle(display, drawable, rectOvalPtr->fillGC,		    x1, y1, (unsigned int) (x2-x1), (unsigned int) (y2-y1));	} else {	    XFillArc(display, drawable, rectOvalPtr->fillGC,		    x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1),		    0, 360*64);	}	if (fillStipple != None) {	    XSetTSOrigin(display, rectOvalPtr->fillGC, 0, 0);	}    }    if (rectOvalPtr->outline.gc != None) {	Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline));	if (rectOvalPtr->header.typePtr == &tkRectangleType) {	    XDrawRectangle(display, drawable, rectOvalPtr->outline.gc,//.........这里部分代码省略.........
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:101,


示例24: ComputeRectOvalBbox

	/* ARGSUSED */static voidComputeRectOvalBbox(    Tk_Canvas canvas,		/* Canvas that contains item. */    RectOvalItem *rectOvalPtr)	/* Item whose bbox is to be recomputed. */{    int bloat, tmp;    double dtmp, width;    Tk_State state = rectOvalPtr->header.state;    if (state == TK_STATE_NULL) {	state = Canvas(canvas)->canvas_state;    }    width = rectOvalPtr->outline.width;    if (state == TK_STATE_HIDDEN) {	rectOvalPtr->header.x1 = rectOvalPtr->header.y1 =	rectOvalPtr->header.x2 = rectOvalPtr->header.y2 = -1;	return;    }    if (Canvas(canvas)->currentItemPtr == (Tk_Item *) rectOvalPtr) {	if (rectOvalPtr->outline.activeWidth>width) {	    width = rectOvalPtr->outline.activeWidth;	}    } else if (state == TK_STATE_DISABLED) {	if (rectOvalPtr->outline.disabledWidth>0) {	    width = rectOvalPtr->outline.disabledWidth;	}    }    /*     * Make sure that the first coordinates are the lowest ones.     */    if (rectOvalPtr->bbox[1] > rectOvalPtr->bbox[3]) {	double tmpY = rectOvalPtr->bbox[3];	rectOvalPtr->bbox[3] = rectOvalPtr->bbox[1];	rectOvalPtr->bbox[1] = tmpY;    }    if (rectOvalPtr->bbox[0] > rectOvalPtr->bbox[2]) {	double tmpX = rectOvalPtr->bbox[2];	rectOvalPtr->bbox[2] = rectOvalPtr->bbox[0];	rectOvalPtr->bbox[0] = tmpX;    }    if (rectOvalPtr->outline.gc == None) {	/*	 * The Win32 switch was added for 8.3 to solve a problem with ovals	 * leaving traces on bottom and right of 1 pixel. This may not be the	 * correct place to solve it, but it works.	 */#ifdef _WIN32	bloat = 1;#else	bloat = 0;#endif /* _WIN32 */    } else {#ifdef MAC_OSX_TK	/*	 * Mac OS X CoreGraphics needs correct rounding here otherwise it will	 * draw outside the bounding box. Probably correct on other platforms	 * as well?	 */	bloat = (int) (width+1.5)/2;#else	bloat = (int) (width+1)/2;#endif /* MAC_OSX_TK */    }    /*     * Special note: the rectangle is always drawn at least 1x1 in size, so     * round up the upper coordinates to be at least 1 unit greater than the     * lower ones.     */    tmp = (int) ((rectOvalPtr->bbox[0] >= 0) ? rectOvalPtr->bbox[0] + .5	    : rectOvalPtr->bbox[0] - .5);    rectOvalPtr->header.x1 = tmp - bloat;    tmp = (int) ((rectOvalPtr->bbox[1] >= 0) ? rectOvalPtr->bbox[1] + .5	    : rectOvalPtr->bbox[1] - .5);    rectOvalPtr->header.y1 = tmp - bloat;    dtmp = rectOvalPtr->bbox[2];    if (dtmp < (rectOvalPtr->bbox[0] + 1)) {	dtmp = rectOvalPtr->bbox[0] + 1;    }    tmp = (int) ((dtmp >= 0) ? dtmp + .5 : dtmp - .5);    rectOvalPtr->header.x2 = tmp + bloat;    dtmp = rectOvalPtr->bbox[3];    if (dtmp < (rectOvalPtr->bbox[1] + 1)) {	dtmp = rectOvalPtr->bbox[1] + 1;    }    tmp = (int) ((dtmp >= 0) ? dtmp + .5 : dtmp - .5);    rectOvalPtr->header.y2 = tmp + bloat;}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:98,



注:本文中的Canvas函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CapabilitiesAdd函数代码示例
C++ CanteraError函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。