processing-GUI:G4P library-GSlider2D (滑动器):setLimitsX(),setLimitsY(),getValueXI().getValueYI()
来源:互联网 发布:即时消息软件 编辑:程序博客网 时间:2024/05/16 18:09
/*the webset of learning G4Phttp://www.lagers.org.uk/g4pthe webset of learning MySQLhttp://bezier.de/processing/libs/sql/http://wiki.processing.org/w/How_to_Install_a_Contributed_Library*/import g4p_controls.*;GSlider2D sdrSniper;PImage imgScene, imgSight;// Lens propertiesint lsize = 40, lsize2 = lsize * lsize;//mag abd k are used to control the size of enlargementfloat mag = 2.0f;float k = -0.00002;int sightX, sightY;int border, borderViaLens;public void setup() { size(540, 460); cursor(CROSS); imageMode(CENTER); imgScene = loadImage("backdrop.jpg"); imgSight = loadImage("sight.png"); // border colours borderViaLens = color(0, 80, 0); //create a slider in a rect(180,340,180,100); sdrSniper = new GSlider2D(this, 180, 340, 180, 100); //the default initial value of x is 0,and y is 0 //set x initial value:180 ; limit slider's X position between 60 and 480 sdrSniper.setLimitsX(180, 60, 480); //set y initial value:150 ; limit slider's Y position between 60 and 280 sdrSniper.setLimitsY(150, 60, 280); //setEasing(float move) : the value of move increase but the speed of move decrease sdrSniper.setEasing(10); //Determines whether to show the tab and panel back colour. sdrSniper.setOpaque(true); //getValueXI(),getValueYI(): get the current X,Y value as an integer. DECIMAL and EXPONENT value types will be rounded to the nearest integer. sightX = sdrSniper.getValueXI(); sightY = sdrSniper.getValueYI(); //println(sightX+" "+sightY);}public void draw() { background(imgScene); showLens(sightX, sightY); image(imgSight, sightX, sightY);}void mousePressed(){ println(mouseX+" "+mouseY);}//connect small rectangle with circle to use rectangle control circle public void handleSlider2DEvents(GSlider2D slider2d, GEvent event) { if (slider2d == sdrSniper) { sightX = sdrSniper.getValueXI(); sightY = sdrSniper.getValueYI(); }}//the function is used to make image display biggerpublic void showLens(int x, int y) { int u, v, r2; float f; for (int vd = - lsize; vd < lsize; vd++) { for (int ud = - lsize; ud < lsize; ud++) { r2 = ud*ud + vd*vd; if (r2 <= lsize2) { f = mag + k * r2; u = floor(ud/f) + x; v = floor(vd/f) + y; if (u >= 0 && u < imgScene.width && v >=0 && v < imgScene.height) set(ud + x, vd + y, imgScene.get(u, v)); else set(ud + x, vd + y, borderViaLens); } } }}
0 0
- processing-GUI:G4P library-GSlider2D (滑动器):setLimitsX(),setLimitsY(),getValueXI().getValueYI()
- processing-G4P library-GButton,GTextField,GPanel,addEventHandler()
- Animated GIF library for Processing
- An OpenGL GUI Library
- OpenGL: An OpenGL GUI Library
- Unity3D中创建滑动GUI
- [Setup] FLTK - A simple C++ GUI Library
- Boost Library 1.32.0 : String and text processing
- Mediastreamer2 library - a modular sound and video processing and streaming
- 在Unity3d中创建滑动GUI
- 在Unity3d中创建滑动GUI
- 教你如何创建滑动GUI
- 在Unity3d中创建滑动GUI
- GUI 剖析之控件篇之 滑动条控件
- GUI
- GUI
- GUI+
- GUI
- [Leetcode]Bulb Switcher
- poj 1466 && hdu 1068Girls and Boys(最大独立集)
- 一些adb的口令
- 【Linux 驱动】netfilter/iptables (三) 注册和注销Netfilter hook
- 费氏查找算法
- processing-GUI:G4P library-GSlider2D (滑动器):setLimitsX(),setLimitsY(),getValueXI().getValueYI()
- 唐巧的iOS技术博客选摘
- Windows下忘记mysql密码后的解决方法
- 迷宫的最短路线(BFS)
- mysql命令行操作符下让mysql的命令自动补全功能
- swift-基础06-元组和Optionals(可选)
- websocket 解决 The extension [x-webkit-deflate-frame] is not supported 问题
- android中activity的四种加载模式
- 理工科思维