Exemple #1
0
        public static JsonArray Pack(CraterData c)
        {
            JsonArray a = new JsonArray(c.craterEffect,
                                        c.craterPoint,
                                        c.warpAmount);

            a.AddAll(Pack(c.noise));
            a.AddAll(Pack(c.comp));
            a.Add(c.craterMin);
            a.Add(c.craterMax);
            a.Add(c.craterLip);
            return(a);
        }
    public static void TestArrays()
    {
        JsonArray jarr = new JsonArray();

        int cnt = jarr.Count;
        cnt.ShouldBe(0);

        JsonValue[] stuff = new JsonValue[] {
            1, 2, 3,
            "a", "b", "c",
        };

        jarr.AddAll(stuff);
        jarr.Count.ShouldBe(6);
        jarr[0].ShouldBe(1);
        jarr[3].ShouldBe("a");
    }
Exemple #3
0
        /// <summary> Tell art breeder to save an image for us. </summary>
        /// <param name="model"> Model that is being used </param>
        /// <param name="id"> ID of image to save </param>
        /// <param name="parent"> Optional parent to allow artbreeder to record history.</param>
        public static void Save(string model, string id, params string[] parentIDs)
        {
            if (!models.ContainsKey(model))
            {
                return;
            }


            JsonObject payload = new JsonObject();
            JsonArray  parents = new JsonArray();

            if (parentIDs != null && parentIDs.Length > 0)
            {
                parents.AddAll(parentIDs);
            }
            payload["key"]         = id;
            payload["parent_keys"] = parents;
            payload["model_name"]  = model;

            Request.Post("https://artbreeder.com/save_tmp_image", payload.ToString(), (result) => {
                Log.Info($"Saved {id} @ {model}. Got {result}");
            }, Prepare);
        }