INNER CODE UNIT · Kotlin

dragY

fjossinet/RNArtist · src/main/kotlin/RNArtist.kt:417

                            val dragY = mouseEvent.y - it.y
                            if (dragX > 0 && dragY > 0) {
                            /*val ratio = mediator.canvas2D.canvasRatio // ratio = w/h -> w = ratio*h
                                val diag = Math.sqrt(dragX * dragX + dragY * dragY)
                                //now we compute the width and height with the same diag and the ratio of the canvas window
                                //d*d = w*w+h*h
                                //d*d = w+w+(ratio*w)*(ratio*w)
                                //w = srqt(d*d/(1+ratio*ratio))
                                val h = Math.sqrt((diag * diag) / (1 + ratio * ratio))
                                val w = ratio * h*/
                                mediator.canvas2D.zoomArea =
                                    Rectangle2D.Double(it.x, it.y, dragX, dragY)
                            }
                        }
                        mediator.canvas2D.repaint()
                    } else if (mouseEvent.button == MouseButton.SECONDARY) {
                        it.quickDraw = true
                        val transX: Double = mouseEvent.x - mediator.canvas2D.transX

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…