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

65 lines
1.2 KiB
Smalltalk
Raw Normal View History

Class {
#name : #DiyaPolygon,
#superclass : #Diya2DPrimShape,
2022-03-16 17:48:18 +01:00
#instVars : [
'points'
],
#category : #'Diya-Graphics'
}
2022-03-16 17:48:18 +01:00
{ #category : #'as yet unclassified' }
DiyaPolygon class >> points: points [
^self new points: points; yourself
]
{ #category : #'as yet unclassified' }
DiyaPolygon class >> points: points shader:s [
^self new points: points; shader:s; yourself
]
{ #category : #accessing }
DiyaPolygon >> calculateVertices [
^self subclassResponsibility
]
{ #category : #initialization }
DiyaPolygon >> initialize [
super initialize.
points := {}.
vbuffer := nil.
]
{ #category : #accessing }
DiyaPolygon >> points [
^ points
]
{ #category : #accessing }
DiyaPolygon >> points: anObject [
points := anObject.
2022-08-07 20:43:16 +02:00
self setDirty
2022-03-16 17:48:18 +01:00
]
{ #category : #accessing }
DiyaPolygon >> process [
bbox := self recFromPoints.
self calculateVertices.
^true
]
2022-03-16 17:48:18 +01:00
{ #category : #accessing }
DiyaPolygon >> recFromPoints [
|maxX maxY minX minY x y|
maxX := minX := (points at: 1) x.
maxY := minY := (points at: 1) y.
points do: [ :p|
x := p x.
y := p y.
maxX := maxX max: x.
maxY := maxY max: y.
minX := minX min: x.
minY := minY min: y.
].
^ Rectangle origin: minX@minY corner: maxX @ maxY
]