AnimationState* Animatable::BlendTo(const String& name, float duration /*= 1.0f*/) { AnimationState* state = GetState(name); if (!state) { o2Debug.LogWarning("Can't blend animation: " + name); return nullptr; } return BlendTo(state, duration); }
void MpDensityPlot::Draw (Scene& scene, const Matrix& z, const ColorMap &cmap, double cmin, double cmax, int mode) { if (! scene.IsOpen()) Matpack.Error("MpDensityPlot: scene is not open"); int outlined = (mode & MpDensityPlot::Outlined) ? (Fill | Outline) : Fill; ColorB BlendFrom(0,0,0), BlendTo(255,255,255); // black to white // scale factor for color mapping int ncmap; double cscale = 0, dz = cmax - cmin; if (cmap) { ncmap = cmap.Size()-1; cscale = (dz == 0.0) ? 0.0 : ncmap/dz; } else ncmap = 0; // plot all density cells for (int x = z.Clo(); x <= z.Chi(); ++x) { double dx1 = (x != z.Clo()) ? 0.5 : 0, dx2 = (x != z.Chi()) ? 0.5 : 0; for (int y = z.Rlo(); y <= z.Rhi(); ++y) { // calculate color long color; if (ncmap) { int c = int((z[y][x]-cmin)*cscale); MpForceRange(c,0,ncmap); color = scene.NewColor(cmap[c]); } else { // linear map to color range black - white double intens = (dz == 0.0) ? 0.0 : (z[y][x] - cmin)/dz; MpForceRange(intens,0.0,1.0); color = scene.NewColor(((1.0-intens)*BlendFrom.red+intens*BlendTo.red)/255.0, ((1.0-intens)*BlendFrom.green+intens*BlendTo.green)/255.0, ((1.0-intens)*BlendFrom.blue+intens*BlendTo.blue)/255.0, RGB); } // draw squares double dy1 = (y != z.Rlo()) ? 0.5 : 0, dy2 = (y != z.Rhi()) ? 0.5 : 0; double px[4] = {y-dy1,y+dy2,y+dy2,y-dy1}, py[4] = {x-dx1,x-dx1,x+dx2,x+dx2}; scene.Polygon(4,px,py,color,outlined); } } }
AnimationState* Animatable::BlendTo(const Animation& animation, float duration /*= 1.0f*/) { AnimationState* state = AddState("unknown", animation, AnimationMask(), 1.0f); return BlendTo(state, duration); }
AnimationState* Animatable::BlendTo(const Animation& animation, const String& name, float duration /*= 1.0f*/) { AnimationState* state = AddState(name, animation, AnimationMask(), 1.0f); return BlendTo(state, duration); }