Skip to content

What is the point of setPosition #4

Open

Description

@GuichiZhao

I can not identify any meaning logic relation to setPosition
Is there anything yet to be implemented?

Activity

  1. changed the title [-]What is the point of `setPosition`[/-] [+]What is the point of setPosition[/+] on Jan 10, 2018
  2. ericdrowell commented on Jan 10, 2018

    @ericdrowell
    Owner

    ah yes - most people would probably not need it, but you can use it to improve performance for special situations. For example if you have a complex rendering on a layer, but just need to move it around, you could use setPosition() to physically move the canvas element as opposed to constantly re rendering. Alternatively, you could copy the canvas, and then re render the canvas pixels at different locations.

  3. ericdrowell commented on Jan 10, 2018

    @ericdrowell
    Owner

    you do have a point however, as most folks would probably never use it

  4. GuichiZhao commented on Jan 10, 2018

    @GuichiZhao
    Author

    I think the situation you mentioned is sort of related to what I want.
    I need to 'move around' the canvas. From the source code, setPosition looks like 'not implemented'. It do nothing but set this.x this.y, and both of the two variables are not used afterward.
    Could you provide more sample code to show how to use setPosition?

    Currently, I use clip to simulate 'move around' the whole canvas. It will be very nice if you can point out how to use setPosition

    Many thanks

  5. ericdrowell commented on Jan 10, 2018

    @ericdrowell
    Owner

    you are absolutely correct, setPosition() isn't actually moving the dom element. Must have been something I was thinking about but missed. setPosition() should also do:

    this.viewport.container.style.marginLeft = x;
    this.viewport.container.style.marginTop = y;

    or something similar

  6. GuichiZhao commented on Jan 10, 2018

    @GuichiZhao
    Author

    Currently, I can not come up with a way to make setPosition meaningful.
    Because setPosition is a method of Layer, even if it can be inherited by Scene or Hit somehow. They both live in memory (except the scene instance belonging to the viewport). For most in-memory canvas, how to implement setPosition

    Correct me If I understand things more wrong, my knowledge of canvas is limited

  7. marstave commented on Jan 25, 2018

    @marstave

    Just alter the render function and put layer.x and layer.y for the two 0,0 in drawImage :)

  8. GuichiZhao commented on Jan 28, 2018

    @GuichiZhao
    Author

    @marstave
    This is also what I thought where position can fit in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions