void VoxelEditor::brushRange(){
	if (_currentBrush != NULL){
		delete _currentBrush;
		_currentBrush = NULL;
		printf("Brush cleared\n");
	}
	else if (_selectedFirstBlock && _selectedSecondBlock && _state == 's') {
		makeBrush(_selectedX1, _selectedY1, _selectedZ1, _selectedX2, _selectedY2, _selectedZ2);
	}
}
示例#2
0
文件: draw.c 项目: trigrass2/libui
void uiDrawFill(uiDrawContext *c, uiDrawPath *p, uiDrawBrush *b)
{
	ID2D1Brush *brush;
	ID2D1Layer *cliplayer;

	brush = makeBrush(b, c->rt);
	cliplayer = applyClip(c);
	ID2D1RenderTarget_FillGeometry(c->rt,
		(ID2D1Geometry *) (p->path),
		brush,
		NULL);
	unapplyClip(c, cliplayer);
	ID2D1Brush_Release(brush);
}
示例#3
0
文件: draw.c 项目: trigrass2/libui
void uiDrawStroke(uiDrawContext *c, uiDrawPath *p, uiDrawBrush *b, uiDrawStrokeParams *sp)
{
	ID2D1Brush *brush;
	ID2D1StrokeStyle *style;
	D2D1_STROKE_STYLE_PROPERTIES dsp;
	FLOAT *dashes;
	size_t i;
	ID2D1Layer *cliplayer;
	HRESULT hr;

	brush = makeBrush(b, c->rt);

	ZeroMemory(&dsp, sizeof (D2D1_STROKE_STYLE_PROPERTIES));
	switch (sp->Cap) {
	case uiDrawLineCapFlat:
		dsp.startCap = D2D1_CAP_STYLE_FLAT;
		dsp.endCap = D2D1_CAP_STYLE_FLAT;
		dsp.dashCap = D2D1_CAP_STYLE_FLAT;
		break;
	case uiDrawLineCapRound:
		dsp.startCap = D2D1_CAP_STYLE_ROUND;
		dsp.endCap = D2D1_CAP_STYLE_ROUND;
		dsp.dashCap = D2D1_CAP_STYLE_ROUND;
		break;
	case uiDrawLineCapSquare:
		dsp.startCap = D2D1_CAP_STYLE_SQUARE;
		dsp.endCap = D2D1_CAP_STYLE_SQUARE;
		dsp.dashCap = D2D1_CAP_STYLE_SQUARE;
		break;
	}
	switch (sp->Join) {
	case uiDrawLineJoinMiter:
		dsp.lineJoin = D2D1_LINE_JOIN_MITER_OR_BEVEL;
		dsp.miterLimit = sp->MiterLimit;
		break;
	case uiDrawLineJoinRound:
		dsp.lineJoin = D2D1_LINE_JOIN_ROUND;
		break;
	case uiDrawLineJoinBevel:
		dsp.lineJoin = D2D1_LINE_JOIN_BEVEL;
		break;
	}
	dsp.dashStyle = D2D1_DASH_STYLE_SOLID;
	dashes = NULL;
	// note that dash widths and the dash phase are scaled up by the thickness by Direct2D
	// TODO be sure to formally document this
	if (sp->NumDashes != 0) {
		dsp.dashStyle = D2D1_DASH_STYLE_CUSTOM;
		dashes = (FLOAT *) uiAlloc(sp->NumDashes * sizeof (FLOAT), "FLOAT[]");
		for (i = 0; i < sp->NumDashes; i++)
			dashes[i] = sp->Dashes[i] / sp->Thickness;
	}
	dsp.dashOffset = sp->DashPhase / sp->Thickness;
	hr = ID2D1Factory_CreateStrokeStyle(d2dfactory,
		&dsp,
		dashes,
		sp->NumDashes,
		&style);
	if (hr != S_OK)
		logHRESULT("error creating stroke style in uiDrawStroke()", hr);
	if (sp->NumDashes != 0)
		uiFree(dashes);

	cliplayer = applyClip(c);
	ID2D1RenderTarget_DrawGeometry(c->rt,
		(ID2D1Geometry *) (p->path),
		brush,
		sp->Thickness,
		style);
	unapplyClip(c, cliplayer);

	ID2D1StrokeStyle_Release(style);
	ID2D1Brush_Release(brush);
}