1
0
mirror of https://github.com/lxsang/Diya-API.git synced 2024-12-26 11:28:22 +01:00
Diya-API/Diya/DiyaEllipse.class.st

98 lines
2.0 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
]
{ #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.
]
{ #category : #accessing }
DiyaEllipse >> process [
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.
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.
} doWithIndex: [:e :i| vbuffer at: i put: e].
^true
]
2022-03-16 01:32:01 +01:00
{ #category : #accessing }
DiyaEllipse >> rx [
^ rx
]
{ #category : #accessing }
DiyaEllipse >> rx: anObject [
rx := anObject.
2022-08-07 20:43:16 +02:00
self setDirty
2022-03-16 01:32:01 +01:00
]
{ #category : #accessing }
DiyaEllipse >> ry [
^ ry
]
{ #category : #accessing }
DiyaEllipse >> ry: anObject [
ry := anObject.
2022-08-07 20:43:16 +02:00
self setDirty
2022-03-16 01:32:01 +01:00
]
2022-03-16 17:48:18 +01:00
{ #category : #initialization }
DiyaEllipse >> setUpShader [
super setUpShader.
self shader
2022-08-07 20:43:16 +02:00
setUniform: #u_border value: (self ? #border);
setUniform: #u_border_color value: ( self ? #borderColor) asGL4FArray;
setUniform: #u_rx value: (rx * (scale x)) ;
setUniform: #u_ry value: (ry * (scale y)) .
2022-03-16 17:48:18 +01:00
]