update tests for PaintSweepGradient
This commit is contained in:
parent
93c23eaaf7
commit
a7d145f027
@ -385,6 +385,29 @@ def test_buildPaintRadialGradient():
|
|||||||
assert gradient.ColorLine.ColorStop == color_stops
|
assert gradient.ColorLine.ColorStop == color_stops
|
||||||
|
|
||||||
|
|
||||||
|
def test_buildPaintSweepGradient():
|
||||||
|
layerBuilder = LayerV1ListBuilder()
|
||||||
|
paint = layerBuilder.buildPaintSweepGradient(
|
||||||
|
colorLine=builder.buildColorLine(
|
||||||
|
stops=[
|
||||||
|
builder.buildColorStop(0.0, 0),
|
||||||
|
builder.buildColorStop(0.5, 1),
|
||||||
|
builder.buildColorStop(1.0, 2, alpha=0.8),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
centerX=127,
|
||||||
|
centerY=129,
|
||||||
|
startAngle=15,
|
||||||
|
endAngle=42,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert paint.Format == ot.Paint.Format.PaintSweepGradient
|
||||||
|
assert paint.centerX.value == 127
|
||||||
|
assert paint.centerY.value == 129
|
||||||
|
assert paint.startAngle.value == 15
|
||||||
|
assert paint.endAngle.value == 42
|
||||||
|
|
||||||
|
|
||||||
def test_buildPaintGlyph_Solid():
|
def test_buildPaintGlyph_Solid():
|
||||||
layerBuilder = LayerV1ListBuilder()
|
layerBuilder = LayerV1ListBuilder()
|
||||||
layer = layerBuilder.buildPaintGlyph("a", 2)
|
layer = layerBuilder.buildPaintGlyph("a", 2)
|
||||||
|
@ -106,7 +106,7 @@ COLR_V1_SAMPLE = (
|
|||||||
(b"\x00\x00\x00 ", "Offset to LayerRecordArray from beginning of table (32)"),
|
(b"\x00\x00\x00 ", "Offset to LayerRecordArray from beginning of table (32)"),
|
||||||
(b"\x00\x03", "LayerRecordCount (3)"),
|
(b"\x00\x03", "LayerRecordCount (3)"),
|
||||||
(b"\x00\x00\x00,", "Offset to BaseGlyphV1List from beginning of table (44)"),
|
(b"\x00\x00\x00,", "Offset to BaseGlyphV1List from beginning of table (44)"),
|
||||||
(b"\x00\x00\x00\x81", "Offset to LayerV1List from beginning of table (129)"),
|
(b"\x00\x00\x00\xcc", "Offset to LayerV1List from beginning of table (204)"),
|
||||||
(b"\x00\x00\x00\x00", "Offset to VarStore (NULL)"),
|
(b"\x00\x00\x00\x00", "Offset to VarStore (NULL)"),
|
||||||
(b"\x00\x06", "BaseGlyphRecord[0].BaseGlyph (6)"),
|
(b"\x00\x06", "BaseGlyphRecord[0].BaseGlyph (6)"),
|
||||||
(b"\x00\x00", "BaseGlyphRecord[0].FirstLayerIndex (0)"),
|
(b"\x00\x00", "BaseGlyphRecord[0].FirstLayerIndex (0)"),
|
||||||
@ -117,20 +117,28 @@ COLR_V1_SAMPLE = (
|
|||||||
(b"\x00\x01", "LayerRecord[1].PaletteIndex (1)"),
|
(b"\x00\x01", "LayerRecord[1].PaletteIndex (1)"),
|
||||||
(b"\x00\t", "LayerRecord[2].LayerGlyph (9)"),
|
(b"\x00\t", "LayerRecord[2].LayerGlyph (9)"),
|
||||||
(b"\x00\x02", "LayerRecord[2].PaletteIndex (2)"),
|
(b"\x00\x02", "LayerRecord[2].PaletteIndex (2)"),
|
||||||
(b"\x00\x00\x00\x02", "BaseGlyphV1List.BaseGlyphCount (2)"),
|
# BaseGlyphV1List
|
||||||
|
(b"\x00\x00\x00\x03", "BaseGlyphV1List.BaseGlyphCount (3)"),
|
||||||
(b"\x00\n", "BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph (10)"),
|
(b"\x00\n", "BaseGlyphV1List.BaseGlyphV1Record[0].BaseGlyph (10)"),
|
||||||
(
|
|
||||||
b"\x00\x00\x00\x10",
|
|
||||||
"Offset to Paint table from beginning of BaseGlyphV1List (16)",
|
|
||||||
),
|
|
||||||
(b"\x00\x0e", "BaseGlyphV1List.BaseGlyphV1Record[1].BaseGlyph (14)"),
|
|
||||||
(
|
(
|
||||||
b"\x00\x00\x00\x16",
|
b"\x00\x00\x00\x16",
|
||||||
"Offset to Paint table from beginning of BaseGlyphV1List (22)",
|
"Offset to Paint table from beginning of BaseGlyphV1List (22)",
|
||||||
),
|
),
|
||||||
|
(b"\x00\x0e", "BaseGlyphV1List.BaseGlyphV1Record[1].BaseGlyph (14)"),
|
||||||
|
(
|
||||||
|
b"\x00\x00\x00\x1c",
|
||||||
|
"Offset to Paint table from beginning of BaseGlyphV1List (28)",
|
||||||
|
),
|
||||||
|
(b"\x00\x0f", "BaseGlyphV1List.BaseGlyphV1Record[2].BaseGlyph (15)"),
|
||||||
|
(
|
||||||
|
b"\x00\x00\x00\x5b",
|
||||||
|
"Offset to Paint table from beginning of BaseGlyphV1List (91)",
|
||||||
|
),
|
||||||
|
# BaseGlyphV1Record[0]
|
||||||
(b"\x01", "BaseGlyphV1Record[0].Paint.Format (1)"),
|
(b"\x01", "BaseGlyphV1Record[0].Paint.Format (1)"),
|
||||||
(b"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"),
|
(b"\x04", "BaseGlyphV1Record[0].Paint.NumLayers (4)"),
|
||||||
(b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"),
|
(b"\x00\x00\x00\x00", "BaseGlyphV1Record[0].Paint.FirstLayerIndex (0)"),
|
||||||
|
# BaseGlyphV1Record[1]
|
||||||
(b"\x0C", "BaseGlyphV1Record[1].Paint.Format (12)"),
|
(b"\x0C", "BaseGlyphV1Record[1].Paint.Format (12)"),
|
||||||
(b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"),
|
(b"\x00\x00<", "Offset to SourcePaint from beginning of PaintComposite (60)"),
|
||||||
(b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"),
|
(b"\x03", "BaseGlyphV1Record[1].Paint.CompositeMode [SRC_OVER] (3)"),
|
||||||
@ -145,6 +153,29 @@ COLR_V1_SAMPLE = (
|
|||||||
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"),
|
(b"\x00\x00\x00\x00\x00\x00\x00\x00", "Affine2x3.dy.value (0.0)"),
|
||||||
(b"\x07", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (7)"),
|
(b"\x07", "BaseGlyphV1Record[1].Paint.SourcePaint.Format (7)"),
|
||||||
(b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"),
|
(b"\x00\n", "BaseGlyphV1Record[1].Paint.SourcePaint.Glyph (10)"),
|
||||||
|
# BaseGlyphV1Record[2]
|
||||||
|
(b"\x06", "BaseGlyphV1Record[2].Paint.Format (6)"),
|
||||||
|
(b"\x00\x00\x06", "Offset to Paint subtable from beginning of PaintGlyph (6)"),
|
||||||
|
(b"\x00\x0b", "BaseGlyphV1Record[2].Paint.Glyph (11)"),
|
||||||
|
(b"\x05", "BaseGlyphV1Record[2].Paint.Paint.Format (5)"),
|
||||||
|
(b"\x00\x00 ", "Offset to ColorLine from beginning of PaintSweepGradient (32)"),
|
||||||
|
(b"\x01\x03\x00\x00\x00\x00", "centerX.value (259)"),
|
||||||
|
(b"\x01\x2c\x00\x00\x00\x00", "centerY.value (300)"),
|
||||||
|
(b"\x00\x2d\x00\x00\x00\x00\x00\x00", "startAngle (45.0)"),
|
||||||
|
(b"\x00\x87\x00\x00\x00\x00\x00\x00", "endAngle (135.0)"),
|
||||||
|
(b"\x00", "ColorLine.Extend (0; pad)"),
|
||||||
|
(b"\x00\x02", "ColorLine.StopCount (2)"),
|
||||||
|
(b"\x00\x00", "ColorLine.ColorStop[0].StopOffset.value (0.0)"),
|
||||||
|
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[0].StopOffset.varIdx (0)"),
|
||||||
|
(b"\x00\x03", "ColorLine.ColorStop[0].Color.PaletteIndex (3)"),
|
||||||
|
(b"@\x00", "ColorLine.ColorStop[0].Color.Alpha.value (1.0)"),
|
||||||
|
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[0].Color.Alpha.varIdx (0)"),
|
||||||
|
(b"@\x00", "ColorLine.ColorStop[1].StopOffset.value (1.0)"),
|
||||||
|
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[1].StopOffset.varIdx (0)"),
|
||||||
|
(b"\x00\x05", "ColorLine.ColorStop[1].Color.PaletteIndex (5)"),
|
||||||
|
(b"@\x00", "ColorLine.ColorStop[1].Color.Alpha.value (1.0)"),
|
||||||
|
(b"\x00\x00\x00\x00", "ColorLine.ColorStop[1].Color.Alpha.varIdx (0)"),
|
||||||
|
# LayerV1List
|
||||||
(b"\x00\x00\x00\x04", "LayerV1List.LayerCount (4)"),
|
(b"\x00\x00\x00\x04", "LayerV1List.LayerCount (4)"),
|
||||||
(
|
(
|
||||||
b"\x00\x00\x00\x14",
|
b"\x00\x00\x00\x14",
|
||||||
@ -286,7 +317,7 @@ COLR_V1_XML = [
|
|||||||
"</LayerRecordArray>",
|
"</LayerRecordArray>",
|
||||||
"<!-- LayerRecordCount=3 -->",
|
"<!-- LayerRecordCount=3 -->",
|
||||||
"<BaseGlyphV1List>",
|
"<BaseGlyphV1List>",
|
||||||
" <!-- BaseGlyphCount=2 -->",
|
" <!-- BaseGlyphCount=3 -->",
|
||||||
' <BaseGlyphV1Record index="0">',
|
' <BaseGlyphV1Record index="0">',
|
||||||
' <BaseGlyph value="glyph00010"/>',
|
' <BaseGlyph value="glyph00010"/>',
|
||||||
' <Paint Format="1"><!-- PaintColrLayers -->',
|
' <Paint Format="1"><!-- PaintColrLayers -->',
|
||||||
@ -316,6 +347,36 @@ COLR_V1_XML = [
|
|||||||
" </BackdropPaint>",
|
" </BackdropPaint>",
|
||||||
" </Paint>",
|
" </Paint>",
|
||||||
" </BaseGlyphV1Record>",
|
" </BaseGlyphV1Record>",
|
||||||
|
' <BaseGlyphV1Record index="2">',
|
||||||
|
' <BaseGlyph value="glyph00015"/>',
|
||||||
|
' <Paint Format="6"><!-- PaintGlyph -->',
|
||||||
|
' <Paint Format="5"><!-- PaintSweepGradient -->',
|
||||||
|
" <ColorLine>",
|
||||||
|
' <Extend value="pad"/>',
|
||||||
|
" <!-- StopCount=2 -->",
|
||||||
|
' <ColorStop index="0">',
|
||||||
|
' <StopOffset value="0.0"/>',
|
||||||
|
" <Color>",
|
||||||
|
' <PaletteIndex value="3"/>',
|
||||||
|
' <Alpha value="1.0"/>',
|
||||||
|
" </Color>",
|
||||||
|
" </ColorStop>",
|
||||||
|
' <ColorStop index="1">',
|
||||||
|
' <StopOffset value="1.0"/>',
|
||||||
|
" <Color>",
|
||||||
|
' <PaletteIndex value="5"/>',
|
||||||
|
' <Alpha value="1.0"/>',
|
||||||
|
" </Color>",
|
||||||
|
" </ColorStop>",
|
||||||
|
" </ColorLine>",
|
||||||
|
' <centerX value="259"/>',
|
||||||
|
' <centerY value="300"/>',
|
||||||
|
' <startAngle value="45.0"/>',
|
||||||
|
' <endAngle value="135.0"/>',
|
||||||
|
" </Paint>",
|
||||||
|
' <Glyph value="glyph00011"/>',
|
||||||
|
" </Paint>",
|
||||||
|
" </BaseGlyphV1Record>",
|
||||||
"</BaseGlyphV1List>",
|
"</BaseGlyphV1List>",
|
||||||
"<LayerV1List>",
|
"<LayerV1List>",
|
||||||
" <!-- LayerCount=4 -->",
|
" <!-- LayerCount=4 -->",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user