Friday, March 31, 2006

effect of ROPs on background


reverse polish notation! read right to left!

P Selected pen
D Destination bitmap
a Bitwise AND
n Bitwise NOT (inverse)
o Bitwise OR
x Bitwise exclusive OR (XOR)

1 R2_BLACK 0 makes everything black
2 R2_NOTMERGEPEN DPon black outlining leaves bg unchanged, else pen is inverted and translucent (correct when bg is black, else darker)
3 R2_MASKNOTPEN DPna black outlining leaves bg unchanged, else pen is inverted and translucent (correct when bg is white, else darker)
4 R2_NOTCOPYPEN Pn overwrites bg, inverted drawing color
5 R2_MASKPENNOT PDna white outlining leaves bg unchanged, else pen is translucent (correct when bg is black, else darker)
6 R2_NOT Dn reverses bg: outlining or overlap shows bg unchanged (it's inverted twice)
7 R2_XORPEN DPx the coolest
8 R2_NOTMASKPEN DPan white outlining leaves bg unchanged, else pen is inverted and translucent (correct when bg is black, else lighter)
9 R2_MASKPEN DPa white outlining leaves bg unchanged, else pen is translucent (correct when bg is white, else darker)
10 R2_NOTXORPEN DPxn similar to xor
11 R2_NOP D drawing is invisible
12 R2_MERGENOTPEN DPno drawing in white leaves bg unchanged, else pen is inverted and translucent (opaque when bg is black)
13 R2_COPYPEN P straight copy
14 R2_MERGEPENNOT PDno black outlining leaves bg unchanged, else pen is translucent (correct when bg is white)
15 R2_MERGEPEN DPo black outlining leaves bg unchanged, else pen is translucent (correct when bg is black)
16 R2_WHITE 1 makes everything white

Saturday, March 25, 2006

more zoom/origin hell

The really weird thing is, it looks much better if the origin DOESN'T move in mirror mode!!! So it's actually not broken at the moment, except for

1) the move and return thing, and that's gone now that the normalized origin isn't zoomed
2) the problem with trail (outer rings move when they shouldn't)
3) make DIB must still use center zoom, otherwise scale to fit will screw up mirrored snapshots

Thursday, March 23, 2006

zoom/origin hell

Unmirrored zooming is supposed to be origin-centered, i.e. you zoom into or out of the ring origin. This isn't allowed in mirror mode because it would change the image. In mirror mode, you zoom into or out of the *mirror origin* (i.e. the center of the screen), and let the ring origin move as needed so that the image stays the same.

origin behavior with zooming, version 1.1:

mirror drag behavior
no no stationary: correct
yes no moves: correct
no yes stationary: correct
yes yes stationary (or with damping, moves and then returns): BOGUS

origin behavior with zooming, version 1.3 (trail):

mirror drag behavior
no no moves: BOGUS
yes no moves: correct
no yes stationary, but with damping, moves and then returns: BOGUS
yes yes stationary (or with damping, moves and then returns): BOGUS

Note that random origin may have the same problems as drag origin; it's hard to tell.

Trail complicates things further, because if the origin moves and returns, the trail pattern is lost.

Really there are two separate problems:

1) The damping feature of the origin motion prevents the ring origin from moving during zoom, or causes it to slip back. As a result, zooming in mirror mode changes the mirror imagery. This behavior always occurred in mirror mode, but somehow it went unnoticed; adding trail made it more noticeable, by causing it to affect unmirrored mode also.

The likely cause is that When you zoom in mirrored mode, the view's normalized origin changes, but the main frame's target origin (also in normalized space) DOESN'T change, so the view eventually slips back to the target origin. This can be solved by saving the normalized origin before zooming the view, and then correcting the target origin by the difference between the new normalized origin and the saved one.

2) Adding trail broke zooming into the ring origin. It could be argued that this was a bad idea anyway and that we should always zoom into the mirror origin, in which case this bug is actually a feature. However, this argument doesn't really hold up, because zooming into the ring origin is typically more interesting than zooming into whatever happens to be in the center of the screen.

This problem could possibly be solved by a temporary coordinate space change, so that the zoom scaling is done in ring-origin space instead of mirror-origin space. You could calculate the difference between the master ring origin and the center of the screen, and then for each ring, subtract the difference from its origin, multiply by zoom, and add the difference back on.

Monday, March 20, 2006

FillPath vs. StrokeAndFillPath

benchmark of FillPath vs. StrokeAndFillPath with null brush:
no significant difference

uniform curvature with respect to number of sides


// decrease curvature as number of sides increases
// behavior is somewhat more orderly but not as interesting either
double s = 1.0f / float(Ring.Sides - 2);
Ring.EvenCurve = float(m_Parms.EvenCurve * s);
Ring.OddCurve = float(m_Parms.OddCurve * s);