Пример #1
0
func (s *UtilsColorSuite) TestHexToRGBBlue() {
	r, g, b := utils.HexToRGB("0000ff")

	assert.Equal(s.T(), 0, r)
	assert.Equal(s.T(), 0, g)
	assert.Equal(s.T(), 255, b)
}
Пример #2
0
func (s *UtilsColorSuite) TestHexToRGBBlack() {
	r, g, b := utils.HexToRGB("000000")

	assert.Equal(s.T(), 0, r)
	assert.Equal(s.T(), 0, g)
	assert.Equal(s.T(), 0, b)
}
Пример #3
0
func (s *UtilsColorSuite) TestHexToRGBWhite() {
	r, g, b := utils.HexToRGB("ffffff")

	assert.Equal(s.T(), 255, r)
	assert.Equal(s.T(), 255, g)
	assert.Equal(s.T(), 255, b)
}
Пример #4
0
// Register will register a font to the document for later usage.
func (f FontType) Register(doc documents.Document) {
	if f.Color != "" {
		doc.SetTextColor(utils.HexToRGB(f.Color))
	}

	if f.Type != "" && f.Size != 0 {
		doc.SetFont(f.Type, f.Weight, f.Size)
	}
}
Пример #5
0
// Parse will draw the rectangle on the document with the given attributes.
func (b *Rectangle) Parse(doc documents.Document) {
	if b.Rotation != 0 {
		doc.TransformBegin()
		fmt.Println(b.Position.X + b.Width/2)
		fmt.Println(b.Position.Y + b.Height/2)
		doc.TransformRotate(b.Rotation, b.Position.X+b.Width/2, b.Position.Y+b.Height/2)
	}

	doc.SetFillColor(utils.HexToRGB(b.Color))
	doc.Rect(b.Position.X, b.Position.Y, b.Width, b.Height, "F")

	if b.Rotation != 0 {
		doc.TransformEnd()
	}
}
Пример #6
0
// Parse will draw the line on the document for the given position and color.
func (b *Line) Parse(doc documents.Document) {
	doc.SetDrawColor(utils.HexToRGB(b.Color))
	doc.Line(b.Position.X, b.Position.Y, b.Position.X+b.W, b.Position.Y+b.H)
}