What is a graphic context? (iOS)

前端 未结 3 1624
暖寄归人
暖寄归人 2021-02-05 11:16

What exactly is a graphic context? When drawing with Core Graphic we get a reference to the context. When I look at the documentation it seems like it is an object or so that ta

相关标签:
3条回答
  • 2021-02-05 11:51

    "it seems like it is an object or so that take care of the correct drawing whether it is for printing, device, pdf and so on."

    Exactly correct.

    You simply write routines that "really" do some drawing (but it could be to anywhere, to any type of thing or device). You don't have to worry about ANYTHING other than drawing in the abstract ... lines, circles, typography, colours and other such nonsense.

    -(void)happyDrawing
    -(void)sadDrawing
    -(void)fancyDrawing
    

    Then -- amazingly -- you can use those anywhere.

    -(void)makeSomeFiles
       {
       .. set up a context for making files
       .. happyDrawing
       }
    -(void)makeATruGrayScaleBitmap
       {
       .. set up a context for making a gray bitmap
       .. happyDrawing
       }
    -(void)drawRect
       {
       .. drawing on your Lisa screen
       .. happyDrawing
       }
    -(void)drawRect
       {
       .. drawing on your iPad screen
       .. happyDrawing
       }
    -(void)printAPage
       {
       .. set up a context for printing
       .. happyDrawing
       }
    

    I hope it helps!

    0 讨论(0)
  • 2021-02-05 11:56

    The graphics context determines how you are drawing to the screen, be it OpenGL or some 2D library. You should know this.

    0 讨论(0)
  • 2021-02-05 11:58

    To put in simple words, an area where the graphics get rendered or drawn before actually presenting it.

    0 讨论(0)
提交回复
热议问题