Giter Site home page Giter Site logo

programmatic mouse click about makie.jl HOT 5 CLOSED

bjarthur avatar bjarthur commented on July 20, 2024
programmatic mouse click

from makie.jl.

Comments (5)

asinghvi17 avatar asinghvi17 commented on July 20, 2024

Yep the events could definitely use some documentation!

As to

use coordinates in data space as opposed to pixel space

data_space_point = Makie.project(ax.scene.camera, :pixel, :data, pixel_space_point)

from makie.jl.

bjarthur avatar bjarthur commented on July 20, 2024

that's close, thank you! but, there seems to be a translation problem that needs to be subtracted. if i plot three points as follows, and then put my cursor directly over [1,1] in data space, project returns (1.18,1.19). similarly, [2,2] returns (2.18,2.20). where is the ~0.2 offset coming from?

julia> using GLMakie

julia> fig,ax,s = scatter([1,2,3])

julia> data_space_point = Makie.project(ax.scene.camera, :pixel, :data, ax.scene.events.mouseposition[])
3-element Point{3, Float32} with indices SOneTo(3):
 1.1825435
 1.1989319
 0.0

julia> data_space_point = Makie.project(ax.scene.camera, :pixel, :data, ax.scene.events.mouseposition[])
3-element Point{3, Float32} with indices SOneTo(3):
 2.1808665
 2.2028778
 0.0

julia> data_space_point = Makie.project(ax.scene.camera, :pixel, :data, ax.scene.events.mouseposition[])
3-element Point{3, Float32} with indices SOneTo(3):
 3.184107
 3.208738

from makie.jl.

jkrumbiegel avatar jkrumbiegel commented on July 20, 2024

you need to subtract the ax.scene.px_area[].origin from mouseposition[] I think

from makie.jl.

bjarthur avatar bjarthur commented on July 20, 2024

that works, thanks! though px_area has been renamed to viewport:

┌ Warning: `.px_area` got renamed to `.viewport`, and means the area the scene maps to in device independent units, not pixels. Note, `size(scene) == widths(scene.viewport[])`
└ @ Makie ~/.julia/packages/Makie/VRavR/src/deprecated.jl:9

from makie.jl.

jkrumbiegel avatar jkrumbiegel commented on July 20, 2024

Right, years old habits ;)

from makie.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.