1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-27 03:48:21 +01:00
Diya-API/Diya/DiyaEllipse.class.st

96 lines
1.9 KiB
Smalltalk
Raw Normal View History

Class {
#name : #DiyaEllipse,
#superclass : #Diya2DPrimShape,
2022-03-16 01:32:01 +01:00
#instVars : [
'rx',
2022-03-16 17:48:18 +01:00
'ry'
2022-03-16 01:32:01 +01:00
],
#category : #'Diya-Graphics'
}
2022-03-16 01:32:01 +01:00
{ #category : #'as yet unclassified' }
DiyaEllipse class >> rx: rx ry: ry [
^self new rx: rx;
ry: ry;
yourself
]
{ #category : #'as yet unclassified' }
DiyaEllipse class >> rx: rx ry: ry shader: s [
^self new rx: rx;
ry: ry;
shader: s;
yourself
]
2022-03-16 17:48:18 +01:00
{ #category : #initialization }
DiyaEllipse >> draw [
OpenGL
enable: GL_BLEND;
blendFnWithSfactor: GL_SRC_ALPHA dfactor: GL_ONE_MINUS_SRC_ALPHA.
super draw.
OpenGL
disable: GL_BLEND
2022-03-16 01:32:01 +01:00
]
{ #category : #initialization }
2022-03-16 17:48:18 +01:00
DiyaEllipse >> drawBorder [
"do nothing"
2022-03-16 01:32:01 +01:00
]
{ #category : #initialization }
DiyaEllipse >> initialize [
super initialize.
translation := nil.
2022-03-16 17:48:18 +01:00
vbuffer := FFIExternalArray externalNewType: GLfloat size: 24.
2022-03-16 01:32:01 +01:00
vbuffer autoRelease.
2022-03-16 17:48:18 +01:00
shader := DiyaEllipseShader uniqueInstance.
2022-03-16 01:32:01 +01:00
]
{ #category : #accessing }
DiyaEllipse >> rx [
^ rx
]
{ #category : #accessing }
DiyaEllipse >> rx: anObject [
rx := anObject.
dirty := true.
]
{ #category : #accessing }
DiyaEllipse >> ry [
^ ry
]
{ #category : #accessing }
DiyaEllipse >> ry: anObject [
ry := anObject.
dirty := true
]
2022-03-16 17:48:18 +01:00
{ #category : #initialization }
DiyaEllipse >> setUpShader [
super setUpShader.
self shader
setUniform: #u_border value: border;
setUniform: #u_border_color value: bcolor asGL4FArray;
setUniform: #u_rx value: rx;
setUniform: #u_ry value: ry.
]
2022-03-16 01:32:01 +01:00
{ #category : #accessing }
DiyaEllipse >> update [
2022-03-16 17:48:18 +01:00
bbox := Rectangle origin: ((rx negated) @ (ry negated)) corner: (rx @ ry).
{
bbox origin x. bbox corner y. 0.0. 0.0.
bbox origin x. bbox origin y. 0.0. 1.0.
bbox corner x. bbox origin y. 1.0. 1.0.
bbox corner x. bbox origin y. 1.0. 1.0.
bbox corner x. bbox corner y. 1.0. 0.0.
bbox origin x. bbox corner y. 0.0. 0.0.
} doWithIndex: [:e :i| vbuffer at: i put: e].
2022-03-16 01:32:01 +01:00
^true
]