protected void btnSave_Click(object sender, ImageClickEventArgs e) { using (WXDBEntities db = new WXDBEntities()) { PicType model = new PicType(); model.Title = txttitle.Text; model.Description = txtDesc.Text; model.Orders = Convert.ToInt32(txtorders.Text); model.AddTime = DateTime.Now; model.Status = 0; model.UpdateTime = DateTime.Now; model.Extend = loginname; model.Extend1 = loginname; try { db.PicType.AddObject(model); db.SaveChanges(); jsHint.toUrl("信息" + model.Title + "增加成功!", "PicTypeList.aspx"); } catch (Exception ex) { jsHint.Alert(ex.Message); } } }
public Pic GenTree(Random r) { int chooser = r.Next(0, 3); PicType type = (PicType)chooser; return(new Pic(type, r, Settings.MIN_GEN_SIZE, Settings.MAX_GEN_SIZE, state.g, state.w, state.videoMode, state)); }
public void ProcessRequest(HttpContext context) { #region 进参数 StreamReader sr = new StreamReader(context.Request.InputStream); InputStream = sr.ReadToEnd(); #endregion PicType pictype = JsonConvert.DeserializeObject <PicType>(context.Request.Params[0]); string UserID = JsonConvert.DeserializeObject <string>(context.Request.Params[1]); if (context.Request.Files.Count > 0) { var file = context.Request.Files[0]; string uploadPath = "/Image/" + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + "/"; if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(context.Server.MapPath(uploadPath)); } string name = DateTime.Now.ToString("yyyyMMddHHmmssff") + ".png"; string filepath = context.Server.MapPath(uploadPath) + name; file.SaveAs(filepath); SaveInDatabase(uploadPath + name, pictype, UserID); } OutStream = JsonConvert.SerializeObject(Code); context.Response.Write(OutStream); }
private static PicType GetQuotePicType(FORMULA_LINETYPE linetype) { PicType result = PicType.TrendLine; if (linetype == FORMULA_LINETYPE.LINETYPE_DEFAULT) { result = PicType.TrendLine; } if (linetype == FORMULA_LINETYPE.LINETYPE_LINESTICK) { result = PicType.LineStick; } if (linetype == FORMULA_LINETYPE.LINETYPE_DOTLINE) { result = PicType.DotLine; } if (linetype == FORMULA_LINETYPE.LINETYPE_COLORSTICK) { result = PicType.MACDLine; } if (linetype == FORMULA_LINETYPE.LINETYPE_VOLSTICK) { result = PicType.VolumeLine; } if (linetype == FORMULA_LINETYPE.LINETYPE_COLOR3D) { result = PicType.COLOR3D; } return(result); }
/// <summary> /// 获取图片 /// </summary> /// <param name="uniacid">商户识别ID</param> /// <param name="picType">图片类型编码</param> /// <returns></returns> public async Task <IActionResult> GetPics(string uniacid, PicType picType) { try { var company = thisData.GetCompanyInfo(uniacid); var url = ""; foreach (var item in company.ProjPics) { if (item.Type == picType) { url = item.Url; break; } } if (string.IsNullOrEmpty(url)) { throw new Exception(); } return(await GetQiniuPic(uniacid, url)); } catch (Exception) { return(this.JsonErrorStatus()); } }
/// <summary> /// 获取指定记录 /// <param name="id">Id值</param> /// </summary> public List <ResPic> Search(int ObjId, PicType objType) { List <ResPic> returnValue = new List <ResPic>(); MySqlConnection oc = ConnectManager.Create(); MySqlCommand _cmdSearchResPicByProId = cmdSearchResPicByProId.Clone() as MySqlCommand; _cmdSearchResPicByProId.Connection = oc; try { _cmdSearchResPicByProId.Parameters["@ObjId"].Value = ObjId; _cmdSearchResPicByProId.Parameters["@ObjType"].Value = (int)objType; if (oc.State == ConnectionState.Closed) { oc.Open(); } MySqlDataReader reader = _cmdSearchResPicByProId.ExecuteReader(); while (reader.Read()) { returnValue.Add(new ResPic().BuildSampleEntity(reader)); } } finally { oc.Close(); oc.Dispose(); oc = null; _cmdSearchResPicByProId.Dispose(); _cmdSearchResPicByProId = null; GC.Collect(); } return(returnValue); }
internal void SavePic(PicType picType, string uniacid, string filename) { var company = GetCompanyModel(uniacid); if (company.QiNiuModel == null) { throw new Exception("error"); } company.QiNiuModel.UploadFile(filename); if (company.ProjPics == null) { company.ProjPics = new List <ProjPic>(); } if (company.ProjPics.Exists(x => x.Type == picType)) { company.QiNiuModel.DeleteFile(company.ProjPics.Find(x => x.Type == picType).Url); company.ProjPics.Find(x => x.Type == picType).Url = filename; } else { company.ProjPics.Add(new ProjPic { Type = picType, Url = filename }); } collection.UpdateOne(x => x.uniacid.Equals(uniacid), Builders <CompanyModel> .Update .Set(x => x.ProjPics, company.ProjPics)); }
public IActionResult SavePic(PicType picType) { try { long size = 0; var files = Request.Form.Files; var file = files[0]; var filename = ContentDispositionHeaderValue .Parse(file.ContentDisposition) .FileName .Trim('"'); var uniacid = HttpContext.Session.GetUniacID(); string saveDir = $@"{MainConfig.BaseDir}{MainConfig.TempDir}{uniacid}/"; if (!Directory.Exists(saveDir)) { Directory.CreateDirectory(saveDir); } string exString = filename.Substring(filename.LastIndexOf(".")); string saveName = Guid.NewGuid().ToString("N"); filename = $@"{saveDir}{saveName}{exString}"; size += file.Length; using (FileStream fs = System.IO.File.Create(filename)) { file.CopyTo(fs); fs.Flush(); } thisData.SavePic(picType, uniacid, filename); return(this.JsonSuccessStatus()); } catch (Exception) { return(this.JsonErrorStatus()); } }
/// <summary> /// 下载指定护照的全部类型图像 /// </summary> /// <param name="passportNo"></param> /// <returns></returns> public static int DownloadSelectedTypes(string passportNo, string dstPath, PicType type = PicType.Type01Normal | PicType.Type02Head | PicType.Type03IR) { int res = 0; int expected = 0; //现在没用,先保留,以后用 if (string.IsNullOrEmpty(dstPath)) { return(0); } if (type.HasFlag(PicType.Type01Normal)) { if (CheckAndDownloadIfNotExist(passportNo, PicType.Type01Normal)) { if (DownloadPic(passportNo, PicType.Type01Normal, dstPath + "\\" + GetFileName(passportNo, PicType.Type01Normal))) { ++res; } } ++expected; } if (type.HasFlag(PicType.Type02Head)) { if (CheckAndDownloadIfNotExist(passportNo, PicType.Type02Head)) { if (DownloadPic(passportNo, PicType.Type02Head, dstPath + "\\" + GetFileName(passportNo, PicType.Type02Head))) { ++res; } } ++expected; } if (type.HasFlag(PicType.Type03IR)) { if (CheckAndDownloadIfNotExist(passportNo, PicType.Type03IR)) { if (DownloadPic(passportNo, PicType.Type03IR, dstPath + "\\" + GetFileName(passportNo, PicType.Type03IR))) { ++res; } } ++expected; } return(res); //if (res > 0) //{ // if (showConfirm) // if (MessageBoxEx.Show("保存成功,是否打开所在文件夹?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) // Process.Start(dstPath); // return res; //} //if (showConfirm) // MessageBoxEx.Show("保存失败"); //return 0; }
private static PicType GetFunctionQuotePicType(FORMULA_FUNCTION_OUTPUT_TYPE linetype) { PicType result = PicType.TrendLine; switch (linetype) { case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_POLYLINE: result = PicType.PolyLine; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWLINE: result = PicType.DrawLine; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWKLINE: result = PicType.DrawKLine; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_STICKLINE: result = PicType.StickLine; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWICON: result = PicType.DrawIcon; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWTEXT: result = PicType.DrawText; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWNUMBER: result = PicType.DrawNumber; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWBAND: result = PicType.DrawBand; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWFLOATRGN: result = PicType.DrawFloatRGN; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWTWR: result = PicType.DrawTWR; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWFILLRGN: result = PicType.FillRGN; break; case FORMULA_FUNCTION_OUTPUT_TYPE.OUTPUT_TYPE_DRAWGBK: result = PicType.DrawGBK; break; } return(result); }
public void AddPic(int position, int size, PicType picType, int width, int height) { var block = new FlacPicBlock(position, size, picType, width, height); items.Add(block); if (PicBlock == null) { PicBlock = block; } }
private void paintCut_Event_Selected(PicType type) { if (type == PicType.ROI) { this.radioButton_ROI.Checked = true; } else if (type == PicType.Exclude) { this.radioButton_Exclude.Checked = true; } }
public JsonResult UploadFile(int saveSource, PicType fileType) { var Res = new JsonResult(); AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); if (Request.Files.Count > 0) { HttpPostedFileBase file = Request.Files[0]; int seat = file.FileName.LastIndexOf('.'); //返回位于String对象中指定位置的子字符串并转换为小写. string extension = file.FileName.Substring(seat).ToLower(); string fileSaveName = FileHelper.GetFileSaveName(extension); string path; if (saveSource == 1) { path = FileHelper.GetFileSavePath(0, fileType, null); } else { path = FileHelper.GetFileSavePath(0, PicType.Ignore, null); } string savepath = FileHelper.CreatePath(Server.MapPath(path)); string fullpath = Path.Combine(savepath, fileSaveName); file.SaveAs(fullpath); ResPic pic = new ResPic(); if (saveSource == 1) { pic.PicUrl = FileHelper.GetFileSavePath(0, fileType, fileSaveName); } else { pic.PicUrl = FileHelper.GetFileSavePath(0, PicType.Ignore, fileSaveName); } result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } else { result.Error = AppError.ERROR_FAILED; result.ErrorMessage = result.ExMessage = "请选择上传的文件!"; } Res.Data = result; return(Res); }
public static string GetFileName(string passportNo, PicType type) { string fileprefix = passportNo; if (type == PicType.Type02Head) { fileprefix += "Head"; } if (type == PicType.Type03IR) { fileprefix += "IR"; } return(fileprefix + ".jpg"); }
/// <summary> /// 批量下载护照指定类型图像 /// </summary> /// <param name="passportNo"></param> /// <param name="type"></param> /// <param name="dstname"></param> /// <returns></returns> public static int DownloadPicBatch(string[] passportNoList, PicType type, string dstPath) { int res = 0; for (int i = 0; i < passportNoList.Length; i++) { string fileName = GetFileName(passportNoList[i], type); if (DownloadPic(passportNoList[i], type, dstPath + "\\" + fileName)) { ++res; } } return(res); }
public static List <string> GetPics(string platform, PicType type, bool getFullPath, bool skipExtension) { List <string> result = new List <string>(); string picfolder = ""; if (type == PicType.BoxArt) { picfolder = Values.BoxartFolder; } else if (type == PicType.Title) { picfolder = Values.TitleFolder; } else { picfolder = Values.GameplayFolder; } var path = Environment.CurrentDirectory + "\\" + Values.PlatformsPath + "\\" + platform + "\\" + picfolder; if (!Directory.Exists(path)) { return(result); } var list = Directory.GetFiles(path).ToList(); if (!getFullPath) { foreach (var item in list) { if (skipExtension) { result.Add(RomFunctions.GetFileNameNoExtension(item)); } else { result.Add(RomFunctions.GetFileName(item)); } } } else { result = list; } return(result); }
/// <summary> /// 下载指定护照的指定类型图像 /// </summary> /// <param name="passportNo"></param> /// <param name="type"></param> /// <param name="dstname"></param> /// <returns></returns> public static bool DownloadPic(string passportNo, PicType type, string dstname) { if (!CheckAndDownloadIfNotExist(passportNo, type)) { MessageBoxEx.Show("找不到指定图像!"); return(false); } string fileName = GetFileName(passportNo, type); if (string.IsNullOrEmpty(dstname)) { return(false); } if (!File.Exists(dstname)) { File.Copy(GlobalUtils.PassportPicPath + "\\" + fileName, dstname); } return(true); }
private void SharedConstructor(PicType type, GraphicsDevice g, GameWindow w, GameState state) { this.g = g; this.w = w; this.type = type; imageCancellationSource = new CancellationTokenSource(); smallImage = GraphUtils.GetTexture(g, Color.Black); bigImage = GraphUtils.GetTexture(g, Color.Black); InitButtons(state); if (type != PicType.GRADIENT) { Trees = new AptNode[3]; Machines = new StackMachine[3]; } else { Trees = new AptNode[1]; Machines = new StackMachine[1]; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ((SysNewsmaster)this.Master).txtTitle = "图片类型信息的管理"; using (WXDBEntities db = new WXDBEntities()) { if (!string.IsNullOrEmpty(Request["del"]) && WebUtil.IsDigit(Request["del"])) { int tmpid = Convert.ToInt32(Request["del"]); PicType model = db.PicType.Where(s => s.Id == tmpid).FirstOrDefault(); if (model != null) { db.PicType.DeleteObject(model); db.SaveChanges(); } } } BindRepeater(); } }
/// <summary> /// 上传图片 /// 图片有三类图,原始大图,缩略中图,缩略小图。 /// url命名原则:大图是原始url,中图url后缀名之前为_m,中图url后缀名之前为_s /// 上传类型:1-宝贝图片;2-投票图片,4- 用户头像 0-其他 /// </summary> /// <param name="objid">图片所属对象ID</param> /// <param name="FileByte">文件</param> /// <param name="FileExtention">文件后缀名(扩展名)</param> /// <param name="type">上传类型:1-宝贝图片;2-投票图片,4- 用户头像 0-其他</param> /// <returns></returns> public static string UploadFile(int objid, byte[] fileByte, string fileExtention, PicType type) { DateTime time = DateTime.Now; string fileName = time.Ticks + "." + fileExtention; string fileSaveUrl = string.Format("/UploadPicture/{0}/{1}/{2}/{3}", type.ToString(), time.ToString("yyyyMM"), objid, fileName); try { string dir = Path.GetDirectoryName(HttpContext.Current.Server.MapPath(fileSaveUrl)); if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); Image image = null; // 保存原图 using (MemoryStream stream = new MemoryStream(fileByte, false)) { image = Image.FromStream(stream); image.Save(HttpContext.Current.Server.MapPath(fileSaveUrl), ImageFormat.Jpeg); } Dictionary<string, int> sizeList = new Dictionary<string, int>(); sizeList.Add("m", 320); sizeList.Add("s", 160); foreach (KeyValuePair<string, int> size in sizeList) { float bl = Math.Min((float)size.Value / image.Width, (float)size.Value / image.Height); Image img = image.GetThumbnailImage((int)(image.Width * bl), (int)(image.Height * bl), null, new IntPtr()); img.Save(Path.Combine(dir, size.Key + fileName), ImageFormat.Jpeg); } return fileSaveUrl; } catch (Exception ex) { return null; } }
public JsonResult AddPic(string sourcePath, PicType picType, string description) { var Res = new JsonResult(); AdvancedResult <ResPic> result = new AdvancedResult <ResPic>(); try { if (!CacheManagerFactory.GetMemoryManager().Contains(token)) { result.Error = AppError.ERROR_PERSON_NOT_LOGIN; } else { int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token)); ResPic pic = new ResPic(); pic.ObjId = userid; pic.ObjType = picType; pic.PicUrl = sourcePath; pic.PicDescription = description; pic.State = StateType.Active; int picid = ResPicAccessor.Instance.Insert(pic); pic.PicId = picid; result.Data = pic; result.Error = AppError.ERROR_SUCCESS; } } catch (Exception e) { result.Error = AppError.ERROR_FAILED; result.ExMessage = e.ToString(); } Res.Data = result; Res.JsonRequestBehavior = JsonRequestBehavior.AllowGet; return(Res); }
private void GetDrawImage(ValueInfo valueInfo, PicType picType, float threshod, ref Image drawImage) { if (valueInfo.IsValid) { if (valueInfo.Value < threshod) { //告警 drawImage = FanAndPowerRepaintInfo.AlarmImage[(int)picType]; _switchBrush.Color = Color.Yellow; } else { //正常 drawImage = FanAndPowerRepaintInfo.OKImage[(int)picType]; _switchBrush.Color = Color.Green; } } else { //无效 drawImage = FanAndPowerRepaintInfo.InvalidImage[(int)picType]; _switchBrush.Color = Color.Gray; } }
public static bool CheckAndDownloadIfNotExist(string passportNo, PicType type) { FtpHandler.ChangeFtpUri(ConfigurationManager.AppSettings["PassportPicPath"]); string fileName = GetFileName(passportNo, type); string picName = GlobalUtils.PassportPicPath + "\\" + fileName; if (File.Exists(picName)) //先检查本地是否存在 { //picPassportNo.Image = Image.FromFile(picName); return(true); } if (FtpHandler.FileExist(fileName)) { if (FtpHandler.Download(GlobalUtils.PassportPicPath, fileName)) { //picPassportNo.Image = Image.FromFile(picName); return(true); } } //picPassportNo.Image = Resources.PassportPictureNotFound; return(false); }
/// <summary> /// 上传图片 /// 图片有三类图,原始大图,缩略中图,缩略小图。 /// url命名原则:大图是原始url,中图url后缀名之前为_m,中图url后缀名之前为_s /// 上传类型:1-宝贝图片;2-投票图片,4- 用户头像 0-其他 /// </summary> /// <param name="objid">图片所属对象ID</param> /// <param name="FileByte">文件</param> /// <param name="FileExtention">文件后缀名(扩展名)</param> /// <param name="type">上传类型:1-宝贝图片;2-投票图片,4- 用户头像 0-其他</param> /// <returns></returns> public static string UploadFile(int objid, byte[] fileByte, string fileExtention, PicType type) { DateTime time = DateTime.Now; string fileName = GetFileSaveName("." + fileExtention); string fileSaveUrl = string.Format("/UploadPicture/{0}/{1}/{2}/{3}", type.ToString(), time.ToString("yyyyMM"), objid, fileName); try { string dir = Path.GetDirectoryName(HttpContext.Current.Server.MapPath(fileSaveUrl)); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } Image image = null; // 保存原图 using (MemoryStream stream = new MemoryStream(fileByte, false)) { image = Image.FromStream(stream); image.Save(HttpContext.Current.Server.MapPath(fileSaveUrl), ImageFormat.Jpeg); } Dictionary <string, int> sizeList = new Dictionary <string, int>(); sizeList.Add("m", 320); sizeList.Add("s", 160); foreach (KeyValuePair <string, int> size in sizeList) { float bl = Math.Min((float)size.Value / image.Width, (float)size.Value / image.Height); Image img = image.GetThumbnailImage((int)(image.Width * bl), (int)(image.Height * bl), null, new IntPtr()); img.Save(Path.Combine(dir, size.Key + fileName), ImageFormat.Jpeg); } return(fileSaveUrl); } catch (Exception ex) { return(null); } }
private void ReadPic(PicType type) { int size = PIC_H * PIC_W; if (type == PicType.CamRaw) { size *= 2; } //wait for data while (serial_.BytesToRead < size) { System.Threading.Thread.Sleep(20); } serial_.Read(buff_, 0, size); int inc = 1; int picW = PIC_W, picH = PIC_H; if (zoom2x) { inc++; picW *= 2; picH *= 2; } Bitmap bmp = new Bitmap(picW, picH); Graphics gr = Graphics.FromImage(bmp); gr.Clear(Color.White); int c = 0; if (type == PicType.CamRaw) { pic1.Image = bmp; for (int i = 0; i < picH; i += inc) { //for (int j = PIC_W; j >= 1; --j) for (int j = 0; j < picW; j += inc) { int pix = buff_[c++] << 8; //high byte pix += buff_[c++]; //low byte byte b = (byte)(pix & 0x1F); //lower 5 bits pix = pix >> 5; //discard lower 5 bits byte g = (byte)(pix & 0x3F); //lower 6 bits; g >>= 1; pix = pix >> 6; //discard lower 6 bits byte r = (byte)(pix & 0x1F); //rest 5 bits; Color col = Color.FromArgb(255 * r / 32, 255 * g / 32, 255 * b / 32); bmp.SetPixel(j, i, col); if (zoom2x) { bmp.SetPixel(j, i + 1, col); bmp.SetPixel(j + 1, i, col); bmp.SetPixel(j + 1, i + 1, col); } }//for } return; }//if byte blob_inc = 50; byte last_pix = 0; for (int i = 0; i < picH; i += inc) { //for (int j = PIC_W; j >= 1; --j) for (int j = 0; j < picW; j += inc) { byte pix = buff_[c++]; if (pix != 0) { if (type == PicType.Xor || type == PicType.Filtered || type == PicType.NoiseReduced) { pix = 255; } else if (type == PicType.Blobs) { if (pix != last_pix) { pix += blob_inc; last_pix = pix; blob_inc += 50; } } //else if } //if pix Color col = Color.FromArgb(pix, pix, pix); bmp.SetPixel(j, i, col); if (zoom2x) { bmp.SetPixel(j, i + 1, col); bmp.SetPixel(j + 1, i, col); bmp.SetPixel(j + 1, i + 1, col); } }//for j } if (type == PicType.Backg) { pic2.Image = bmp; } else if (type == PicType.Gray) { pic3.Image = bmp; } else if (type == PicType.Xor) { pic4.Image = bmp; } else if (type == PicType.NoiseReduced) { pic6.Image = bmp; } }
private void GetDrawImage(ValueInfo valueInfo, PicType picType, float threshod, ref Image drawImage) { if (valueInfo.IsValid) { if (valueInfo.Value < threshod) { //�澯 drawImage = FanAndPowerRepaintInfo.AlarmImage[(int)picType]; _switchBrush.Color = Color.Yellow; } else { //���� drawImage = FanAndPowerRepaintInfo.OKImage[(int)picType]; _switchBrush.Color = Color.Green; } } else { //��Ч drawImage = FanAndPowerRepaintInfo.InvalidImage[(int)picType]; _switchBrush.Color = Color.Gray; } }
public FlacPicBlock(int position, int size, PicType picType, int width, int height) : base(position, size) { this.PicType = picType; this.Width = width; this.Height = height; }
public string GetPicURL(string facebookId, PicType type = PicType.square, int width = 130, int height = 130) { // https://graph.facebook.com/10204916518582922/picture?type=square&height=130&width=130 return("https://graph.facebook.com/" + facebookId + "/picture?type=" + type + "&width=" + width + "&height=" + height); }
/// <summary> /// 批量下载指定护照的全部类型图像 /// </summary> /// <param name="passportNo"></param> /// <returns></returns> public static int DownloadSelectedTypesBatch(string[] passportNoList, string dstPath, PicType type = PicType.Type01Normal | PicType.Type02Head | PicType.Type03IR) { int res = 0; for (int i = 0; i < passportNoList.Length; i++) { res += DownloadSelectedTypes(passportNoList[i], dstPath, type); } return(res); }
public static string GetFileSavePath(int objid, PicType type, string fileName) { DateTime time = DateTime.Now; return(string.Format("/UploadPicture/{0}/{1}/{2}/{3}", type.ToString(), time.ToString("yyyyMM"), objid, fileName)); }
public Pic(PicType type, Random rand, int min, int max, GraphicsDevice g, GameWindow w, bool video, GameState state) { this.video = video; SharedConstructor(type, g, w, state); for (int i = 0; i < Trees.Length; i++) { Trees[i] = AptNode.GenerateTree(rand.Next(min, max), rand, video); Machines[i] = new StackMachine(Trees[i]); } if (type == PicType.GRADIENT) { var enum_size = Enum.GetNames(typeof(GradientType)).Length; var gradType = (GradientType)rand.Next(0, enum_size); float[] hues; switch (gradType) { case GradientType.ANALOGOUS: { hues = new float[3]; (hues[0], hues[1], hues[2]) = GetAnalogousHues((float)rand.NextDouble()); break; } case GradientType.COMPLEMENTARY: { hues = new float[2]; (hues[0], hues[1]) = GetComplementaryHues((float)rand.NextDouble()); break; } case GradientType.SPLIT_COMPLEMENTARY: { hues = new float[3]; (hues[0], hues[1], hues[2]) = GetSplitComplementaryHues((float)rand.NextDouble()); break; } case GradientType.SQUARE: { hues = new float[4]; (hues[0], hues[1], hues[2], hues[3]) = GetSquareHues((float)rand.NextDouble()); break; } case GradientType.TETRADIC: { hues = new float[4]; (hues[0], hues[1], hues[2], hues[3]) = GetTetradicHues((float)rand.NextDouble()); break; } case GradientType.TRIADIC: { hues = new float[3]; (hues[0], hues[1], hues[2]) = GetTriadicHues((float)rand.NextDouble()); break; } case GradientType.RANDOM: { hues = new float[rand.Next(Settings.MIN_GRADIENTS, Settings.MAX_GRADIENTS)]; for (int i = 0; i < hues.Length; i++) { hues[i] = (float)rand.NextDouble(); } break; } case GradientType.DOUBLE_COMPLEMENT: { hues = new float[4]; (hues[0], hues[1], hues[2], hues[3]) = GetTetradicHues((float)rand.NextDouble()); break; } case GradientType.DIAD: { hues = new float[2]; (hues[0], hues[1]) = GetComplementaryHues((float)rand.NextDouble()); break; } default: throw new Exception("hues broke"); } colors = hues.SelectF(h => { float s = (float)rand.NextDouble(); float v = (float)rand.NextDouble(); var(red, green, blue) = HSV2RGB(h, s, v); return(new Color(red, green, blue)); }); pos = new float[colors.Length]; int chance = Settings.STOP_GRADIENT_CHANCE * pos.Length; for (int i = 0; i < colors.Length; i++) { if (i > 0 && rand.Next(0, chance) == 0) { pos[i] = pos[i - 1]; } else { pos[i] = (float)(rand.NextDouble() * 2.0 - 1.0); } } Array.Sort(pos); } SetupTextbox(); }
public Pic(PicType type, GraphicsDevice g, GameWindow w, GameState state) { SharedConstructor(type, g, w, state); }