Search in sources :

Example 1 with IGraphics3D

use of org.matheclipse.core.graphics.IGraphics3D in project symja_android_library by axkr.

the class GraphicsFunctions method exportGraphicsSVG.

public static boolean exportGraphicsSVG(StringBuilder buf, IAST data2D, Dimensions2D dim) {
    if (data2D.isList()) {
        boolean first = true;
        IAST rgbColor = F.NIL;
        IExpr opacity = F.num(0.75);
        for (int i = 1; i < data2D.size(); i++) {
            IExpr arg = data2D.get(i);
            if (arg.isAST()) {
                IAST primitive = (IAST) arg;
                if (primitive.isAST(S.RGBColor, 4)) {
                    rgbColor = primitive;
                    continue;
                }
                if (primitive.isAST(S.Opacity, 2)) {
                    opacity = primitive.arg1();
                    continue;
                }
                if (primitive.head().isBuiltInSymbol()) {
                    IBuiltInSymbol symbol = (IBuiltInSymbol) primitive.head();
                    IEvaluator evaluator = symbol.getEvaluator();
                    if (evaluator instanceof IGraphics3D) {
                        if (!first) {
                            buf.append(",");
                        }
                        first = false;
                        if (!((IGraphics3D) evaluator).graphics2D(buf, primitive, dim, rgbColor, opacity)) {
                            return false;
                        }
                        continue;
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr) IGraphics3D(org.matheclipse.core.graphics.IGraphics3D)

Example 2 with IGraphics3D

use of org.matheclipse.core.graphics.IGraphics3D in project symja_android_library by axkr.

the class ExpressionJSONConvert method exportGraphics3DJSON.

private static JsonNode exportGraphics3DJSON(IExpr data3D) {
    if (data3D.isList()) {
        IAST list = (IAST) data3D;
        ArrayNode temp = JSON_OBJECT_MAPPER.createArrayNode();
        for (int i = 1; i < list.size(); i++) {
            IExpr arg = list.getAST(i);
            if (arg.isAST()) {
                IAST ast = (IAST) arg;
                if (ast.head().isBuiltInSymbol()) {
                    StringBuilder buf = new StringBuilder();
                    IBuiltInSymbol symbol = (IBuiltInSymbol) ast.head();
                    IEvaluator evaluator = symbol.getEvaluator();
                    if (evaluator instanceof IGraphics3D) {
                    // JsonNode n = ((IGraphics3D) evaluator).graphics3D(buf, (IAST) ast);
                    // temp.add(n);
                    }
                }
            }
        }
        return temp;
    }
    ArrayNode temp = JSON_OBJECT_MAPPER.createArrayNode();
    temp.add(temp.toString());
    return temp;
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) IAST(org.matheclipse.core.interfaces.IAST) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IExpr(org.matheclipse.core.interfaces.IExpr) IGraphics3D(org.matheclipse.core.graphics.IGraphics3D)

Example 3 with IGraphics3D

use of org.matheclipse.core.graphics.IGraphics3D in project symja_android_library by axkr.

the class GraphicsFunctions method exportGraphics3DRecursive.

public static boolean exportGraphics3DRecursive(StringBuilder buf, IAST data3D) {
    if (data3D.isList()) {
        boolean first = true;
        IAST rgbColor = F.NIL;
        IExpr opacity = F.NIL;
        IAST list = data3D;
        for (int i = 1; i < list.size(); i++) {
            IExpr arg = list.get(i);
            if (arg.isAST()) {
                IAST ast = (IAST) arg;
                if (ast.isList()) {
                    StringBuilder primitivesBuffer = new StringBuilder();
                    if (exportGraphics3DRecursive(primitivesBuffer, ast)) {
                        if (!first) {
                            buf.append(",");
                        }
                        first = false;
                        buf.append(primitivesBuffer);
                    }
                } else if (ast.isRGBColor()) {
                    rgbColor = ast;
                } else if (ast.isAST(S.Opacity, 2)) {
                    opacity = ast.arg1();
                } else if (ast.head().isBuiltInSymbol()) {
                    IBuiltInSymbol symbol = (IBuiltInSymbol) ast.head();
                    IEvaluator evaluator = symbol.getEvaluator();
                    if (evaluator instanceof IGraphics3D) {
                        StringBuilder primitivesBuffer = new StringBuilder();
                        if (((IGraphics3D) evaluator).graphics3D(primitivesBuffer, ast, rgbColor, opacity)) {
                            if (!first) {
                                buf.append(",");
                            }
                            first = false;
                            buf.append(primitivesBuffer);
                        }
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr) IGraphics3D(org.matheclipse.core.graphics.IGraphics3D)

Example 4 with IGraphics3D

use of org.matheclipse.core.graphics.IGraphics3D in project symja_android_library by axkr.

the class GraphicsFunctions method primitivesDimension.

public static boolean primitivesDimension(IAST list, Dimensions2D dim) {
    for (int i = 1; i < list.size(); i++) {
        if (list.get(i).isAST()) {
            IAST primitive = (IAST) list.get(i);
            if (primitive.head().isBuiltInSymbol()) {
                IBuiltInSymbol symbol = (IBuiltInSymbol) primitive.head();
                IEvaluator evaluator = symbol.getEvaluator();
                if (evaluator instanceof IGraphics3D) {
                    if (!((IGraphics3D) evaluator).graphics2DDimension(primitive, dim)) {
                    // return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) IEvaluator(org.matheclipse.core.interfaces.IEvaluator) IAST(org.matheclipse.core.interfaces.IAST) IGraphics3D(org.matheclipse.core.graphics.IGraphics3D)

Aggregations

IGraphics3D (org.matheclipse.core.graphics.IGraphics3D)4 IAST (org.matheclipse.core.interfaces.IAST)4 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)4 IEvaluator (org.matheclipse.core.interfaces.IEvaluator)4 IExpr (org.matheclipse.core.interfaces.IExpr)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1