float Easing::ease(float t) const { double easedT; if(t>=1) t=1; switch (m_type) { default: easedT = t; break; case In: easedT = applyFunction(t); break; case Out: easedT = 1-applyFunction(1-t); break; case In_Out: if (t < 0.5) { easedT = applyFunction(2*t)/2; } else { easedT = 1-applyFunction(2 - 2*t)/2; } break; } return easedT; }
int asc_support_main(ATerm *bottomOfStack, int argc, char *argv[], void (*register_all)(), void (*resolve_all)(), void (*init_all)(), unsigned const char* tableBaf, size_t tableSize, ATbool parseInput, ATBhandler handler) { PT_ParseTree pt = NULL; PT_Tree asfix; PT_Tree trm; PT_ParseTree rpt = NULL; ATerm reduct; const char *outputFilename; int numberOfInputs; ATinit(argc, argv, bottomOfStack); initApis(); register_all(); resolve_all(); init_all(); initParsetable(tableBaf, tableSize); SGLR_initialize(); OPT_initialize(); ASC_initializeDefaultOptions(); /* Check whether we're a ToolBus process */ if (toolbusMode(argc, argv)) { ATBinit(argc, argv, bottomOfStack); ATBconnect(NULL, NULL, -1, asf_toolbus_handler); ATBeventloop(); } else { handleOptions(argc, argv, parseInput); numberOfInputs = ASC_getNumberOfParseTrees(); outputFilename = ASC_getOutputFilename(); if (!streq(ASC_getPrefixFunction(),"")) { pt = applyFunction((const char*) ASC_getPrefixFunction(), (const char*) ASC_getResultNonTermName(), numberOfInputs, inputs); } else { if (numberOfInputs == 0) { pt = parsetreeFromFile("-", parseInput); } else if (numberOfInputs == 1) { pt = inputs[0]; } else if (numberOfInputs != 1) { ATerror("Can only process one argument if no -f and -r option " "are supplied.\n" "Did a -s argument eat up your -f or -r option?\n"); return 1; } } if (PT_isValidParseTree(pt)) { trm = PT_getParseTreeTop(pt); if (ASC_getVerboseFlag()) { ATfprintf(stderr,"Reducing ...\n"); } reduct = innermost(trm); if (ASC_getVerboseFlag()) { ATfprintf(stderr,"Reducing finished.\n"); } if (ASC_getStatsFlag()) { printStats(); } if (ASC_getOutputFlag()) { asfix = toasfix(reduct); rpt = PT_makeParseTreeTop(asfix, 0); if (parseInput) { FILE *fp = NULL; if (!strcmp(outputFilename, "-")) { fp = stdout; } else { fp = fopen(outputFilename, "wb"); } if (fp != NULL) { PT_yieldParseTreeToFile(rpt, fp, ATfalse); } else { ATerror("asc-main: unable to open %s for writing\n", outputFilename); } } else { if (ASC_getBafmodeFlag()) { ATwriteToNamedBinaryFile(PT_ParseTreeToTerm(rpt),outputFilename); } else { ATwriteToNamedTextFile(PT_ParseTreeToTerm(rpt),outputFilename); } } } } } return 0; }