TSharedRef< ISlateRun > FImageDecorator::Create( const FTextRunParseResults& RunInfo, const FString& OriginalText, const TSharedRef< FString >& InOutModelText, const ISlateStyle* Style )
{
	const FTextRange* const BrushNameRange = RunInfo.MetaData.Find( TEXT("src") );

	FTextRange ModelRange;
	ModelRange.BeginIndex = InOutModelText->Len();
	*InOutModelText += TEXT('\x200B'); // Zero-Width Breaking Space
	ModelRange.EndIndex = InOutModelText->Len();

	if ( BrushNameRange != NULL )
	{
		const FString BrushNameString = OriginalText.Mid(BrushNameRange->BeginIndex, BrushNameRange->EndIndex - BrushNameRange->BeginIndex);
		if ( OverrideStyle != NULL )
		{
			Style = OverrideStyle;
		}

		FName BrushName( *BrushNameString );
		if ( Style->HasWidgetStyle< FInlineTextImageStyle >( BrushName ) )
		{
			const FInlineTextImageStyle& ImageStyle = Style->GetWidgetStyle< FInlineTextImageStyle >( BrushName );
			return FSlateImageRun::Create( InOutModelText, &ImageStyle.Image, ImageStyle.Baseline, ModelRange );
		}

		return FSlateImageRun::Create( InOutModelText, Style->GetBrush( BrushName ), 0, ModelRange );
	}

	const FInlineTextImageStyle& ImageStyle = FInlineTextImageStyle::GetDefault();
	return FSlateImageRun::Create( InOutModelText, &ImageStyle.Image, ImageStyle.Baseline, ModelRange );
}
示例#2
0
void LineBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("LineBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_LINES);

	float radius = ((float)dlg->getSize() / 2);
	Point point = { target.x, target.y };

	int counter = strcmp(BrushName(), "Scattered Lines") != 0 ? 1 : (float)dlg->getSize();

	for (int i = 0; i < counter; i++) {
		SetColor(point);

		glVertex2d(point.x - radius, point.y);
		glVertex2d(point.x + radius, point.y);

		if (counter != 1) {
			do {
				point = { Math::rand_range(target.x - radius, target.x + radius), Math::rand_range(target.y - radius, target.y + radius) };
			} while (fabs(Math::distance(point.x, point.y, target.x, target.y) - radius) > 0.05f);
		}
	}

	glEnd();
}
示例#3
0
void CircleBrush::BrushMove(const Point source, const Point target)
{
	ImpressionistDoc* pDoc = GetDocument();
	ImpressionistUI* dlg = pDoc->m_pUI;

	if (pDoc == NULL) {
		printf("CircleBrush::BrushMove  document is NULL\n");
		return;
	}

	glBegin(GL_TRIANGLE_FAN);
	
	float theta, pos_x, pos_y = 0.0f;
	float radius = ((float)dlg->getSize() / 2);
	Point center = { target.x, target.y };
	Point _center_;
	int counter = strcmp(BrushName(), "Scattered Circles")!=0 ? 1 : 3;

	for (int i = 0; i < counter; i++) {
		
		SetColor(center);
		
		for (int j = 0; j < 360; j++)
		{
			theta = 2 * M_PI * j / 360;
			pos_x = center.x + cos(theta) * radius;
			pos_y = center.y + sin(theta) * radius;
			glVertex2f(pos_x, pos_y);
		}

		if (counter!=1) {
			do {
				_center_ = { Math::rand_range(center.x - radius, center.x + radius), Math::rand_range(center.y - radius, center.y + radius) };
			} while (fabs(Math::distance(center.x, center.y, _center_.x, _center_.y) - radius) > 0.05f);
			center = _center_;
		}
	}

	glEnd();
}