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

108 lines
2.1 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
]
2022-03-21 01:45:21 +01:00
{ #category : #initialization }
DiyaEllipse >> drawLines [
self shouldNotBeCalled
]
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
]
2022-03-19 02:18:29 +01:00
{ #category : #initialization }
DiyaEllipse >> inner: aPoint [
|dxy|
dxy := self local: aPoint.
^ ((((dxy x) ** 2)/(rx**2)) + (((dxy y) ** 2) / (ry**2))) < 1.
]
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
2022-03-23 00:52:15 +01:00
setUniform: #u_border value: (style get: #border);
setUniform: #u_border_color value: (style get:#borderColor) asGL4FArray;
2022-03-16 17:48:18 +01:00
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 origin y. 0.0. 0.0.
bbox origin x. bbox corner y. 0.0. 1.0.
bbox corner x. bbox corner y. 1.0. 1.0.
2022-03-16 17:48:18 +01:00
bbox corner x. bbox corner y. 1.0. 1.0.
bbox corner x. bbox origin y. 1.0. 0.0.
bbox origin x. bbox origin y. 0.0. 0.0.
2022-03-16 17:48:18 +01:00
} doWithIndex: [:e :i| vbuffer at: i put: e].
2022-03-16 01:32:01 +01:00
^true
]