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

48 lines
1.0 KiB
Smalltalk
Raw Normal View History

2022-03-01 22:58:58 +01:00
Class {
#name : #Diya2DNode,
#superclass : #DiyaNode,
#category : #'Diya-Graphics'
}
2022-03-03 19:19:40 +01:00
{ #category : #'as yet unclassified' }
2022-03-04 20:28:38 +01:00
Diya2DNode >> gltf: points do: block [
2022-03-03 19:19:40 +01:00
^ points collect: [ :point | |coord|
coord := self tf +* { point x. point y. 1.0 }.
2022-03-04 20:28:38 +01:00
block value: coord first value: (coord at:2)
2022-03-03 19:19:40 +01:00
]
]
2022-03-01 22:58:58 +01:00
{ #category : #initialization }
Diya2DNode >> initialize [
super initialize.
translation := 0@0.
scale := 1.0@1.0.
2022-03-01 22:58:58 +01:00
rotation := 0.0.
tf := Array2D identity: 3.
]
{ #category : #accessing }
Diya2DNode >> updateTF [
tf := Array2D identity:3.
"translation"
tf := tf +* (Array2D rows: 3 columns: 3 contents: {
1.0. 0.0. translation x.
0.0. 1.0. translation y.
0.0. 0.0. 1.0
}).
2022-03-01 22:58:58 +01:00
"rotation"
tf := tf +* (Array2D rows: 3 columns: 3 contents:{
rotation cos. (rotation sin) negated. 0.0.
rotation sin. rotation cos. 0.0.
0.0. 0.0. 1.0
}).
"scale"
tf := tf +* (Array2D rows: 3 columns: 3 contents:{
scale x. 0.0. 0.0.
0.0. scale y. 0.0.
0.0. 0.0. 1.0
}).
self parent isRoot ifTrue: [ ^tf ].
2022-03-01 22:58:58 +01:00
tf := self parent tf +* tf
]