Skip to content

Scale a Quad from center in all directions #1090

Discussion options

You must be logged in to vote

Thank you for your response @JorjMcKie. But I found that you can use morph to scale the quad

Below is the function that i'm using to scale the morph by its center:

def getPolygon(inst, scale=1):
    [sumX, sumY] = [0, 0]
    for point in inst:
        sumX += point[0]
        sumY += point[1]
    avgX = sumX/4
    avgY = sumY/4

    # Scale the rectange using Quad.morph(): https://pymupdf.readthedocs.io/en/latest/quad.html#Quad.morph
    inst = inst.morph(fitz.Point(avgX,  avgY), fitz.Matrix(scale, scale))
    # re-ordering the points in list counter-clockwise
    inst[2], inst[3] = inst[3], inst[2]
    return inst

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@AnweshGangula
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by AnweshGangula
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants