ultimatepp/uppsrc/Draw/SDrawPut.cpp
cxl 5d10e4e6b5 Draw: SDraw
git-svn-id: svn://ultimatepp.org/upp/trunk@6084 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2013-05-19 20:48:58 +00:00

68 lines
1.5 KiB
C++

#include "Draw.h"
NAMESPACE_UPP
struct sColorize : public ImageMaker
{
Image img;
Color color;
virtual String Key() const {
StringBuffer h;
RawCat(h, color);
RawCat(h, img.GetSerialId());
return h;
}
virtual Image Make() const {
return SetColorKeepAlpha(img, color);
}
};
void SDraw::SysDrawImageOp(int x, int y, const Image& img, const Rect& src, Color color)
{
if(!IsNull(color)) {
sColorize m;
m.img = img;
m.color = color;
SysDrawImageOp(x, y, MakeImage(m), src, Null);
return;
}
Rect sr(Point(x, y) + cloff.Top().offset, (src & img.GetSize()).GetSize());
const Vector<Rect>& clip = cloff.Top().clip;
for(int i = 0; i < clip.GetCount(); i++) {
Rect cr = clip[i] & sr;
if(!cr.IsEmpty())
PutImage(cr.TopLeft(), img, Rect(cr.TopLeft() - sr.TopLeft() + src.TopLeft(), cr.GetSize()));
}
}
void SDraw::SysDrawImageOp(int x, int y, const Image& img, Color color)
{
SysDrawImageOp(x, y, img, img.GetSize(), color);
}
void SDraw::DrawRectOp(int x, int y, int cx, int cy, Color color)
{
Rect r = RectC(x, y, cx, cy);
r += cloff.Top().offset;
const Vector<Rect>& clip = cloff.Top().clip;
for(int i = 0; i < clip.GetCount(); i++) {
Rect cr = clip[i] & r;
if(!cr.IsEmpty())
PutRect(cr, color);
}
}
void SDraw::PutHorz(int x, int y, int cx)
{
DrawRect(x, y, cx, 1, docolor);
}
void SDraw::PutVert(int x, int y, int cy)
{
DrawRect(x, y, 1, cy, docolor);
}
END_UPP_NAMESPACE