2022-03-01 22:58:58 +01:00
|
|
|
Class {
|
|
|
|
#name : #Diya2DNode,
|
|
|
|
#superclass : #DiyaNode,
|
2022-03-06 18:33:10 +01:00
|
|
|
#instVars : [
|
2022-03-19 02:18:29 +01:00
|
|
|
'vbuffer'
|
2022-03-06 18:33:10 +01:00
|
|
|
],
|
2022-03-01 22:58:58 +01:00
|
|
|
#category : #'Diya-Graphics'
|
|
|
|
}
|
|
|
|
|
2022-03-16 01:32:01 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> boundingBox [
|
2022-03-19 02:18:29 +01:00
|
|
|
|rec|
|
2022-03-21 18:03:15 +01:00
|
|
|
children ifEmpty: [ ^ Rectangle origin: 0@0 corner: 0@0 ].
|
2022-03-19 02:18:29 +01:00
|
|
|
rec := children first boundingBox.
|
|
|
|
children do:[:c|
|
|
|
|
rec = c ifFalse:[
|
|
|
|
rec := rec merge: c boundingBox]
|
|
|
|
].
|
|
|
|
^rec
|
2022-03-16 01:32:01 +01:00
|
|
|
]
|
|
|
|
|
2022-03-19 02:18:29 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> draw [
|
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-03-16 01:32:01 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> extent [
|
2022-03-19 02:18:29 +01:00
|
|
|
^ self boundingBox extent
|
2022-03-16 01:32:01 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> height [
|
|
|
|
^ self extent y
|
|
|
|
]
|
|
|
|
|
2022-03-01 22:58:58 +01:00
|
|
|
{ #category : #initialization }
|
|
|
|
Diya2DNode >> initialize [
|
|
|
|
super initialize.
|
|
|
|
translation := 0@0.
|
2022-03-21 19:13:11 +01:00
|
|
|
scale := 1@1.
|
|
|
|
rotation := 0.
|
2022-08-10 22:53:14 +02:00
|
|
|
tf := MatrixTransform2x3 identity .
|
2022-03-06 18:33:10 +01:00
|
|
|
shader := Diya2DShader uniqueInstance.
|
2022-03-06 19:50:19 +01:00
|
|
|
vbuffer := nil.
|
2022-03-16 01:32:01 +01:00
|
|
|
]
|
|
|
|
|
2022-08-07 18:15:57 +02:00
|
|
|
{ #category : #accessing }
|
2022-03-19 02:18:29 +01:00
|
|
|
Diya2DNode >> inner: aPoint [
|
|
|
|
^ self boundingBox containsPoint: (self local: aPoint)
|
|
|
|
]
|
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> local: aPoint [
|
2022-08-13 01:37:42 +02:00
|
|
|
^ self tf globalPointToLocal: aPoint
|
2022-03-19 02:18:29 +01:00
|
|
|
|
|
|
|
]
|
|
|
|
|
2022-08-07 18:15:57 +02:00
|
|
|
{ #category : #accessing }
|
2022-03-16 01:32:01 +01:00
|
|
|
Diya2DNode >> recFromBuffer [
|
|
|
|
|maxX maxY minX minY x y|
|
2022-03-16 17:48:18 +01:00
|
|
|
maxX := minX := vbuffer at: 1.
|
|
|
|
maxY := minY := vbuffer at: 2.
|
2022-03-16 01:32:01 +01:00
|
|
|
1 to: vbuffer size by: 4 do: [ :i|
|
|
|
|
x := vbuffer at: i.
|
|
|
|
y := vbuffer at: i + 1.
|
|
|
|
maxX := maxX max: x.
|
|
|
|
maxY := maxY max: y.
|
|
|
|
minX := minX min: x.
|
|
|
|
minY := minY min: y.
|
|
|
|
].
|
|
|
|
^ Rectangle origin: minX@minY corner: maxX @ maxY
|
2022-03-06 18:33:10 +01:00
|
|
|
]
|
|
|
|
|
2022-03-01 22:58:58 +01:00
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> updateTF [
|
2022-08-10 22:53:14 +02:00
|
|
|
tf := MatrixTransform2x3 identity.
|
2022-03-01 22:58:58 +01:00
|
|
|
"translation"
|
2022-08-12 22:19:54 +02:00
|
|
|
tf setOffset: translation + pivot.
|
2022-03-01 22:58:58 +01:00
|
|
|
"rotation"
|
2022-08-10 22:53:14 +02:00
|
|
|
rotation = 0 ifFalse:[tf setAngle: rotation ].
|
2022-08-12 22:19:54 +02:00
|
|
|
"translate back to pivot"
|
|
|
|
pivot isZero ifFalse:[
|
|
|
|
tf := tf composedWithLocal:
|
|
|
|
(MatrixTransform2x3 identity
|
|
|
|
setOffset: pivot negated;
|
|
|
|
yourself)
|
|
|
|
].
|
|
|
|
scale isZero ifFalse: [
|
|
|
|
tf := tf composedWithLocal:
|
|
|
|
(MatrixTransform2x3 identity
|
|
|
|
setScale: scale;
|
|
|
|
yourself)
|
|
|
|
].
|
2022-03-21 22:39:52 +01:00
|
|
|
self parent ifNil: [ ^self ].
|
2022-08-10 22:53:14 +02:00
|
|
|
self parent isRoot ifFalse: [tf := self parent tf composedWithLocal: tf ].
|
2022-03-21 22:39:52 +01:00
|
|
|
children ifNotNil: [children do:[:c| c updateTF ]].
|
2022-03-06 18:33:10 +01:00
|
|
|
|
2022-03-01 22:58:58 +01:00
|
|
|
]
|
2022-03-16 01:32:01 +01:00
|
|
|
|
|
|
|
{ #category : #accessing }
|
|
|
|
Diya2DNode >> width [
|
|
|
|
^ self extent x
|
|
|
|
]
|