示例#1
0
synfig::Layer::Handle
LinearGradient::hit_check(synfig::Context context, const synfig::Point &point)const
{
	if(get_blend_method()==Color::BLEND_STRAIGHT && get_amount()>=0.5)
		return const_cast<LinearGradient*>(this);
	if(get_amount()==0.0)
		return context.hit_check(point);
	if((get_blend_method()==Color::BLEND_STRAIGHT || get_blend_method()==Color::BLEND_COMPOSITE) && color_func(point).get_a()>0.5)
		return const_cast<LinearGradient*>(this);
	return context.hit_check(point);
}
示例#2
0
synfig::Layer::Handle
Layer_PasteCanvas::hit_check(synfig::Context context, const synfig::Point &pos)const
{
    if(depth==MAX_DEPTH)return 0;
    depth_counter counter(depth);

    Transformation transformation(get_summary_transformation());

    bool children_lock=param_children_lock.get(bool(true));
    ContextParams cp(context.get_params());
    apply_z_range_to_params(cp);
    if (canvas) {
        Point target_pos = transformation.back_transform(pos);

        if(canvas && get_amount() && canvas->get_context(cp).get_color(target_pos).get_a()>=0.25)
        {
            if(!children_lock)
            {
                return canvas->get_context(cp).hit_check(target_pos);
            }
            return const_cast<Layer_PasteCanvas*>(this);
        }
    }
    return context.hit_check(pos);
}
示例#3
0
synfig::Layer::Handle
Layer_PasteCanvas::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	if(depth==MAX_DEPTH)return 0;depth_counter counter(depth);

	Vector origin=param_origin.get(Vector());
	Vector focus=param_focus.get(Vector());
	Real zoom=param_zoom.get(Real());
	bool children_lock=param_children_lock.get(bool(true));
	ContextParams cp(context.get_params());
	cp.z_range=param_z_range.get(bool());
	cp.z_range_position=param_z_range_position.get(Real());
	cp.z_range_depth=param_z_range_depth.get(Real());
	cp.z_range_blur=param_z_range_blur.get(Real());
	if (canvas) {
		Point target_pos=(pos-focus-origin)/exp(zoom)+focus;

		if(canvas && get_amount() && canvas->get_context(cp).get_color(target_pos).get_a()>=0.25)
		{
			if(!children_lock)
			{
				return canvas->get_context(cp).hit_check(target_pos);
			}
			return const_cast<Layer_PasteCanvas*>(this);
		}
	}
	return context.hit_check(pos);
}
示例#4
0
synfig::Layer::Handle
SimpleCircle::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	if((pos-center).mag()<radius)
		return const_cast<SimpleCircle*>(this);
	else
		return context.hit_check(pos);
}
示例#5
0
Layer::Handle
Layer_MeshTransform::hit_check(synfig::Context context, const synfig::Point &point)const
{
	Vector v;
	return mesh.transform_coord_world_to_texture(point, v)
		 ? context.hit_check(v)
		 : Layer::Handle();
}
示例#6
0
synfig::Layer::Handle
Metaballs::hit_check(synfig::Context context, const synfig::Point &point)const
{
	Real density(totaldensity(point));

	if (density <= 0 || density > 1 || get_amount() == 0)
		return context.hit_check(point);

	synfig::Layer::Handle tmp;

	if (get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(point)))
		return tmp;

	if (Color::is_onto(get_blend_method()) && !(context.hit_check(point)))
		return 0;

	return const_cast<Metaballs*>(this);
}
synfig::Layer::Handle
SimpleCircle::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	Point center=param_center.get(Point());
	Real radius=param_radius.get(Real());

	if((pos-center).mag()<radius)
		return const_cast<SimpleCircle*>(this);
	else
		return context.hit_check(pos);
}
示例#8
0
synfig::Layer::Handle
NoiseDistort::hit_check(synfig::Context context, const synfig::Point &point)const
{
	if(get_blend_method()==Color::BLEND_STRAIGHT && get_amount()>=0.5)
		return const_cast<NoiseDistort*>(this);
	if(get_amount()==0.0)
		return context.hit_check(point);
	if(color_func(point,0,context).get_a()>0.5)
		return const_cast<NoiseDistort*>(this);
	return synfig::Layer::Handle();
}
示例#9
0
synfig::Layer::Handle
Layer_Stretch::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	Vector amount=param_amount.get(Vector());
	Point center=param_center.get(Point());
	
	Point npos(pos);
	npos[0]=(npos[0]-center[0])/amount[0]+center[0];
	npos[1]=(npos[1]-center[1])/amount[1]+center[1];
	return context.hit_check(npos);
}
示例#10
0
synfig::Layer::Handle
XORPattern::hit_check(synfig::Context context, const synfig::Point &getpos)const
{
	// if we have a zero amount
	if(get_amount()==0.0)
		// then the click passes down to our context
		return context.hit_check(getpos);

	synfig::Layer::Handle tmp;
	// if we are behind the context, and the click hits something in the context
	if(get_blend_method()==Color::BLEND_BEHIND && (tmp=context.hit_check(getpos)))
		// then return the thing it hit in the context
		return tmp;

	// if we're using an 'onto' blend method and the click missed the context
	if(Color::is_onto(get_blend_method()) && !(tmp=context.hit_check(getpos)))
		// then it misses everything
		return 0;

	// otherwise the click hit us, since we're the size of the whole plane
	return const_cast<XORPattern*>(this);
}
synfig::Layer::Handle
Layer_SphereDistort::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	Vector center=param_center.get(Vector());
	double radius=param_radius.get(double());
	double percent=param_amount.get(double());
	int type=param_type.get(int());
	bool clip=param_clip.get(bool());
	
	bool clipped;
	Point point(sphtrans(pos,center,radius,percent,type,clipped));
	if(clip && clipped)
		return 0;
	return context.hit_check(point);
}
示例#12
0
synfig::Layer::Handle
Warp::hit_check(synfig::Context context, const synfig::Point &p)const
{
	Point src_tl=param_src_tl.get(Point());
	Point src_br=param_src_br.get(Point());
	bool clip=param_clip.get(bool());
	
	Point newpos(transform_forward(p));

	if(clip)
	{
		Rect rect(src_tl,src_br);
		if(!rect.is_inside(newpos))
			return 0;
	}

	return context.hit_check(newpos);
}
示例#13
0
synfig::Layer::Handle
Layer_Bitmap::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	Point surface_pos;
	surface_pos=pos-tl;

	surface_pos[0]/=br[0]-tl[0];
	if(surface_pos[0]<=1.0 && surface_pos[0]>=0.0)
	{
		surface_pos[1]/=br[1]-tl[1];
		if(surface_pos[1]<=1.0 && surface_pos[1]>=0.0)
		{
			return const_cast<Layer_Bitmap*>(this);
		}
	}

	return context.hit_check(pos);
}
示例#14
0
synfig::Layer::Handle
Layer_PasteCanvas::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	if(depth==MAX_DEPTH)return 0;depth_counter counter(depth);

	if (canvas) {
		Point target_pos=(pos-focus-origin)/exp(zoom)+focus;

		if(canvas && get_amount() && canvas->get_context().get_color(target_pos).get_a()>=0.25)
		{
			if(!children_lock)
			{
				return canvas->get_context().hit_check(target_pos);
			}
			return const_cast<Layer_PasteCanvas*>(this);
		}
	}
	return context.hit_check(pos);
}
示例#15
0
synfig::Layer::Handle
Zoom::hit_check(synfig::Context context, const synfig::Point &pos)const
{
	Vector center=param_center.get(Vector());
	return context.hit_check((pos-center)/exp(param_amount.get(Real()))+center);
}
示例#16
0
synfig::Layer::Handle
CurveWarp::hit_check(synfig::Context context, const synfig::Point &point)const
{
	return context.hit_check(transform(point));
}