'From Cuis 5.0 [latest update: #4507] on 3 January 2021 at 12:29:58 pm'!
!classDefinition: #M3Exp04Morph category: 'VectorGraphics-Experiments'!
MovableMorph subclass: #M3Exp04Morph
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'VectorGraphics-Experiments'!

!M3Exp04Morph commentStamp: '<historical>' prior: 0!
"Just an experiment to exercise drawing operations."
| m |
m _ M3Exp01Morph new.
m morphPosition: 15@30.
(VectorCanvas onForm: Display) fullDraw: m.
Display forceToScreen.!


!M3Exp04Morph methodsFor: 'drawing' stamp: 'jmv 1/3/2021 12:11:47'!
drawOn: aCanvas
	"A canvas is already set with a proper transformation from our coordinates to those of the Canvas target."



aCanvas image: ImageMorph defaultForm at: -10@ -10.

aCanvas strokeWidth: 5 color: (Color green alpha: 0.6) fillColor: (Color red alpha: 0.3) do: [
	aCanvas roundRectangleMinX: -10 maxX: 75 minY: -10 maxY: 47 rx: 40 ry: 20 ].

! !


!VectorCanvas methodsFor: 'drawing - MorphicCanvas protocol' stamp: 'jmv 1/3/2021 12:25:56'!
image: srcForm at: aPoint
	"Workaround using WarpBlt until properly implemented in VectorEngine"

	| cellSize srcBox dstBox srcQuad |

	"hack to affect morphIds in a reasonably way"
	self fillRectangle: (srcForm boundingBox translatedBy: aPoint) color: `Color black alpha: 0.01`.

	cellSize _ 4.
	srcBox _ srcForm boundingBox.
	dstBox _ currentTransformation displayBoundsOfTransformOf: srcBox.
	srcQuad _ dstBox corners collect: [ :pt | (currentTransformation inverseTransform: pt) floor ].
	dstBox _ currentTransformation displayBoundsOfTransformOf: (srcBox translatedBy: aPoint).
	(WarpBlt toForm: form)
		clipRect: clipRect;
		sourceForm: srcForm;
		colorMap: (srcForm colormapIfNeededFor: form);
		cellSize: cellSize;
		combinationRule: Form blend;
		copyQuad: srcQuad toRect: dstBox.! !

