Ejemplo n.º 1
0
def test_buildAffine2x3():
    matrix = builder.buildAffine2x3((1.5, 0, 0.5, 2.0, 1.0, -3.0))
    assert matrix.xx == builder.VariableFloat(1.5)
    assert matrix.yx == builder.VariableFloat(0.0)
    assert matrix.xy == builder.VariableFloat(0.5)
    assert matrix.yy == builder.VariableFloat(2.0)
    assert matrix.dx == builder.VariableFloat(1.0)
    assert matrix.dy == builder.VariableFloat(-3.0)
Ejemplo n.º 2
0
def test_buildPaintTransform():
    layerBuilder = LayerV1ListBuilder()
    paint = layerBuilder.buildPaintTransform(
        transform=builder.buildAffine2x3((1, 2, 3, 4, 5, 6)),
        paint=layerBuilder.buildPaintGlyph(
            glyph="a",
            paint=layerBuilder.buildPaintSolid(paletteIndex=0, alpha=1.0),
        ),
    )

    assert paint.Format == ot.Paint.Format.PaintTransform
    assert paint.Paint.Format == ot.Paint.Format.PaintGlyph
    assert paint.Paint.Paint.Format == ot.Paint.Format.PaintSolid

    assert paint.Transform.xx.value == 1.0
    assert paint.Transform.yx.value == 2.0
    assert paint.Transform.xy.value == 3.0
    assert paint.Transform.yy.value == 4.0
    assert paint.Transform.dx.value == 5.0
    assert paint.Transform.dy.value == 6.0

    paint = layerBuilder.buildPaintTransform(
        (1, 0, 0, 0.3333, 10, 10),
        {
            "format": 4,
            "colorLine": {
                "stops": [(0.0, 0), (1.0, 1)]
            },
            "c0": (100, 100),
            "c1": (100, 100),
            "r0": 0,
            "r1": 50,
        },
    )

    assert paint.Format == ot.Paint.Format.PaintTransform
    assert paint.Transform.xx.value == 1.0
    assert paint.Transform.yx.value == 0.0
    assert paint.Transform.xy.value == 0.0
    assert paint.Transform.yy.value == 0.3333
    assert paint.Transform.dx.value == 10
    assert paint.Transform.dy.value == 10
    assert paint.Paint.Format == ot.Paint.Format.PaintRadialGradient