Exemplo n.º 1
0
bool Brush::operator==(const Brush& brush) const
{
	return radius1() == brush.radius1() && radius2() == brush.radius2() &&
			qAbs(hardness1() - brush.hardness1()) <= 1.0/256.0 &&
			qAbs(hardness2() - brush.hardness2()) <= 1.0/256.0 &&
			qAbs(opacity1() - brush.opacity1()) <= 1.0/256.0 &&
			qAbs(opacity2() - brush.opacity2()) <= 1.0/256.0 &&
			color1() == brush.color1() &&
			color2() == brush.color2() &&
			spacing() == brush.spacing() &&
			subpixel() == brush.subpixel() &&
			incremental() == brush.incremental() &&
			blendingMode() == brush.blendingMode();
}
Exemplo n.º 2
0
const ray& perspective_camera::generate_ray(ray& out, const unsigned int x, const unsigned int y, const unsigned int sx, const unsigned int sy)
{
	// maximum x is (get_display_width - 1)
	// maximum y is (get_display_height - 1)
	assert(x < get_display_width());
	assert(y < get_display_height());

	out.m_origin = get_eye();

	// calculate pixel coordinates by offsetting origin pixel
	point3 subpixel(m_origin_pixel.x + (m_pixel_pitch * x), m_origin_pixel.y - (m_pixel_pitch * y), -1.0);	// z = -1 because we are using the RH coordinate system
	subpixel.x = subpixel.x + ((m_subpixel_pitch * sx) + (m_subpixel_pitch * 0.5));
	subpixel.y = subpixel.y + ((m_subpixel_pitch * sy) + (m_subpixel_pitch * 0.5));

	out.m_direction = subpixel - out.m_origin;

	normalize(out.m_direction, out.m_direction);

	return out;
}
Exemplo n.º 3
0
void main()
{
	short val;
	int menu, pres;
	float p, mx, my;

	curmass = 0.5;
	curdrag = 0.15;
	prefsize(800,640);
	initbuzz();
	winopen("dynadraw");
	glcompat(GLC_OLDPOLYGON,1);
	subpixel(1);
	shademodel(FLAT);
	gconfig();
	qdevice(LEFTMOUSE);
	qdevice(MIDDLEMOUSE);
	qdevice(MENUBUTTON);
	qdevice(RIGHTSHIFTKEY); 
	qdevice(UPARROWKEY); 
	qdevice(DOWNARROWKEY); 
	qdevice(RIGHTSHIFTKEY); 
	makeframe();
	menu = defpup("dynadraw %t|toggle line style|save PostScript");
	width = initwidth;
	mouse.fixedangle = 1;
	while(1) {
		switch(qread(&val)) {
		case REDRAW:
			makeframe();
			break;
		case MIDDLEMOUSE:
			if(val) 
				clearscreen();
			break;
		case UPARROWKEY:
			if(val) 
				initwidth *= 1.414213;
			width = initwidth;
			break;
		case DOWNARROWKEY:
			if(val) 
				initwidth /= 1.414213;
			width = initwidth;
			break;
		case MENUBUTTON:
			if(val) {
				switch(dopup(menu)) {
				case 1: 
					mouse.fixedangle = 1-mouse.fixedangle;
					break;
				case 2: 
					savepolys();
					break;
				}
			}
			break;
		case LEFTMOUSE:
			if(val) {
				my = getmousey();
				if(my>0*SLIDERHIGH && my<2*SLIDERHIGH) {
					if(my>SLIDERHIGH) {
						while(getbutton(LEFTMOUSE)) {
							p = paramval();
							if(p != curmass) {
								curmass = p;
								showsettings();
							}
						}
					} else {
						while(getbutton(LEFTMOUSE)) {
							p = paramval();
							if(p != curdrag) {
								curdrag = p;
								showsettings();
							}
						}
					}
				} else {
					mx = 1.25*fgetmousex();
					my = fgetmousey();
					filtersetpos(&mouse,mx,my);
					odelx = 0.0;
					odely = 0.0;
					while(getbutton(LEFTMOUSE)) {
						mx = 1.25*fgetmousex();
						my = fgetmousey();
						if(filterapply(&mouse,mx,my)) {
							drawsegment(&mouse);
							color(0);
							buzz();
						}
					}
				}
			}
			break;
		}
	}
}