Esempio n. 1
0
func RGBColorMulNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor {
	var val = uint32(n.Value)
	var r = c.R * val
	var g = c.G * val
	var b = c.B * val
	return ast.NewRGBColor(r, g, b, nil)
}
Esempio n. 2
0
func RGBColorDivNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor {
	var val = n.Value
	var r = math.Floor(float64(c.R) / val)
	var g = math.Floor(float64(c.G) / val)
	var b = math.Floor(float64(c.B) / val)
	return ast.NewRGBColor(uint32(r), uint32(g), uint32(b), nil)
}
Esempio n. 3
0
func RGBColorSubNumber(c *ast.RGBColor, n *ast.Number) *ast.RGBColor {
	var val = uint32(n.Value)
	var r = uintsub(c.R, val)
	var g = uintsub(c.G, val)
	var b = uintsub(c.B, val)
	return ast.NewRGBColor(r, g, b, nil)
}
Esempio n. 4
0
func TestComputeRGBColorWithNumber(t *testing.T) {
	val := Compute(ast.NewOp(ast.T_PLUS), ast.NewRGBColor(10, 10, 10, nil), ast.NewNumber(3, nil, nil))
	c, ok := val.(*ast.RGBColor)
	assert.True(t, ok)
	assert.Equal(t, "rgb(13, 13, 13)", c.String())
}