The mechanism of mydriasis depends on the agent being used. It usually involves either a disruption of the parasympathetic nerve supply to the eye (which normally constricts the pupil) or overactivity of the sympathetic nervous system (SNS). Pupil diameter also increases in reaction to cognitive tasks requiring memory and attention, and this phenomenon is used as an indicator of mental activation (‘arousal’) in psychophysiological experiments. Drugs
A mydriatic is an agent that induces dilation of the pupil. Drugs such as tropicamide are used in medicine to permit examination of the retina and other deep structures of the eye, and also to reduce painful ciliary muscle spasm (see cycloplegia). One effect of administration of a mydriatic is intolerance to bright light (photophobia). Purposefully-induced mydriasis via mydriatics is also used as a diagnostic test for Horners syndrome. Mydriasis can be induced via modulation of adrenergic or cholinergic signalling. Drugs that can cause mydriasis include:

Stimulants (typically monoaminergics) such as amphetamines, cocaine, MDMA, and mephedrone. Anticholinergics such as diphenhydramine, atropine, hyoscyamine, and scopolamine antagonize the muscarinic acetylcholine receptors in the eye. Blocking acetylcholine receptors reduces the pupillary muscles ability to constrict and causes dilation (which is critical in eye surgery procedures such as cataract surgery which require uninterrupted access to the inner eye via the pupillary aperture, thus requiring that the eye be both paralyzed and anesthetized before the procedure can go ahead). The antimuscarinic, tropicamide, may be used as a mydriastic agent during surgery. Serotonergics such as LSD, psilocybin mushrooms, mescaline and 2C-B. These drugs are typically hallucinogens.
The "afterimage on empty shape" effect is related to a class of effects referred to as contrast effects.In this effect, an empty (white) shape is presented on a colored background for several seconds. When the background color disappears (becomes white), an illusionary color similar to the original background is perceived within the shape. The mechanism of the effect is still unclear, and may be produced by one or two of the following mechanisms:

During the presentation of the empty shape on a colored background, the colored background induces an illusory complementary color ("induced color") inside the empty shape. After the disappearance of the colored background an afterimage of the "induced color" might appear inside the "empty shape". Thus, the expected color of the shape will be complementary to the "induced color", and therefore similar to the color of the original background. After the disappearance of the colored background, an afterimage of the background is induced. This induced color has a complementary color to that of the original background. It is possible that this background afterimage induces simultaneous contrast on the "empty shape". Simultaneous contrast is a psychophysical phenomenon of the change in the appearance of a color (or an achromatic stimulus) caused by the presence of a surrounding average color (or luminance).