Re: Image perspective and shape reference
- --- In email@example.com, "Philip
Taylor" <excors+yahoo@...> wrote:
> On 30/10/06, Matt Westcott <matthew@...> wrote:
> > --- In firstname.lastname@example.org,
> >to fill
> > > 1) Is it possible to manipulate the perspective of an image or
> > > a shape in perspective?added
> > It ought to be possible to do that (with a bit of matrix algebra)
> > through the transform / setTransform methods, but they were only
> > to the Canvas spec a few months back, and as a result no browsersCorrect.
> > currently implement them (as far as I know).
> My memory of geometry is not entirely clear, but I believe you can't
> do perspective with setTransform because it only handles 2D affine
> transformations - parallel lines will always remain parallel. The
> transform matrix only contains six values (m11, m12, m21, m22, dx,
The setTransform() method is an affine transformation in 2D space.
The result would be as good ( or bad ) as the texture mapping on
PlayStation 1. It could be acceptable if you subdivide the polygons
into small triangles but it's tough to balance between speed and
Back in the days of Quake 1, the perspective correction was done
every 8 ( or 16 ) pixels and the mapping was affine in between. It
was mostly visible when you walked along a wall because of the big
difference of perspective from one edge to the other. But this
> That's a relatively easy case since the walls are always vertical -I
> also did some perspective-correct textured floors likescaled
> http://canvex.lazyilluminati.com/misc/floor5.jpg by drawing thin (2
> pixel) horizontal strips, with a rotated/scaled/translated image
> pattern fill (plus some mipmapping because images normally get
> down in an ugly flickery way). It works by setting the transformonto
> matrix such that the desired line of texture will be transformed
> the desired line of screen coordinates (corresponding to the currentends
> horizontal strip), then drawing a pattern-filled rectangle which
> up getting transformed to those screen coordinates; that justinvolves
> some maths (or experimentation and typing in random equations untilit works).
> I think that method could support any arbitrary 3D polygon (thoughmy
> code was limited to the requirements of my floors) - but the biggestin most practical cases.
> problem is that it's really quite slow, because it needs lots of
> textured-rectangle-fills for each polygon, which makes it unusable
It can work for arbitrary 3D polygons but it would be really CPU
intensive and most likely not suitable for more than ~20-30