本文整理汇总了C++中TStroke类的典型用法代码示例。如果您正苦于以下问题:C++ TStroke类的具体用法?C++ TStroke怎么用?C++ TStroke使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TStroke类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: img
void StrokeSelection::changeColorStyle(int styleIndex)
{
TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
if (!tool)
return;
TVectorImageP img(tool->getImage(true));
if (!img)
return;
TPalette *palette = img->getPalette();
TColorStyle *cs = palette->getStyle(styleIndex);
if (!cs->isStrokeStyle())
return;
if (m_indexes.empty())
return;
UndoSetStrokeStyle *undo = new UndoSetStrokeStyle(img, styleIndex);
std::set<int>::iterator it;
for (it = m_indexes.begin(); it != m_indexes.end(); ++it) {
int index = *it;
assert(0 <= index && index < (int)img->getStrokeCount());
TStroke *stroke = img->getStroke(index);
undo->addStroke(stroke);
stroke->setStyle(styleIndex);
}
tool->notifyImageChanged();
TUndoManager::manager()->add(undo);
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:28,代码来源:strokeselection.cpp
示例2: getStroke
void ControlPointEditorStroke::setLinearSpeedOut(int index, bool linear,
bool updatePoints) {
TStroke *stroke = getStroke();
if (!stroke || m_controlPoints.size() == 1) return;
int cpCount = stroke->getControlPointCount();
int pointIndex = m_controlPoints[index].m_pointIndex;
if (pointIndex == cpCount - 1) {
if (isSelfLoop())
pointIndex = 0;
else
return;
}
int nextIndex =
(index == m_controlPoints.size() - 1 && isSelfLoop()) ? 0 : index + 1;
TThickPoint point = stroke->getControlPoint(pointIndex);
TThickPoint nextPoint = (pointIndex < cpCount - 3)
? stroke->getControlPoint(pointIndex + 3)
: TThickPoint();
if (linear) {
TThickPoint p(nextPoint - point);
double n = norm(p);
TThickPoint speedOut =
(n != 0.0) ? (0.01 / n) * p : TThickPoint(0.001, 0.001, 0.0);
m_controlPoints[index].m_speedOut = speedOut;
} else {
TThickPoint newNext2 = (nextPoint + point) * 0.5;
TThickPoint speedOut = (newNext2 - point) * 0.5;
m_controlPoints[index].m_speedOut = speedOut;
}
if (updatePoints) updateDependentPoint(index);
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:33,代码来源:controlpointselection.cpp
示例3: getStroke
void ControlPointEditorStroke::updatePoints() {
TStroke *stroke = getStroke();
if (!stroke) return;
bool selfLoop = isSelfLoop();
// Se e' rimasto un unico punto non ha senso che la stroke sia selfloop
if (selfLoop && m_controlPoints.size() == 1) {
stroke->setSelfLoop(false);
selfLoop = false;
}
// Se e' self loop devo aggiungere un punto in piu' al cpCount
std::vector<TThickPoint> points;
int cpCount = selfLoop ? m_controlPoints.size() + 1 : m_controlPoints.size();
if (cpCount == 1)
// Single point case
points.resize(3, getControlPoint(0));
else {
std::vector<std::pair<int, TThickPoint>> dependentPoints;
points.push_back(getControlPoint(0));
points.push_back(getSpeedOutPoint(0));
int i, pointIndex, currPointIndex = m_controlPoints[0].m_pointIndex + 1;
for (i = 1; i < cpCount; ++i) {
bool isLastSelfLoopPoint = (selfLoop && i == cpCount - 1);
int index = isLastSelfLoopPoint ? 0 : i;
TThickPoint p = getControlPoint(index);
pointIndex = isLastSelfLoopPoint ? getStroke()->getControlPointCount()
: m_controlPoints[index].m_pointIndex;
dependentPoints.clear();
getDependentPoints(index, dependentPoints);
int j;
for (j = 0; j < (int)dependentPoints.size() &&
dependentPoints[j].first < pointIndex;
j++) {
if (currPointIndex < dependentPoints[j].first) {
currPointIndex = dependentPoints[j].first;
points.push_back(dependentPoints[j].second);
}
}
points.push_back(p);
for (; j < (int)dependentPoints.size(); j++) {
if (currPointIndex < dependentPoints[j].first) {
currPointIndex = dependentPoints[j].first;
points.push_back(dependentPoints[j].second);
}
}
}
}
stroke->reshape(&points[0], points.size());
m_vi->notifyChangedStrokes(m_strokeIndex);
}
开发者ID:gab3d,项目名称:opentoonz,代码行数:59,代码来源:controlpointselection.cpp
示例4: getRasterPoint
/*-- (StylePickerTool内で)LineとAreaを切り替えてPickできる。mode: 0=Area, 1=Line, 2=Line&Areas(default) --*/
int StylePicker::pickStyleId(const TPointD &pos, double radius2, int mode) const
{
int styleId = 0;
if (TToonzImageP ti = m_image) {
TRasterCM32P ras = ti->getRaster();
TPoint point = getRasterPoint(pos);
if (!ras->getBounds().contains(point))
return -1;
TPixelCM32 col = ras->pixels(point.y)[point.x];
switch (mode) {
case 0: //AREAS
styleId = col.getPaint();
break;
case 1: //LINES
styleId = col.getInk();
break;
case 2: //ALL (Line & Area)
default:
styleId = col.isPurePaint() ? col.getPaint() : col.getInk();
break;
}
} else if (TRasterImageP ri = m_image) {
const TPalette *palette = m_palette.getPointer();
if (!palette)
return -1;
TRaster32P ras = ri->getRaster();
if (!ras)
return -1;
TPoint point = getRasterPoint(pos);
if (!ras->getBounds().contains(point))
return -1;
TPixel32 col = ras->pixels(point.y)[point.x];
styleId = palette->getClosestStyle(col);
} else if (TVectorImageP vi = m_image) {
// prima cerca lo stile della regione piu' vicina
TRegion *r = vi->getRegion(pos);
if (r)
styleId = r->getStyle();
// poi cerca quello della stroke, ma se prima aveva trovato una regione, richiede che
// il click sia proprio sopra la stroke, altrimenti cerca la stroke piu' vicina (max circa 10 pixel)
const double maxDist2 = (styleId == 0) ? 100.0 * radius2 : 0;
bool strokeFound;
double dist2, w, thick;
UINT index;
//!funzionerebbe ancora meglio con un getNearestStroke che considera
//la thickness, cioe' la min distance dalla outline e non dalla centerLine
strokeFound = vi->getNearestStroke(pos, w, index, dist2);
if (strokeFound) {
TStroke *stroke = vi->getStroke(index);
thick = stroke->getThickPoint(w).thick;
if (dist2 - thick * thick < maxDist2) {
assert(stroke);
styleId = stroke->getStyle();
}
}
}
return styleId;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:60,代码来源:stylepicker.cpp
示例5: contains
bool TRegion::Imp::contains(const TStroke &s, bool mayIntersect) const
{
if (!getBBox().contains(s.getBBox()))
return false;
if (mayIntersect && thereAreintersections(s))
return false;
return contains(s.getThickPoint(0.5));
}
开发者ID:AmEv7Fam,项目名称:opentoonz,代码行数:9,代码来源:tregion.cpp
示例6: getDelta
double TStrokeBenderDeformation::getDelta(const TStroke &s, double w) const {
double totalLenght = s.getLength();
if (totalLenght != 0) {
double val = s.getLength(w) / totalLenght * (M_PI * 10.0);
return sin(val);
}
return 0;
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:10,代码来源:tstrokedeformations.cpp
示例7: getClosestStroke
bool PinchTool::moveCursor(const TPointD &pos)
{
double w = 0.0;
TStroke *stroke = getClosestStroke(pos, w);
if (!stroke)
return false;
m_cursor = stroke->getThickPoint(w);
return true;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:10,代码来源:pinchtool.cpp
示例8: TStroke
TRect TRasterImageUtils::addStroke(const TRasterImageP &ri, TStroke *stroke, TRectD clip,
double opacity, bool doAntialiasing)
{
TStroke *s = new TStroke(*stroke);
TPoint riCenter = ri->getRaster()->getCenter();
s->transform(TTranslation(riCenter.x, riCenter.y));
TRect rect = fastAddInkStroke(ri, s, clip, opacity, doAntialiasing);
rect -= riCenter;
delete s;
return rect;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:11,代码来源:trasterimageutils.cpp
示例9: vimage
bool PinchTool::keyDown(int key,
TUINT32 flags,
const TPoint &pos)
{
m_deformation->reset();
#if 0
char c = (char)key;
if(c == 'p' ||
c == 'P' )
{
TVectorImageP vimage(getImage());
if(!vimage)
return false;
char fileName[] = {"c:\\toonz_input.sdd"};
ofstream out_file(fileName);
if(!out_file)
{
cerr<<"Error on opening: "<<fileName<<endl;
return false;
}
out_file<<"# VImage info\n";
out_file<<"# Number of stroke:\n";
const int max_number_of_strokes = vimage->getStrokeCount();
out_file<<max_number_of_strokes<<endl;
int number_of_strokes = 0;
const int cp_for_row=3;
while( number_of_strokes<max_number_of_strokes)
{
TStroke* ref = vimage->getStroke(number_of_strokes);
out_file<<endl;
out_file<<"# Number of control points for stroke:\n";
const int max_number_of_cp = ref->getControlPointCount();
out_file<<max_number_of_cp <<endl;
out_file<<"# Control Points:\n";
int number_of_cp=0;
while( number_of_cp<max_number_of_cp )
{
out_file<<ref->getControlPoint(number_of_cp)<<" ";
if(!((number_of_cp+1)%cp_for_row)) // add a new line after ten points
out_file<<endl;
number_of_cp++;
}
out_file<<endl;
number_of_strokes++;
}
}
#endif
return true;
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:52,代码来源:pinchtool.cpp
示例10: getDisplacement
TThickPoint TStrokeThicknessDeformation::getDisplacement(const TStroke &stroke,
double w) const {
// potenziale exp^(-x^2) limitato tra
// [-c_maxLenghtOfGaussian,c_maxLenghtOfGaussian]
double diff = stroke.getLength(w);
diff = diff - m_startParameter;
if (fabs(diff) <= m_lengthOfDeformation) {
// modulo il vettore spostamento in funzione del potenziale
// il termine (1.0/m_lengthOfDeformation) * 3 scala
// il punto in diff su un sistema di coordinate
// normalizzato, associato con la curva exp^(-x^2)
diff *= (1.0 / m_lengthOfDeformation) * c_maxLenghtOfGaussian;
if (m_vect)
return gaussianPotential(diff) * TThickPoint(*m_vect, 0);
else {
double outVal = gaussianPotential(diff);
return TThickPoint(0, 0, outVal);
}
}
return TThickPoint();
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:25,代码来源:tstrokedeformations.cpp
示例11: getDisplacementForControlPoint
//-----------------------------------------------------------------------------
TThickPoint TStrokeThicknessDeformation::getDisplacementForControlPoint(
const TStroke &stroke, UINT n) const {
// potenziale exp^(-x^2) limitato tra
// [-c_maxLenghtOfGaussian,c_maxLenghtOfGaussian]
double diff = stroke.getLengthAtControlPoint(n);
diff = diff - m_startParameter;
if (fabs(diff) <= m_lengthOfDeformation) {
// modulo il vettore spostamento in funzione del potenziale
// il termine (1.0/m_lengthOfDeformation) * 3 scala
// il punto in diff su un sistema di coordinate
// normalizzato, associato con la curva exp^(-x^2)
diff *= (1.0 / m_lengthOfDeformation) * c_maxLenghtOfGaussian;
TThickPoint delta;
if (m_vect) {
// tsign(m_vect->y) * 0.1
delta =
TThickPoint(0, 0, m_versus * norm(*m_vect) * gaussianPotential(diff));
} else {
double outVal = gaussianPotential(diff);
delta = TThickPoint(0, 0, outVal);
}
// TThickPoint cp = stroke.getControlPoint(n);
// if(cp.thick + delta.thick<0.001) delta.thick = 0.001-cp.thick;
return delta;
}
return TThickPoint();
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:32,代码来源:tstrokedeformations.cpp
示例12: assert
bool SelfLoopDeformation::check(Context *dragger,
DraggerStatus *status)
{
assert(status && dragger && "Not dragger or status available");
assert(!"SelfLoopDeformation::check not yet implemented!");
// lengthOfAction_ = status->lengthOfAction_;
// deformerSensibility_ = status->deformerSensibility_;
// stroke2move_ = status->stroke2change_;
TStroke *s = stroke2move_;
// double &w = status->w_;
if (s->isSelfLoop()) {
// dragger->changeDeformation(SelfLoopDeformation::instance());
// SelfLoopDeformation::instance()->activate(dragger,
// status);
return true;
}
return false;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:19,代码来源:SelfLoopDeformation.cpp
示例13: norm
double ToonzExt::StrokeParametricDeformer::getDelta(const TStroke &stroke,
double w) const {
#if 0
double w0 = w;
if(w0 == 1.0)
return norm( stroke.getSpeed(1.0));
double tmp = stroke.getLength(w0);
tmp+=1.0;
double w1 = stroke.getParameterAtLength(tmp);
/*
double w1 = w + 0.01;
if(w1>1.0)
{
w0 = 1.0 - 0.01;
w1 = 1.0;
}
*/
const double dx = 1.0; //stroke.getLength(w0,w1);
TThickPoint pnt = this->getDisplacement(stroke,w1) -
this->getDisplacement(stroke,w0);
double dy = sqrt( sq(pnt.x) + sq(pnt.y) + sq(pnt.thick) );
assert(dx!=0.0);
return dy/dx;
/*
// the increaser is wrong than this value need to be the deformation
// value
// is norm
TThickPoint pnt = this->getDisplacement(stroke,
w);
return sqrt( sq(pnt.x) + sq(pnt.y) + sq(pnt.thick) );
//return pot_->gradient(w);
*/
#endif
return this->getDisplacement(stroke, w).y;
}
开发者ID:SaierMe,项目名称:opentoonz,代码行数:42,代码来源:StrokeParametricDeformer.cpp
示例14: renormalizeImage
void renormalizeImage(TVectorImage *vi)
{
int i, j;
int n = vi->getStrokeCount();
std::vector<ControlPoint> points;
points.reserve(n * 2);
for (i = 0; i < n; i++) {
TStroke *stroke = vi->getStroke(i);
int m = stroke->getControlPointCount();
if (m > 0) {
if (m == 1)
points.push_back(ControlPoint(stroke, 0));
else {
points.push_back(ControlPoint(stroke, 0));
points.push_back(ControlPoint(stroke, m - 1));
}
}
}
int count = points.size();
for (i = 0; i < count; i++) {
ControlPoint &pi = points[i];
TPointD posi = pi.getPoint();
TPointD center = posi;
std::vector<int> neighbours;
neighbours.push_back(i);
for (j = i + 1; j < count; j++) {
TPointD posj = points[j].getPoint();
double d = tdistance(posj, posi);
if (d < 0.01) {
neighbours.push_back(j);
center += posj;
}
}
int m = neighbours.size();
if (m == 1)
continue;
center = center * (1.0 / m);
for (j = 0; j < m; j++)
points[neighbours[j]].setPoint(center);
}
}
开发者ID:CroW-CZ,项目名称:opentoonz,代码行数:41,代码来源:toutlinevectorizer.cpp
示例15: computeAverageThickness
void TColorStyle::drawStroke(TFlash &flash, const TStroke *s) const {
bool isCenterline = false;
double minThickness, maxThickness = 0;
std::wstring quality = flash.getLineQuality();
double thickness = computeAverageThickness(s, minThickness, maxThickness);
if (minThickness == maxThickness && minThickness == 0) return;
if (quality == TFlash::ConstantLines)
isCenterline = true;
else if (quality == TFlash::MixedLines &&
(maxThickness == 0 || minThickness / maxThickness > 0.5))
isCenterline = true;
else if (quality == TFlash::VariableLines &&
maxThickness - minThickness <
0.16) // Quando si salva il pli, si approssima al thick.
// L'errore di approx e' sempre 0.1568...
isCenterline = true;
// else assert(false);
flash.setFillColor(getAverageColor());
// flash.setFillColor(TPixel::Red);
TStroke *saux = const_cast<TStroke *>(s);
if (isCenterline) {
saux->setAverageThickness(thickness);
flash.setThickness(s->getAverageThickness());
flash.setLineColor(getAverageColor());
flash.drawCenterline(s, false);
} else {
saux->setAverageThickness(0);
if (!flash.drawOutline(saux)) {
flash.setThickness(thickness);
flash.setLineColor(getAverageColor());
flash.drawCenterline(s, false);
}
}
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:36,代码来源:tcolorstyles.cpp
注:本文中的TStroke类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论