Simplifying Graphics With Java and Threads (轉)
Simplifying Graphics With and Threads
By Alex Chaffee and John Papageorge
July 1997
Here's some code that Earth's Alex Chaffee likes to use as an example of how Java can be used to simplify algorithms by combining graphics with threading to render complex graphics.
Basically there are three threads: a Renderer, which performs a complex calculation; an Animator, which wakes up periodically and draws the current image to the screen; and of course the default User Interface thread, which responds to user events and changes the display as appropriate.
The Renderer runs at a low priority—just grinding away forever, or at least until it's done; it shouldn't interfere with the other two threads. The Animator only comes to life every 500 msec or so, to avoid the expense of drawing each pixel.
To perfoa specific calculation, subclass the Renderer to make a Mandelbrot function. Note the -oriented design: this way, the Mandelbrot subclass only needs to overr the Run method and doesn't have to worry about the threading implementation, which is handled by its superclass. Of course, in this example, the threading implementation is trivial, but this is a teaching exercise.
Other items of note are the use of an offscreen Graphics buffer, and the use of progressive rendering. The code makes several rough passes over the image, calculating the value in each quadrant, then gradually refines the view. Unlike scape's rendering of progressive gifs, this program treats a calculated pixel as the "center" of a square of color, not as the top corner or a pixel-wide stripe, and so avoids that odd venetian-blind scrolling-up effect. With a laugh, Chaffee says, "But maybe I'm the only one in the world who thought Netscape's gif-rendering algorithm looked funny." now , see Chaffee's code
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10748419/viewspace-1002866/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Java 21 新特性:虛擬執行緒(Virtual Threads)Java執行緒thread
- Scan Your Truck Using Nexiq Adapter: Simplifying Your Diagnostic ProcessAPT
- CorelDRAW Graphics Suite 2022UI
- Threads in Node 10.5.0: a practical introthread
- mormot.core.threads--TSynBackgroundTimerORMthread
- mormot.core.threads--TSynQueueORMthread
- mormot.core.threads--TBlockingProcessORMthreadBloC
- mormot.core.threads--TSynBackgroundThreadMethodORMthread
- mormot.core.threads--TSynParallelProcessORMthreadParallel
- mormot.core.threads--TSynThreadORMthread
- mormot.core.threads--TSynThreadPoolORMthread
- Android 使用graphics.Camera類實現自定義旋轉飄落Android
- Python安裝graphics庫Python
- COMP3811 Computer Graphics
- CPT205 Computer Graphics
- CorelDRAW Graphics Suite 2022 for MacUIMac
- VisualVM第二章-ThreadsLVMthread
- mormot.core.threads.pas unitORMthread
- 論文解讀(NGCF)《LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation》GC
- COMP612 Computer Graphics Programming
- Do you wish to have better graphics?
- Qt 之 Graphics View Framework 簡介QTViewFramework
- Astute Graphics for Mac ai創意外掛合集ASTMacAI
- Fundamentals of Computer Graphics 4th目錄
- android轉javaAndroidJava
- Node.js 真·多執行緒 Worker Threads 初探Node.js執行緒thread
- Threads are going to be renewed over time to try and avoid a probable memory leak.threadGo
- # uwsgi 的 processes , threads , workers 三者的關係thread
- Bitmap回收—Canvas: trying to use a recycled bitmap android.graphicsCanvasAndroid
- Astute Graphics for Mac(ai2021創意外掛合集)ASTMacAI
- 最全的AI外掛Astute Graphics 2020全系列AIAST
- 8.0新特性-並行查詢innodb_parallel_read_threads並行Parallelthread
- Java —— 轉換流Java
- Java map轉JSONJavaJSON
- Java初探Oracle(轉)JavaOracle
- CorelDRAW Graphics Suite 2021.5 Mac(圖形設計軟體)UIMac
- CorelDRAW Graphics Suite 2022 Mac(cdr2022直裝版)UIMac
- AI來實現程式碼轉換!Python轉Java,Java轉Go不在話下?AIPythonJavaGo
- JAVA字串轉日期或日期轉字串Java字串