Sachin Desai
2005-12-18 22:48:31 UTC
I need help in understanding how to scroll an image once it's
displayed as a graphic for a player. Basically what I'm trying to
accomplish is to scroll an image in a small window. I have the
player's form set to the image and the following code accomplishes
what I want but the rendering is not smooth, i.e. when I drag, I'm
not able to see any movement until the drag stops whereupon the image
renders.
If I replace "self graphicForm: f" with "f displayAt: self origin"
then I get the desired result which is having the image rendered
pretty much immediately as I drag. The one problem is the image is
not rendered in the player, instead it's rendered at some offset from
the player. Any ideas?
In general, if someone wants to display a changing image or graphics
in a window, what's the mechanism for doing this. I've tried to do
this with a player that load the image and a costume that listens on
the events and does the rendering. I'm not sure if this is the right
approach but any help would be gladly welcome.
onRedButtonDown
| nextPoint lastPoint f |
<on: redButtonDown>
lastPoint _ nil.
self closedHandCursor show.
[Sensor redButtonPressed] whileTrue: [
nextPoint _ Sensor cursorPoint.
lastPoint ifNil: [lastPoint _ nextPoint].
self delta: (nextPoint - lastPoint).
self imageOffset: (self imageOffset + self delta).
self drawingCanvas
translateBy: self delta
during: [:canvas |
canvas fillColor: Color white.
canvas paintImage: self form at: (self imageOffset).
f _ canvas contentsOfArea: (***@0 extent: ***@200).
self graphicForm: f].
lastPoint _ nextPoint.
].
self openHandCursor show.
-- Sachin
displayed as a graphic for a player. Basically what I'm trying to
accomplish is to scroll an image in a small window. I have the
player's form set to the image and the following code accomplishes
what I want but the rendering is not smooth, i.e. when I drag, I'm
not able to see any movement until the drag stops whereupon the image
renders.
If I replace "self graphicForm: f" with "f displayAt: self origin"
then I get the desired result which is having the image rendered
pretty much immediately as I drag. The one problem is the image is
not rendered in the player, instead it's rendered at some offset from
the player. Any ideas?
In general, if someone wants to display a changing image or graphics
in a window, what's the mechanism for doing this. I've tried to do
this with a player that load the image and a costume that listens on
the events and does the rendering. I'm not sure if this is the right
approach but any help would be gladly welcome.
onRedButtonDown
| nextPoint lastPoint f |
<on: redButtonDown>
lastPoint _ nil.
self closedHandCursor show.
[Sensor redButtonPressed] whileTrue: [
nextPoint _ Sensor cursorPoint.
lastPoint ifNil: [lastPoint _ nextPoint].
self delta: (nextPoint - lastPoint).
self imageOffset: (self imageOffset + self delta).
self drawingCanvas
translateBy: self delta
during: [:canvas |
canvas fillColor: Color white.
canvas paintImage: self form at: (self imageOffset).
f _ canvas contentsOfArea: (***@0 extent: ***@200).
self graphicForm: f].
lastPoint _ nextPoint.
].
self openHandCursor show.
-- Sachin