Canvas etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Canvas etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

27 Mart 2019 Çarşamba

Awt Canvas Sınıfı

Giriş
Hiyerarşisi şöyle.
public class Canvas extends Component implements Accessible
Açıklaması şöyle.
A canvas is for drawing on, basically. It also serves like a Panel for creating a custom AWT-based component, but unlike Panel it can't contain other components.
Canvas C++ kütüphanesi tarafından kullanılabilir çünü Awt bileşeni olduğu için işletim sisteminde handle olarak karşılığı bulunur. Açıklaması şöyle.  Yani heavyweight bir bileşendir.
There are two kinds of graphics components in the Java programming language: heavyweight and lightweight. A heavyweight component is associated with its own native screen resource (commonly known as a peer). Components from the java.awt package, such as Button and Label, are heavyweight components.
[...]
A lightweight component has no native screen resource of its own, so it is "lighter." A lightweight component relies on the screen resource from an ancestor in the containment hierarchy, possibly the underlying Frame object. Components from the javax.swing package, such as JButton and JLabel, are lightweight components.

13 Ocak 2019 Pazar

JOGL Canvas Sınıfı - OpenGL İçin Binding

Giriş
JOGL kütüphanesi OpenGL için binding sağlar.

Maven
Şu satırı dahil ederiz
<dependency>
  <groupId>org.jogamp.gluegen</groupId>
  <artifactId>gluegen-rt-main</artifactId>
  <version>2.3.1</version>
</dependency>
<dependency>
  <groupId>org.jogamp.jogl</groupId>
  <artifactId>jogl-all-main</artifactId>
  <version>2.3.1</version>
</dependency>
glutInitDisplayMode() ile JOGL farkının açıklaması şöyle.
There is no direct analog. GLUT associates OpenGL more or less directly with a display window.

With JOGL, you create a canvas, then associate the canvas with the window. Creating the canvas looks something like this:
...
After that, the details vary depending on the window toolkit (AWT, SWT, Swing, etc.) you're going to use. There's not much difference between Swing and AWT: you create a frame, add the canvas to the frame, and add an EventListener for OpenGL events (reshape, draw, etc.)
constructor
Şöyle yaparız.
GLProfile profile = GLProfile.getDefault();
GLCapabilities capabilities = new GLCapabilities(profile);
GLCanvas canvas = new GLCanvas(capabilities);

14 Mayıs 2017 Pazar

JavaFX Canvas Sınıfı

getGraphicsContext2D metodu
Şöyle yaparız. GraphicsContext nesnesi döndürür.
GraphicsContext gc = canvas.getGraphicsContext2D();
getHeight metodu
Şöyle yaparız.
canvas.getHeight();
getWidth metodu
Şöyle yaparız.
canvas.getWidth();
snapShot metodu
Şöyle yaparız.
Image snapshot = canvas.snapshot(null, null);