jueves, 28 de diciembre de 2023

Graficar Hexagono con Python y Kivy

Tener instalado la libreria kivy, desde la linea de comandos o CMD digitar 
pip install kivy 
manual de instalacion de librerias en python aqui.

from kivy.app import App

from kivy.uix.widget import Widget

from kivy.graphics import Color, Ellipse, Rectangle, Line

class MyPaintWidget(Widget):

    a=[[1,1]]

    def on_touch_down(self, touch):

        with self.canvas:

            self.a.append([touch.x,touch.y])

            print(self.a)

            L = len(self.a)

            x1 = self.a[L-1][0]

            y1 = self.a[L-1][1]

            x2 = self.a[L-2][0]

            y2 = self.a[L-2][1]

            Color(0.5, 0.5, 1)

            d = 50

            if (L>2) :

            Line(points=(x1,y1,x2,y2), width=10)

            Ellipse(pos=(touch.x+12,touch.y+13),size=(20,20))

class MyPaintApp(App):

    def build(self):

        return MyPaintWidget()

if __name__ == '__main__':

    MyPaintApp().run()

download aqui
minuvasoft10@gmail.com --- Programador de Proyectos Software


martes, 19 de diciembre de 2023

Imprimir Directamente sin Cuadro de Dialogo con Java Netbeans

package paketa2;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import static java.awt.print.Printable.NO_SUCH_PAGE;
import static java.awt.print.Printable.PAGE_EXISTS;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class frmPri2 extends javax.swing.JFrame implements Printable {
    public frmPri2() {
        initComponents();
    }
    private void btnPrintActionPerformed(java.awt.event.ActionEvent evt) {                                         
        
        PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(this);
        try {
                job.print();
        } catch (PrinterException e) {
                e.printStackTrace();
        }
    }                                        
    public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
        if (page > 0) {
             return NO_SUCH_PAGE;
        }

        Graphics2D g2d = (Graphics2D) g;
      Image img1;
        ImageIcon icon = new ImageIcon("barcode2.gif");
        img1 = icon.getImage();
        g.drawString("minuvaHard10 corp.", 100, 100);
        g.drawString("Simulacion de Ticket", 100, 130);
        g.drawImage(img1, 200, 150,null);

        return PAGE_EXISTS;
    }

    public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new frmPri2().setVisible(true);
            }
        });
    }
}
download aqui
minuvasoft10@gmail.com Programador de Proyectos Software.



sábado, 2 de diciembre de 2023

Mover Imagen a posicion de Mouse con Python y Kivy

Tener instalado la libreria kivy, copiar la imagen a la carpeta del programa.

from kivy.app import App

from kivy.uix.widget import Widget

from kivy.graphics import Color, Ellipse, Rectangle, Line

from kivy.core.image import Image

class MyPaintWidget(Widget):

    a=[[1,1]]

    def on_touch_down(self, touch):

        with self.canvas:

            self.a.append([touch.x,touch.y])

            Color(0, 0.5, 0)

            Rectangle(pos=(0,0), size=self.size)

            Rectangle(source="nave.png", pos=(touch.x, touch.y), size=(100,100))

class MyPaintApp(App):

    def build(self):

        return MyPaintWidget()

if __name__ == '__main__':

    MyPaintApp().run()

 e-mail: minuvasoft10@gmail.com Programador de Proyectos Software.





Hallar las raizes de Cualquier Ecuacion con Excel 365

  Se establece un intervalo de x de -20 a 20 para hallar los f(x) que cambian de signo, X aumenta en 1.   Se halla el cambio de signo de f(x...