View Single Post
Old 07-14-2014, 06:17 AM
Rodrigo Mota Rodrigo Mota is offline
Join Date: Apr 2005
Location: Portugal
Posts: 53

Think I found a solution, I'm posting it as it might help someone with a similar problem.
Going to start playing with the parameters of the function now

Imports System
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        e.Graphics.DrawImage(drawValve(), 50, 100)
    End Sub

    Function drawValve() As Bitmap
        'VÁLVULA 40 X 40
        Dim t1 As New Point(0, 10)
        Dim t2 As New Point(0, 30)
        Dim t3 As New Point(20, 20)
        Dim t4 As New Point(40, 10)
        Dim t5 As New Point(40, 30)
        Dim t6 As New Point(20, 10)
        Dim r2 As Rectangle = New Rectangle(10, 0, 20, 20)

        Dim aIni As Single = 0
        Dim aAmp As Single = -180
        Dim l As Pen = New Pen(Brushes.Black, 2)

        Dim vT1 As Point() = {t1, t2, t3}
        Dim vT2 As Point() = {t3, t4, t5}

        Dim vP As Bitmap = New Bitmap(40, 40)
        Dim vPeq As Graphics = Me.CreateGraphics
        vPeq = Graphics.FromImage(vP)

        With vPeq
            .FillPolygon(Brushes.Yellow, vT1)
            .DrawPolygon(l, vT1)
            .FillPolygon(Brushes.Yellow, vT2)
            .DrawPolygon(l, vT2)
            .FillPie(Brushes.Yellow, r2, aIni, aAmp)
            .DrawPie(l, r2, aIni, aAmp)
            .DrawLine(l, t3, t6)
        End With
        Return vP
    End Function
Reply With Quote