INNER CODE UNIT · Kotlin

diag

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

                                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
                        val transY: Double = mouseEvent.y - mediator.canvas2D.transY
                        it.workingSession.moveView(transX, transY)
                        mediator.canvas2D.transX = mouseEvent.x

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…