public static void Main() { rectangle r1 = new rectangle(10, 20); r1.getArea(); triangle t1 = new triangle(30, 40); }
public void Render(long time, rectangle r) { var c = (test++ % 25) / 25f; var cc = new Color(c, c, c, 255); //GL.Viewport(0, 0, r.width, r.height); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? #if TRIANGLE this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle #else // this.vertices.Apply(this.shader); if (this.frame != null) { GL.BindTexture(TextureTarget.Texture2D, (this.frame.Buffer as IOpenGLFrame).Textures[0]); this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 6); // Starting from vertex 0; 6 vertices total -> 2 triangle GL.DisableVertexAttribArray(0); frame.Dispose(); frame = null; } #endif }
// Main Method public static void Main(String [] args) { // creating object of class // "rectangle", named as "rect" rectangle rect = new rectangle(); // these two lines are normal calling // of that two methods // rect.area(6.3, 4.2); // rect.perimeter(6.3, 4.2); // creating delegate object, name as "rectdele" // and pass the method as parameter by // class object "rect" rectDelegate rectdele = new rectDelegate(rect.area); // also can be written as // rectDelegate rectangle = rect.area; // call 2nd method "perimeter" // Multicasting rectdele += rect.perimeter; // pass the values in two method // by using "Invoke" method rectdele.Invoke(6.3, 4.2); Console.WriteLine(); // call the methods with // different values rectdele.Invoke(16.3, 10.3); }
private void Form1_Load(object sender, EventArgs e) { var sb = new StringBuilder(); var rec1 = new rectangle(); this.shps.Text += rec1.heigth.ToString() + " " + rec1.width.ToString() + "\r\n"; var rec2 = new rectangle(); this.shps.Text += rec2.heigth.ToString() + " " + rec2.width.ToString() + "\r\n"; var tr1 = new triangle(); this.shps.Text += tr1.a + " " + tr1.b + " " + tr1.c + "\r\n"; var tr2 = new triangle(); this.shps.Text += tr2.a + " " + tr2.b + " " + tr2.c + "\r\n"; var ccl1 = new circle(); var ccl2 = new circle(); rec1.insertShape(tr1); rec1.insertShape(ccl1); tr1.insertShape(tr2); //rec1 - composition, rec2- composition chi, ccl2- composition chi shapes.Add(rec1); shapes.Add(rec2); shapes.Add(ccl2); }
public QuadTree(int pLevel, rectangle pBounds) { level = pLevel; QuadObjects = new List <Prism>(); bounds = pBounds; subnodes = new QuadTree[4]; }
void IRenderOwner.render(IRenderFrame destination, long time, rectangle r) { // using (var lck = this.Renderer.GetDrawLock()) { // var state = this.Renderer.StartRender(destination, r); // GL.MatrixMode(MatrixMode.Projection); // GL.LoadIdentity(); // this.xwt.StartRender(renderer, this); var c = (test++ % 25) / 25f; var cc = new Xwt.Drawing.Color(c, c, c, 255); GL.ClearColor((float)cc.Red, (float)cc.Green, (float)cc.Blue, (float)cc.Alpha); GL.Clear(ClearBufferMask.ColorBufferBit /*ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit*/); // We're not using stencil buffer so why bother with clearing? this.vertices.Apply(this.shader); GL.DrawArrays(BeginMode.Triangles, 0, 3); // Starting from vertex 0; 3 vertices total -> 1 triangle GL.DisableVertexAttribArray(0); // this.Renderer.EndRender(state); this.Renderer.Present(destination, r, IntPtr.Zero); } }
void Start() { m_TargetBuildingBehaviour = GetComponent <UserDefinedTargetBuildingBehaviour>(); if (m_TargetBuildingBehaviour) { m_TargetBuildingBehaviour.RegisterEventHandler(this); Debug.Log("Registering User Defined Target event handler."); } m_FrameQualityMeter = FindObjectOfType <FrameQualityMeter>(); m_TrackableSettings = FindObjectOfType <TrackableSettings>(); m_QualityDialog = FindObjectOfType <QualityDialog>(); if (m_QualityDialog) { m_QualityDialog.GetComponent <CanvasGroup>().alpha = 0; } textobj = GameObject.Find("wordobj"); musicobj = GameObject.Find("music"); status = GameObject.Find("status"); tempObj = GameObject.Find("TargetBuilderCanvas"); obj = tempObj.GetComponent <rectangle>(); // tm = textobj.GetComponent<TextMesh>(); //tm.text = "hello"; //textobj.SetActive(false); // print(textobj); // print(textobj.GetComponent<TextMesh>().text); }
private void RenderScene() // present (using IRenderOwner) { // owner.Lock(); try { var oldtargets = new Surface[1]; for (int nit = 0; nit < 1; nit++) { try { oldtargets[nit] = this.owner.device.GetRenderTarget(nit); } catch { } } this.owner.device.SetRenderTarget(0, this.rt); // clear the surface to transparent // this.owner.device.Clear(ClearFlags.Target, new global::SharpDX.Color(0, 0, 0, 255), 1.0f, 0); // this.owner.device.BeginScene(); // using (var dl = (this.owner as ).GetDrawLock()) // render using opengl { var state = this.owner.StartRender(null, rectangle.Zero); var r = new rectangle(0, 0, this.owner.renderframe.Width, this.owner.renderframe.Height); this.owner.renderer.render(this.owner.renderframe, this.frametime, r); this.owner.EndRender(state); } /* * // render the scene * if (SUCCEEDED(g_pd3dDevice->BeginScene())) * { * // setup the world, view, and projection matrices * SetupMatrices(); * * // render the vertex buffer contents * g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); * g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); * g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 1); * * // end the scene * g_pd3dDevice->EndScene(); * } * * // return the full size of the surface * pSize->cx = WIDTH; * pSize->cy = HEIGHT;*/ // this.dev.EndScene(); // this.owner.device.EndScene(); this.owner.device.SetRenderTarget(0, oldtargets[0]); oldtargets[0]?.Dispose(); } finally { // owner.Unlock(); } }
public static BaseShape createShape(string type) { BaseShape shape = null; switch (type) { case "三角形": shape = new triangle(); shape.type = type; break; case "圆形": shape = new circle(); shape.type = type; break; case "正方形": shape = new rectangle(); shape.type = type; break; case "矩形": shape = new square(); shape.type = type; break; } return(shape); }
object IRenderer.StartRender(IRenderFrame destination, rectangle r) { var oldframebuffer = (uint)GL.GetInteger(GetPName.FramebufferBinding); try { if (destination == null) { GL.Viewport(r.x, r.y, r.width, r.height);// new Rectangle(this.window.Location,this.window.ClientSize)); } else { var frame = (RenderFrame)destination; GL.BindFramebuffer(FramebufferTarget.Framebuffer, frame.framebuffer); GL.Viewport(0, 0, frame.Width, frame.Height);// new Rectangle(this.window.Location,this.window.ClientSize)); } } catch (Exception e) { // Log.LogException(e); } return(oldframebuffer);// destination; }
public void FirmarUserPDF_POLICY_SELLO_GENERICO_Button_Click(object sender, EventArgs e) { //Recuperamos la instancia del cliente ViafirmaClient clienteViafirma = ViafirmaClientFactory.GetInstance(); // Recuperamos el documento a firmar. //string path = Environment.CurrentDirectory; //FileStream fs = File.OpenRead(path + "\\resources\\exampleSign.pdf"); Assembly assembly = Assembly.GetExecutingAssembly(); Stream fs = assembly.GetManifestResourceStream(Global.DEMO_FILE_PDF_PATH); byte[] datos_a_firmar = new byte[fs.Length]; fs.Read(datos_a_firmar, 0, datos_a_firmar.Length); //Obtengo la imagen a estampar Stream stampImage = assembly.GetManifestResourceStream(Global.DEMO_STAMPER_PATH); byte[] image = new byte[stampImage.Length]; stampImage.Read(image, 0, image.Length); String imageB64 = System.Convert.ToBase64String(image); // Enviamos a firmar el documento //Creamos el objeto documento con los datos a firmar documento doc = new documento(); doc.nombre = "PDF_SELLOIMAGEN.pdf"; doc.datos = datos_a_firmar; doc.typeFormatSign = typeFormatSign.PAdES_BASIC; doc.tipo = typeFile.PDF; // En algunos casos, por ejemplo en el arranque de la aplicación puede ser interesante // Comprobar que efectivamente el servidor de firma está disponible System.Console.Write(clienteViafirma.ping("Prueba Conexión") + "\n"); //Creamos la politica de firma policy pol = PolicyUtil.newPolicy(typeFormatSign.PAdES_BASIC, typeSign.ATTACHED); PolicyUtil.AddParameter(pol, PolicyParams.DIGITAL_SIGN_PAGE, "1"); //creamos el rectangle rectangle r = PolicyUtil.newRectangle(140, 200, 100, 50); PolicyUtil.AddParameter(pol, PolicyParams.DIGITAL_SIGN_RECTANGLE, PolicyUtil.rectangleToJson(r)); // Registramos el documento que deseamos firmar. Obteniendo un identificador temporal. // Este identificador temporal no es necesario que sea almacenado ya que sólo tiene validez durante el proceso de firma. string idTemporalFirma = clienteViafirma.PrepareSignWithPolicy(pol, doc); System.Console.Write("idTemporalFirma: " + idTemporalFirma); //Logica del ejemplo para descagar el fichero con la extension correcta Session["extension"] = ".pdf"; // Iniciamos el proceso de firma redireccionando al usuario a Viafirma.. // Esto redireccionará al usuario a Viafirma para la firma del documento con el // identificador de firma indicado. clienteViafirma.Sign(idTemporalFirma); }
// Use this for initialization void Start() { barrier = new rectangle[rec_number]; barrier[0] = new rectangle(1, 3, -2, -1); barrier[1] = new rectangle(-6, -4, -1, 0); barrier[2] = new rectangle(-2, -0, 0, 1); draw_ball(); }
static void Main(string[] args) { square s1 = new square(5); rectangle r1 = new rectangle(5, 6); rectangle r2 = new rectangle(6, 6); circle c1 = new circle(5); ArrayList list = new ArrayList(); list.Add(r1); list.Add(s1); list.Add(c1); foreach (var x in list) { Console.Write("{0} ", x); } list.Sort(); Console.WriteLine("\nArray list after sorting"); foreach (var x in list) { Console.Write("{0} ", x); } List <geom_shape> list1 = new List <geom_shape>(); list1.Add(r1); list1.Add(s1); list1.Add(c1); Console.WriteLine("\nList before sorting"); foreach (var x in list1) { Console.Write("{0} ", x); } list1.Sort(); Console.WriteLine("\nList after sorting"); foreach (var x in list1) { Console.Write("{0} ", x); } Console.WriteLine(""); Matrix3dimensional <geom_shape> figure = new Matrix3dimensional <geom_shape>(4, 4, 4, null); figure[0, 0, 0] = r1; figure[1, 1, 1] = c1; figure[2, 2, 2] = s1; figure[1, 2, 3] = r2; Console.WriteLine(figure.ToString()); SimpleStack <geom_shape> Stack = new SimpleStack <geom_shape>(); Stack.Push(r1); Stack.Push(r2); Stack.Push(s1); Stack.Push(c1); while (Stack.Count > 0) { Console.WriteLine(Stack.Pop()); } Console.ReadKey(); }
public void Draw(SpriteBatch spriteBatch, Vector2 position) { Vector2 weaponOffset = new Vector2(-11, 5); Rectangle sourceRectangleAvatar; Rectangle destinationRectangleAvatar; Rectangle sourceRectangleWeapon; Rectangle destinationRectangleWeapon; //Rectangle sourceRectangleProjectile; //Rectangle destinationRectangleProjectile; if (currentframe == 0) { sourcerectangleavatar = new rectangle(432, 16, 16, 16); destinationrectangleavatar = new rectangle((int)location.x, (int)location.y, 16 * constant.displayscalex, 16 * constant.displayscaley); sourcerectangleweapon = new rectangle(432 + (int)weaponoffset.x, 16 + (int)weaponoffset.y, 11, 8); destinationrectangleweapon = new rectangle((int)location.x + (int)weaponoffset.x * constant.displayscalex, (int)location.y + (int)weaponoffset.y * constant.displayscaley, 11 * constant.displayscalex, 8 * constant.displayscaley); } if (currentFrame == 1) { sourceRectangleAvatar = new Rectangle(464, 16, 16, 16); destinationRectangleAvatar = new Rectangle((int)position.X, (int)position.Y, 16 * Constant.DisplayScaleX, 16 * Constant.DisplayScaleY); sourceRectangleWeapon = new Rectangle(464 + (int)weaponOffset.X, 16 + (int)weaponOffset.Y, 11, 8); destinationRectangleWeapon = new Rectangle((int)position.X + (int)weaponOffset.X * Constant.DisplayScaleX, (int)position.Y + (int)weaponOffset.Y * Constant.DisplayScaleY, 11 * Constant.DisplayScaleX, 8 * Constant.DisplayScaleY); } else if (currentFrame == 2) { sourceRectangleAvatar = new Rectangle(496, 16, 16, 16); destinationRectangleAvatar = new Rectangle((int)position.X, (int)position.Y, 16 * Constant.DisplayScaleX, 16 * Constant.DisplayScaleY); weaponOffset = new Vector2(-7, 5); sourceRectangleWeapon = new Rectangle(496 + (int)weaponOffset.X, 16 + (int)weaponOffset.Y, 7, 8); destinationRectangleWeapon = new Rectangle((int)position.X + (int)weaponOffset.X * Constant.DisplayScaleX, (int)position.Y + (int)weaponOffset.Y * Constant.DisplayScaleY, 7 * Constant.DisplayScaleX, 8 * Constant.DisplayScaleY); } else { sourceRectangleAvatar = new Rectangle(528, 16, 16, 16); destinationRectangleAvatar = new Rectangle((int)position.X, (int)position.Y, 16 * Constant.DisplayScaleX, 16 * Constant.DisplayScaleY); weaponOffset = new Vector2(-3, 5); sourceRectangleWeapon = new Rectangle(528 + (int)weaponOffset.X, 16 + (int)weaponOffset.Y, 3, 8); destinationRectangleWeapon = new Rectangle((int)position.X + (int)weaponOffset.X * Constant.DisplayScaleX, (int)position.Y + (int)weaponOffset.Y * Constant.DisplayScaleY, 3 * Constant.DisplayScaleX, 8 * Constant.DisplayScaleY); } spriteBatch.Begin(); spriteBatch.Draw(texture, destinationRectangleAvatar, sourceRectangleAvatar, Color.White); spriteBatch.Draw(texture, destinationRectangleWeapon, sourceRectangleWeapon, Color.White); spriteBatch.End(); }
static void Main(string[] args) { rectangle rect = new rectangle(10, 10); circle circ = new circle(20); square sqr = new square(15); ArrayList figures_array_list = new ArrayList(); figures_array_list.Add(rect); figures_array_list.Add(circ); figures_array_list.Add(sqr); Console.WriteLine("ArrayList:"); for (int i = 0; i < figures_array_list.Count; i++) { Console.WriteLine(figures_array_list[i].ToString()); } figures_array_list.Sort(); Console.WriteLine("Sorted:"); for (int i = 0; i < figures_array_list.Count; i++) { Console.WriteLine(figures_array_list[i].ToString()); } List <abstract_figure> figure_list_t = new List <abstract_figure> (); figure_list_t.Add(circ); figure_list_t.Add(rect); figure_list_t.Add(sqr); Console.WriteLine("List<T>"); foreach (var i in figure_list_t) { Console.WriteLine(i.ToString()); } figure_list_t.Sort(); Console.WriteLine("Sorted:"); foreach (var i in figure_list_t) { Console.WriteLine(i.ToString()); } Console.WriteLine("3d Sparse-matrix:"); Matrix <abstract_figure> figure_matrix = new Matrix <abstract_figure>(10, 10, 10, null); figure_matrix[1, 1, 1] = circ; figure_matrix[9, 0, 9] = sqr; figure_matrix[6, 9, 1] = rect; Console.Write(figure_matrix.ToString()); Console.WriteLine("Stack:"); SimpleStack <abstract_figure> figure_stack = new SimpleStack <abstract_figure>(); figure_stack.push(circ); figure_stack.push(rect); figure_stack.push(sqr); for (int i = 0; i < 3; i++) { Console.WriteLine(figure_stack.pop().ToString()); } Console.ReadKey(); }
static void Main() { rectangle rect = new rectangle(5, 4); square square = new square(5); circle circle = new circle(5); ArrayList l1 = new ArrayList(); l1.Add(circle); l1.Add(rect); l1.Add(square); Console.WriteLine("ArrayList:"); foreach (object i in l1) { Console.Write(i.ToString() + " "); } Console.Write("\nList:"); List <geometr_figur> l2 = new List <geometr_figur>(); l2.Add(circle); l2.Add(rect); l2.Add(square); Console.WriteLine("\nПеред сортировкой:"); foreach (object i in l2) { Console.Write(i.ToString() + " "); } l2.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (object i in l2) { Console.Write(i.ToString() + " "); } Console.WriteLine(""); Console.WriteLine("Стек"); SimpleStack <geometr_figur> stack = new SimpleStack <geometr_figur>(); stack.Push(rect); stack.Push(square); stack.Push(circle); while (stack.Count > 0) { geometr_figur f = stack.Pop(); Console.WriteLine(f); } Console.WriteLine("\nМатрица"); Matrix <geometr_figur> matrix = new Matrix <geometr_figur>(3, 3, 3, new FigureMatrixCheckEmpty()); matrix[0, 0, 0] = rect; matrix[1, 1, 1] = square; matrix[2, 2, 2] = circle; Console.WriteLine(matrix.ToString()); }
bool exam_rec(Vector3 par, rectangle rec) { if (exam_linex(par, rec.x1, rec.y1, rec.y2) && exam_linex(par, rec.x2, rec.y1, rec.y2) && exam_liney(par, rec.y1, rec.x1, rec.x2) && exam_liney(par, rec.y2, rec.x1, rec.x2)) { return(true); } else { return(false); } }
public static void Main(String [] args) { rectangle r = new rectangle(2, 3); //r.length=9; //r.breadth=10; Console.WriteLine("From Main: length {0}, breadth {1}", r.length, r.breadth); fun1(r); Console.WriteLine("From Main after fun1: length {0}, breadth {1}", r.length, r.breadth); fun2(ref r); Console.WriteLine("From Main after fun2: length {0}, breadth {1}", r.length, r.breadth); }
static void Main(string[] args) { Console.WriteLine("Width?&&&&"); double a = double.Parse(Console.ReadLine()); Console.WriteLine("Height?&&&&"); double b = double.Parse(Console.ReadLine()); rectangle s = new rectangle(a, b); Console.WriteLine(s); Console.ReadKey(); }
static void Main(string[] args) { rectangle rectangle = new rectangle(23.21, 23.23); rectangle.getArea(); circle circle = new circle(23.12); circle.getArea(); Console.WriteLine("area of rectangle is" + rectangle.getArea()); Console.WriteLine("area of circle is" + circle.getArea()); Console.ReadLine(); }
//------------------------------------------------- // render_triangle - render a triangle that // is used for up/down arrows and left/right // indicators //------------------------------------------------- static void render_triangle(bitmap_argb32 dest, bitmap_argb32 source, rectangle sbounds, object param) //void *param) { int halfwidth = dest.width() / 2; int height = dest.height(); int x, y; // start with all-transparent dest.fill(new rgb_t(0x00, 0x00, 0x00, 0x00)); // render from the tip to the bottom for (y = 0; y < height; y++) { int linewidth = (y * (halfwidth - 1) + (height / 2)) * 255 * 2 / height; //uint32_t *target = &dest.pix32(y, halfwidth); RawBuffer targetBuf; UInt32 targetOffset = dest.pix32(out targetBuf, y, halfwidth); // don't antialias if height < 12 if (dest.height() < 12) { int pixels = (linewidth + 254) / 255; if (pixels % 2 == 0) { pixels++; } linewidth = pixels * 255; } // loop while we still have data to generate for (x = 0; linewidth > 0; x++) { int dalpha; // first column we only consume one pixel if (x == 0) { dalpha = Math.Min(0xff, linewidth); targetBuf.set_uint32((int)targetOffset + x, new rgb_t((byte)dalpha, 0xff, 0xff, 0xff)); //target[x] = new rgb_t(dalpha, 0xff, 0xff, 0xff); } // remaining columns consume two pixels, one on each side else { dalpha = Math.Min(0x1fe, linewidth); targetBuf.set_uint32((int)targetOffset + x, new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff)); //target[x] = target[-x] = new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff); targetBuf.set_uint32((int)targetOffset + (-x), new rgb_t((byte)(dalpha / 2), 0xff, 0xff, 0xff)); } // account for the weight we consumed */ linewidth -= dalpha; } } }
static void Main(string[] args) { rectangle rec = new rectangle(5, 6); rec.Print(); square sq = new square(5); sq.Print(); circle cir = new circle(5); cir.Print(); Console.ReadKey(); }
public void ChangerectangleWidth_Input8_Returns8() { //Arrange int l = 7; int w = 5; int Width = 8; rectangle testrectangle = new rectangle(l, w); //Act--- double changedWidth = testrectangle.ChangerectangleWidth(8); //Assert Assert.AreEqual(changedWidth, Width); }
public void GetrectangleWidth_Input6_Returns6() { //Arrange int l = 4; int w = 6; rectangle testrectangle = new rectangle(l, w); //Act--- double width = testrectangle.GetrectangleWidth(); //Assert Assert.AreEqual(width, w); }
public void Getrectanglelength_Input11_Returns11() { //Arrange int l = 4; int w = 5; rectangle testrectangle = new rectangle(l, w); //Act--- double length = testrectangle.Getrectanglelength(); //Assert Assert.AreEqual(length, l); }
static void Main(string[] args) { Shapes[] s = new Shapes[2]; s[0] = new rectangle() { x = 10, y = 20 }; s[1] = new square() { x = 2 }; Console.WriteLine("Area of object={0}", Area(s)); }
public void Changerectanglelength_Input7_Returns7() { //Arrange int l = 7; int w = 5; int Length = 7; rectangle testrectangle = new rectangle(l, w); //Act--- double changedLength = testrectangle.ChangerectangleLength(7); //Assert Assert.AreEqual(changedLength, Length); }
public static void Main() { Delegates_demo3 obj = new Delegates_demo3(); rectangle del3 = null; del3 += new rectangle(obj.rectangle_area); del3 += new rectangle(obj.rectangle_perimeter); del3(4, 4); Console.WriteLine(); del3(5, 4); }
private void Form1_MouseDown(object sender, MouseEventArgs e) { circles c = new circles(e.X, e.Y); circle.Add(c); c.RanColors(); c.GetDirectionRnd(); rectangle r = new rectangle(e.X, e.Y); rectangles.Add(r); r.RanColors(); r.GetDirectionRnd(); }
public void GetrectanglePerimeter_Input4andinput5_Returns18() { //Arrange int l = 4; int w = 5; int perimeter = 18; rectangle testrectangle = new rectangle(l, w); //Act--- double outputperimeter = testrectangle.GetrectanglePerimeter(); //Assert Assert.AreEqual(outputperimeter, perimeter); }
static bool insiderectangle(rectangle a, int x, int y) { return x >= a.xa && x <= a.xb && y >= a.ya && y <= a.yb; }
public static void copybitmap(osd_bitmap dest, osd_bitmap src, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { FuncDict["copybitmap"] = "copybitmap"; rectangle myclip = new rectangle(); /* if necessary, remap the transparent color */ if (transparency == TRANSPARENCY_COLOR) transparent_color = Machine.pens[transparent_color]; if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { int temp = sx; sx = sy; sy = temp; bool tb = flipx; flipx = flipy; flipy = tb; if (clip != null) { /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = clip.min_y; myclip.min_y = temp; temp = clip.max_x; myclip.max_x = clip.max_y; myclip.max_y = temp; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X) != 0) { sx = dest.width - src.width - sx; if (clip != null) { /* clip and myclip might be the same, so we need a temporary storage */ int temp = clip.min_x; myclip.min_x = dest.width - 1 - clip.max_x; myclip.max_x = dest.width - 1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0) { sy = dest.height - src.height - sy; if (clip != null) { int temp; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_y; myclip.min_y = dest.height - 1 - clip.max_y; myclip.max_y = dest.height - 1 - temp; clip = myclip; } } if (dest.depth != 16) copybitmap_core8(dest, src, flipx, flipy, sx, sy, clip, transparency, transparent_color); else copybitmap_core16(dest, src, flipx, flipy, sx, sy, clip, transparency, transparent_color); }
static void drawgfx_core16(osd_bitmap dest, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { int ox; int oy; int ex; int ey; /* check bounds */ ox = sx; oy = sy; ex = sx + gfx.width - 1; if (sx < 0) sx = 0; if (clip != null && sx < clip.min_x) sx = clip.min_x; if (ex >= dest.width) ex = dest.width - 1; if (clip != null && ex > clip.max_x) ex = clip.max_x; if (sx > ex) return; ey = sy + gfx.height - 1; if (sy < 0) sy = 0; if (clip != null && sy < clip.min_y) sy = clip.min_y; if (ey >= dest.height) ey = dest.height - 1; if (clip != null && ey > clip.max_y) ey = clip.max_y; if (sy > ey) return; osd_mark_dirty(sx, sy, ex, ey, 0); /* ASG 971011 */ { _BytePtr sd = new _BytePtr(gfx.gfxdata, (int)(code * gfx.char_modulo)); /* source data */ int sw = ex - sx + 1; /* source width */ int sh = ey - sy + 1; /* source height */ int sm = gfx.line_modulo; /* source modulo */ _ShortPtr dd = new _ShortPtr(dest.line[sy], sx); /* dest data */ int dm = dest.line[1].offset - dest.line[0].offset; /* dest modulo */ UShortSubArray paldata = new UShortSubArray(gfx.colortable, (int)((gfx.color_granularity * color))); if (flipx) { sd.offset += gfx.width - 1 - (sx - ox); } else sd.offset += (sx - ox); if (flipy) { sd.offset += sm * (gfx.height - 1 - (sy - oy)); sm = -sm; } else sd.offset += sm * (sy - oy); switch (transparency) { case TRANSPARENCY_NONE: if (flipx) blockmove_opaque_flipx16(sd, sw, sh, sm, dd, dm, paldata); else blockmove_opaque16(sd, sw, sh, sm, dd, dm, paldata); break; case TRANSPARENCY_PEN: if (flipx) blockmove_transpen_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transpen16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_PENS: if (flipx) blockmove_transmask_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transmask16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_COLOR: if (flipx) blockmove_transcolor_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transcolor16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_THROUGH: if (flipx) blockmove_transthrough_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_transthrough16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; case TRANSPARENCY_PEN_TABLE: if (flipx) blockmove_pen_table_flipx16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); else blockmove_pen_table16(sd, sw, sh, sm, dd, dm, paldata, transparent_color); break; } } }
public static void drawgfx(osd_bitmap dest, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { rectangle myclip = new rectangle(); if (gfx == null) { usrintf_showmessage("drawgfx() gfx == 0"); return; } if (gfx.colortable == null) { usrintf_showmessage("drawgfx() gfx.colortable == 0"); return; } code %= gfx.total_elements; color %= (uint)gfx.total_colors; if (gfx.pen_usage != null && (transparency == TRANSPARENCY_PEN || transparency == TRANSPARENCY_PENS)) { int transmask = 0; if (transparency == TRANSPARENCY_PEN) { transmask = 1 << transparent_color; } else if (transparency == TRANSPARENCY_PENS) { transmask = transparent_color; } if ((gfx.pen_usage[(int)code] & ~transmask) == 0) /* character is totally transparent, no need to draw */ return; else if ((gfx.pen_usage[(int)code] & transmask) == 0 && transparency != TRANSPARENCY_THROUGH && transparency != TRANSPARENCY_PEN_TABLE) /* character is totally opaque, can disable transparency */ transparency = TRANSPARENCY_NONE; } if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { int temp; temp = sx; sx = sy; sy = temp; bool tempb = flipx; flipx = flipy; flipy = tempb; if (clip != null) { /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = clip.min_y; myclip.min_y = temp; temp = clip.max_x; myclip.max_x = clip.max_y; myclip.max_y = temp; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X) != 0) { sx = dest.width - gfx.width - sx; if (clip != null) { int temp; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = dest.width - 1 - clip.max_x; myclip.max_x = dest.width - 1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } #if !PREROTATE_GFX flipx = !flipx; #endif } if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0) { sy = dest.height - gfx.height - sy; if (clip != null) { int temp; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_y; myclip.min_y = dest.height - 1 - clip.max_y; myclip.max_y = dest.height - 1 - temp; clip = myclip; } #if !PREROTATE_GFX flipy = !flipy; #endif } if (dest.depth != 16) drawgfx_core8(dest, gfx, code, color, flipx, flipy, sx, sy, clip, transparency, transparent_color); else drawgfx_core16(dest, gfx, code, color, flipx, flipy, sx, sy, clip, transparency, transparent_color); }
public static void drawgfxzoom(osd_bitmap dest_bmp, GfxElement gfx, uint code, uint color, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color, int scalex, int scaley) { FuncDict["drawgfxzoom"] = "drawgfxzoom"; rectangle myclip = new rectangle(); /* only support TRANSPARENCY_PEN and TRANSPARENCY_COLOR */ if (transparency != TRANSPARENCY_PEN && transparency != TRANSPARENCY_COLOR) return; if (transparency == TRANSPARENCY_COLOR) transparent_color = Machine.pens[transparent_color]; /* scalex and scaley are 16.16 fixed point numbers 1<<15 : shrink to 50% 1<<16 : uniform scale 1<<17 : double to 200% */ if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { int temp; temp = sx; sx = sy; sy = temp; var tempb = flipx; flipx = flipy; flipy = tempb; temp = scalex; scalex = scaley; scaley = temp; if (clip != null) { /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = clip.min_y; myclip.min_y = temp; temp = clip.max_x; myclip.max_x = clip.max_y; myclip.max_y = temp; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X) != 0) { sx = dest_bmp.width - ((gfx.width * scalex + 0x7fff) >> 16) - sx; if (clip != null) { int temp; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_x; myclip.min_x = dest_bmp.width - 1 - clip.max_x; myclip.max_x = dest_bmp.width - 1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } #if !PREROTATE_GFX flipx = !flipx; #endif } if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0) { sy = dest_bmp.height - ((gfx.height * scaley + 0x7fff) >> 16) - sy; if (clip != null) { int temp; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; /* clip and myclip might be the same, so we need a temporary storage */ temp = clip.min_y; myclip.min_y = dest_bmp.height - 1 - clip.max_y; myclip.max_y = dest_bmp.height - 1 - temp; clip = myclip; } #if !PREROTATE_GFX flipy = !flipy; #endif } /* KW 991012 -- Added code to force clip to bitmap boundary */ if (clip != null) { myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; if (myclip.min_x < 0) myclip.min_x = 0; if (myclip.max_x >= dest_bmp.width) myclip.max_x = dest_bmp.width - 1; if (myclip.min_y < 0) myclip.min_y = 0; if (myclip.max_y >= dest_bmp.height) myclip.max_y = dest_bmp.height - 1; clip = myclip; } /* ASG 980209 -- added 16-bit version */ if (dest_bmp.depth != 16) { if (gfx != null && gfx.colortable != null) { UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */ int source_base = (int)((code % gfx.total_elements) * gfx.height); int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16; int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16; /* compute sprite increment per screen pixel */ int dx = (gfx.width << 16) / sprite_screen_width; int dy = (gfx.height << 16) / sprite_screen_height; int ex = sx + sprite_screen_width; int ey = sy + sprite_screen_height; int x_index_base; int y_index; if (flipx) { x_index_base = (sprite_screen_width - 1) * dx; dx = -dx; } else { x_index_base = 0; } if (flipy) { y_index = (sprite_screen_height - 1) * dy; dy = -dy; } else { y_index = 0; } if (clip != null) { if (sx < clip.min_x) { /* clip left */ int pixels = clip.min_x - sx; sx += pixels; x_index_base += pixels * dx; } if (sy < clip.min_y) { /* clip top */ int pixels = clip.min_y - sy; sy += pixels; y_index += pixels * dy; } /* NS 980211 - fixed incorrect clipping */ if (ex > clip.max_x + 1) { /* clip right */ int pixels = ex - clip.max_x - 1; ex -= pixels; } if (ey > clip.max_y + 1) { /* clip bottom */ int pixels = ey - clip.max_y - 1; ey -= pixels; } } if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; /* case 1: TRANSPARENCY_PEN */ if (transparency == TRANSPARENCY_PEN) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _BytePtr dest = dest_bmp.line[y]; int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index >> 16]; if (c != transparent_color) dest[x] = (byte)pal[c]; x_index += dx; } y_index += dy; } } /* case 2: TRANSPARENCY_COLOR */ else if (transparency == TRANSPARENCY_COLOR) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _BytePtr dest = dest_bmp.line[y]; int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = pal[source[x_index >> 16]]; if (c != transparent_color) dest[x] = (byte)c; x_index += dx; } y_index += dy; } } } } } /* ASG 980209 -- new 16-bit part */ else { if (gfx != null && gfx.colortable != null) { UShortSubArray pal = new UShortSubArray(gfx.colortable, (int)(gfx.color_granularity * (color % gfx.total_colors))); /* ASG 980209 */ int source_base = (int)((code % gfx.total_elements) * gfx.height); int sprite_screen_height = (scaley * gfx.height + 0x8000) >> 16; int sprite_screen_width = (scalex * gfx.width + 0x8000) >> 16; /* compute sprite increment per screen pixel */ int dx = (gfx.width << 16) / sprite_screen_width; int dy = (gfx.height << 16) / sprite_screen_height; int ex = sx + sprite_screen_width; int ey = sy + sprite_screen_height; int x_index_base; int y_index; if (flipx) { x_index_base = (sprite_screen_width - 1) * dx; dx = -dx; } else { x_index_base = 0; } if (flipy) { y_index = (sprite_screen_height - 1) * dy; dy = -dy; } else { y_index = 0; } if (clip != null) { if (sx < clip.min_x) { /* clip left */ int pixels = clip.min_x - sx; sx += pixels; x_index_base += pixels * dx; } if (sy < clip.min_y) { /* clip top */ int pixels = clip.min_y - sy; sy += pixels; y_index += pixels * dy; } /* NS 980211 - fixed incorrect clipping */ if (ex > clip.max_x + 1) { /* clip right */ int pixels = ex - clip.max_x - 1; ex -= pixels; } if (ey > clip.max_y + 1) { /* clip bottom */ int pixels = ey - clip.max_y - 1; ey -= pixels; } } if (ex > sx) { /* skip if inner loop doesn't draw anything */ int y; /* case 1: TRANSPARENCY_PEN */ if (transparency == TRANSPARENCY_PEN) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]); int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = source[x_index >> 16]; if (c != transparent_color) dest[x] = (byte)pal[c]; x_index += dx; } y_index += dy; } } /* case 2: TRANSPARENCY_COLOR */ else if (transparency == TRANSPARENCY_COLOR) { for (y = sy; y < ey; y++) { _BytePtr source = new _BytePtr(gfx.gfxdata, (source_base + (y_index >> 16)) * gfx.line_modulo); _ShortPtr dest = new _ShortPtr(dest_bmp.line[y]); int x, x_index = x_index_base; for (x = sx; x < ex; x++) { int c = pal[source[x_index >> 16]]; if (c != transparent_color) dest.write16(x, (ushort)c); x_index += dx; } y_index += dy; } } } } } }
static void copybitmapzoom(osd_bitmap dest_bmp, osd_bitmap source_bmp, bool flipx, bool flipy, int sz, int sy, rectangle clip, int transparency, int transparent_color, int scalex, int scaley) { throw new Exception(); }
public static void fillbitmap(osd_bitmap dest, int pen, rectangle clip) { FuncDict["fillbitmap"] = "fillbitmap"; rectangle myclip = new rectangle(); if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { if (clip != null) { myclip.min_x = clip.min_y; myclip.max_x = clip.max_y; myclip.min_y = clip.min_x; myclip.max_y = clip.max_x; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_X) != 0) { if (clip != null) { int temp = clip.min_x; myclip.min_x = dest.width - 1 - clip.max_x; myclip.max_x = dest.width - 1 - temp; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; clip = myclip; } } if ((Machine.orientation & ORIENTATION_FLIP_Y) != 0) { if (clip != null) { myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; int temp = clip.min_y; myclip.min_y = dest.height - 1 - clip.max_y; myclip.max_y = dest.height - 1 - temp; clip = myclip; } } int sx = 0; int ex = dest.width - 1; int sy = 0; int ey = dest.height - 1; if (clip != null && sx < clip.min_x) sx = clip.min_x; if (clip != null && ex > clip.max_x) ex = clip.max_x; if (sx > ex) return; if (clip != null && sy < clip.min_y) sy = clip.min_y; if (clip != null && ey > clip.max_y) ey = clip.max_y; if (sy > ey) return; osd_mark_dirty(sx, sy, ex, ey, 0); /* ASG 971011 */ /* ASG 980211 */ if (dest.depth == 16) { if ((pen >> 8) == (pen & 0xff)) { for (int y = sy; y <= ey; y++) { for (int k = 0; k < (ex - sx + 1) * 2; k++) dest.line[y][sx * 2 + k] = (byte)(pen & 0xff); } //memset(&dest.line[y][sx*2],pen&0xff,(ex-sx+1)*2); } else { _ShortPtr sp = new _ShortPtr(dest.line[sy]); int x; for (x = sx; x <= ex; x++) sp.write16(x, (ushort)pen); sp.offset += sx * 2; for (int y = sy + 1; y <= ey; y++) { Buffer.BlockCopy(sp.buffer, sp.offset, dest.line[y].buffer, sx * 2, (ex - sx + 1) * 2); } //memcpy(&dest.line[y][sx*2],sp,(ex-sx+1)*2); } } else { for (int y = sy; y <= ey; y++) { for (int k = 0; k < ex - sx + 1; k++) dest.line[y][sx + k] = (byte)pen; } } }
public static void copyscrollbitmap(osd_bitmap dest, osd_bitmap src, int rows, int[] rowscroll, int cols, int[] colscroll, rectangle clip, int transparency, int transparent_color) { FuncDict["copyscrollbitmap"] = "copyscrollbitmap"; int srcwidth, srcheight, destwidth, destheight; if (rows == 0 && cols == 0) { copybitmap(dest, src, false, false, 0, 0, clip, transparency, transparent_color); return; } if ((Machine.orientation & ORIENTATION_SWAP_XY) != 0) { srcwidth = src.height; srcheight = src.width; destwidth = dest.height; destheight = dest.width; } else { srcwidth = src.width; srcheight = src.height; destwidth = dest.width; destheight = dest.height; } if (rows == 0) { /* scrolling columns */ int col, colwidth; rectangle myclip = new rectangle(); colwidth = srcwidth / cols; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; col = 0; while (col < cols) { int cons, scroll; /* count consecutive columns scrolled by the same amount */ scroll = colscroll[col]; cons = 1; while (col + cons < cols && colscroll[col + cons] == scroll) cons++; if (scroll < 0) scroll = srcheight - (-scroll) % srcheight; else scroll %= srcheight; myclip.min_x = col * colwidth; if (myclip.min_x < clip.min_x) myclip.min_x = clip.min_x; myclip.max_x = (col + cons) * colwidth - 1; if (myclip.max_x > clip.max_x) myclip.max_x = clip.max_x; copybitmap(dest, src, false, false, 0, scroll, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, 0, scroll - srcheight, myclip, transparency, transparent_color); col += cons; } } else if (cols == 0) { /* scrolling rows */ int row, rowheight; rectangle myclip = new rectangle(); rowheight = srcheight / rows; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; row = 0; while (row < rows) { int cons, scroll; /* count consecutive rows scrolled by the same amount */ scroll = rowscroll[row]; cons = 1; while (row + cons < rows && rowscroll[row + cons] == scroll) cons++; if (scroll < 0) scroll = srcwidth - (-scroll) % srcwidth; else scroll %= srcwidth; myclip.min_y = row * rowheight; if (myclip.min_y < clip.min_y) myclip.min_y = clip.min_y; myclip.max_y = (row + cons) * rowheight - 1; if (myclip.max_y > clip.max_y) myclip.max_y = clip.max_y; copybitmap(dest, src, false, false, scroll, 0, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, scroll - srcwidth, 0, myclip, transparency, transparent_color); row += cons; } } else if (rows == 1 && cols == 1) { /* XY scrolling playfield */ int scrollx, scrolly, sx, sy; if (rowscroll[0] < 0) scrollx = srcwidth - (-rowscroll[0]) % srcwidth; else scrollx = rowscroll[0] % srcwidth; if (colscroll[0] < 0) scrolly = srcheight - (-colscroll[0]) % srcheight; else scrolly = colscroll[0] % srcheight; for (sx = scrollx - srcwidth; sx < destwidth; sx += srcwidth) for (sy = scrolly - srcheight; sy < destheight; sy += srcheight) copybitmap(dest, src, false, false, sx, sy, clip, transparency, transparent_color); } else if (rows == 1) { /* scrolling columns + horizontal scroll */ int col, colwidth; int scrollx; rectangle myclip = new rectangle(); if (rowscroll[0] < 0) scrollx = srcwidth - (-rowscroll[0]) % srcwidth; else scrollx = rowscroll[0] % srcwidth; colwidth = srcwidth / cols; myclip.min_y = clip.min_y; myclip.max_y = clip.max_y; col = 0; while (col < cols) { int cons, scroll; /* count consecutive columns scrolled by the same amount */ scroll = colscroll[col]; cons = 1; while (col + cons < cols && colscroll[col + cons] == scroll) cons++; if (scroll < 0) scroll = srcheight - (-scroll) % srcheight; else scroll %= srcheight; myclip.min_x = col * colwidth + scrollx; if (myclip.min_x < clip.min_x) myclip.min_x = clip.min_x; myclip.max_x = (col + cons) * colwidth - 1 + scrollx; if (myclip.max_x > clip.max_x) myclip.max_x = clip.max_x; copybitmap(dest, src, false, false, scrollx, scroll, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, scrollx, scroll - srcheight, myclip, transparency, transparent_color); myclip.min_x = col * colwidth + scrollx - srcwidth; if (myclip.min_x < clip.min_x) myclip.min_x = clip.min_x; myclip.max_x = (col + cons) * colwidth - 1 + scrollx - srcwidth; if (myclip.max_x > clip.max_x) myclip.max_x = clip.max_x; copybitmap(dest, src, false, false, scrollx - srcwidth, scroll, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, scrollx - srcwidth, scroll - srcheight, myclip, transparency, transparent_color); col += cons; } } else if (cols == 1) { /* scrolling rows + vertical scroll */ int row, rowheight; int scrolly; rectangle myclip = new rectangle(); if (colscroll[0] < 0) scrolly = srcheight - (-colscroll[0]) % srcheight; else scrolly = colscroll[0] % srcheight; rowheight = srcheight / rows; myclip.min_x = clip.min_x; myclip.max_x = clip.max_x; row = 0; while (row < rows) { int cons, scroll; /* count consecutive rows scrolled by the same amount */ scroll = rowscroll[row]; cons = 1; while (row + cons < rows && rowscroll[row + cons] == scroll) cons++; if (scroll < 0) scroll = srcwidth - (-scroll) % srcwidth; else scroll %= srcwidth; myclip.min_y = row * rowheight + scrolly; if (myclip.min_y < clip.min_y) myclip.min_y = clip.min_y; myclip.max_y = (row + cons) * rowheight - 1 + scrolly; if (myclip.max_y > clip.max_y) myclip.max_y = clip.max_y; copybitmap(dest, src, false, false, scroll, scrolly, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, scroll - srcwidth, scrolly, myclip, transparency, transparent_color); myclip.min_y = row * rowheight + scrolly - srcheight; if (myclip.min_y < clip.min_y) myclip.min_y = clip.min_y; myclip.max_y = (row + cons) * rowheight - 1 + scrolly - srcheight; if (myclip.max_y > clip.max_y) myclip.max_y = clip.max_y; copybitmap(dest, src, false, false, scroll, scrolly - srcheight, myclip, transparency, transparent_color); copybitmap(dest, src, false, false, scroll - srcwidth, scrolly - srcheight, myclip, transparency, transparent_color); row += cons; } } }
static void copybitmap_core16(osd_bitmap dest, osd_bitmap src, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { throw new Exception(); }
static void copybitmap_core8(osd_bitmap dest, osd_bitmap src, bool flipx, bool flipy, int sx, int sy, rectangle clip, int transparency, int transparent_color) { FuncDict["copybitmap_core8"] = "copybitmap_core8"; int ox; int oy; int ex; int ey; /* check bounds */ ox = sx; oy = sy; ex = sx + src.width - 1; if (sx < 0) sx = 0; if (clip != null && sx < clip.min_x) sx = clip.min_x; if (ex >= dest.width) ex = dest.width - 1; if (clip != null && ex > clip.max_x) ex = clip.max_x; if (sx > ex) return; ey = sy + src.height - 1; if (sy < 0) sy = 0; if (clip != null && sy < clip.min_y) sy = clip.min_y; if (ey >= dest.height) ey = dest.height - 1; if (clip != null && ey > clip.max_y) ey = clip.max_y; if (sy > ey) return; _BytePtr sd = new _BytePtr(src.line[0]); /* source data */ int sw = ex - sx + 1; /* source width */ int sh = ey - sy + 1; /* source height */ int sm = (int)(src.line[1].offset - src.line[0].offset); /* source modulo */ _BytePtr dd = new _BytePtr(dest.line[sy], sx); /* dest data */ int dm = (int)(dest.line[1].offset - dest.line[0].offset); /* dest modulo */ if (flipx) { sd.offset += src.width - 1 - (sx - ox); } else sd.offset += (sx - ox); if (flipy) { sd.offset += sm * (src.height - 1 - (sy - oy)); sm = -sm; } else sd.offset += (sm * (sy - oy)); switch (transparency) { case TRANSPARENCY_NONE: if (flipx) blockmove_opaque_noremap_flipx8(sd, sw, sh, sm, dd, dm); else blockmove_opaque_noremap8(sd, sw, sh, sm, dd, dm); break; case TRANSPARENCY_PEN: case TRANSPARENCY_COLOR: if (flipx) blockmove_transpen_noremap_flipx8(sd, sw, sh, sm, dd, dm, transparent_color); else blockmove_transpen_noremap8(sd, sw, sh, sm, dd, dm, transparent_color); break; case TRANSPARENCY_THROUGH: if (flipx) blockmove_transthrough_noremap_flipx8(sd, sw, sh, sm, dd, dm, transparent_color); else blockmove_transthrough_noremap8(sd, sw, sh, sm, dd, dm, transparent_color); break; } }
public static void tilemap_set_clip(tilemap _tilemap, rectangle clip) { int left, top, right, bottom; if (clip != null) { left = clip.min_x; top = clip.min_y; right = clip.max_x + 1; bottom = clip.max_y + 1; if ((_tilemap.orientation & ORIENTATION_SWAP_XY) != 0) { var temp = left; left = top; top = temp;//SWAP(left,top) temp = right; right = bottom; bottom = temp;//SWAP(right,bottom) } if ((_tilemap.orientation & ORIENTATION_FLIP_X) != 0) { //SWAP(left,right) var temp = left; left = right; right = temp; left = screen_width - left; right = screen_width - right; } if ((_tilemap.orientation & ORIENTATION_FLIP_Y) != 0) { //SWAP(top,bottom) var temp = top; top = bottom; bottom = temp; top = screen_height - top; bottom = screen_height - bottom; } } else { left = 0; top = 0; right = _tilemap.width; bottom = _tilemap.height; } _tilemap.clip_left = left; _tilemap.clip_right = right; _tilemap.clip_top = top; _tilemap.clip_bottom = bottom; //if( errorlog ) fprintf( errorlog, "clip: %d,%d,%d,%d\n", left,top,right,bottom ); }
public artwork_element(rectangle box, byte[] colors, byte alpha) { this.box = box; this.red = colors[0]; this.green = colors[1]; this.blue = colors[2]; this.alpha = alpha; }