Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use drawVerticies? #147

Closed
ReneTC opened this issue Aug 8, 2021 · 2 comments
Closed

How to use drawVerticies? #147

ReneTC opened this issue Aug 8, 2021 · 2 comments
Labels
question Further information is requested

Comments

@ReneTC
Copy link

ReneTC commented Aug 8, 2021

Im trying to make a triangle. Seems like the best way to do this is with drawVertices. However, I can't get this to work and there are not any examples. I would love your input on this.

import skia
from IPython.display import display
surface = skia.Surface(256, 256)

with surface as canvas:
    color = skia.ColorSetRGB(0, 0, 0)

    paint = skia.Paint(Color=skia.Color(0, 0, 255))

    p1 = skia.Point(0, 0)
    p2 = skia.Point(100, 0.0)
    p3 = skia.Point(50, 100)

    test = skia.Vertices([p1,p2,p3])
    Canvas.drawVertices(test,paint)

image = surface.makeImageSnapshot()
display(image)

I get the error


TypeError: __init__(): incompatible constructor arguments. The following argument types are supported:
    1. skia.Vertices(mode: skia.Vertices.VertexMode, positions: List[skia.Point], texs: object = None, colors: object = None, indices: object = None)

Invoked with: [Point(0, 0), Point(100, 0), Point(50, 100)]
@kyamagu
Copy link
Owner

kyamagu commented Aug 10, 2021

See the documentation and test codes.

@kyamagu kyamagu added the question Further information is requested label Aug 10, 2021
@ReneTC
Copy link
Author

ReneTC commented Aug 10, 2021

Thank you! After vierwing the test codes I see I needed skia.Vertices.kTriangles_VertexMode. The following works perfectly;

import skia
from IPython.display import display
surface = skia.Surface(256, 256)

with surface as canvas:
    color = skia.ColorSetRGB(0, 0, 0)

    paint = skia.Paint(Color=skia.Color(0, 0, 255))

    p1 = skia.Point(0, 0)
    p2 = skia.Point(100, 0.0)
    p3 = skia.Point(50, 100)

    test = skia.Vertices(skia.Vertices.kTriangles_VertexMode,[p1,p2,p3])
    canvas.drawVertices(test,paint)

image = surface.makeImageSnapshot()
display(image)

@ReneTC ReneTC closed this as completed Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants