You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


TRIANGLE COLORS
08-16-2014, 02:43 AM
Post: #1
 (Print Post)
TRIANGLE COLORS
While chatting with a few QB64 programmers on the QB64 chat room, someone had asked if anyone could draw a tri-colored triangle in QB64. They shared a link to a picture of such triangle. I told them that it would be easy to do so, so I sat out to create a demo for it.

Several people suggested that the easiest and most efficient way to do so is with OPEN-GL (or Direct X), which is true since it would hardware accelerated and drawn by the hardware. But, I took the question as if they wanted to know if someone could do it as a software rendering.

Below are some screenshots of the attached demo.

   
       

Please note, this demo demonstrates how to draw a colored triangle and is not optimized in any way. The triangle drawing parts are not in FUNCTIONs or SUBs.



Thanks,
Walter Whitman
The Joyful Programmer


Attached File(s)
.bas  Triangle Colors.bas (Size: 11.04 KB / Downloads: 110)

Please help support The Joyful Programmer and The QB64 Edition by visiting our online store provided by Amazon.com. We hand-picked books related to computer programming from Amazon.com and added them to our store. When you make a purchase from our store, we do receive a small commission from the sale. Visit our store at: http://www.thejoyfulprogrammer.com/qb64/...azon-store
Find all posts by this user
Like Post
08-16-2014, 04:08 AM
Post: #2
 (Print Post)
RE: TRIANGLE COLORS
Attached is an updated version of the colored triangle demo. It draws randomly colored triangles at random locations on the screen. The triangle drawing has been placed in a SUB so it could be used in other projects.

The demo is not optimized, so the triangle drawing is slow.

Here is a screenshot:

   


Attached File(s)
.bas  Triangle Colors Ver 2.bas (Size: 8.33 KB / Downloads: 92)

Please help support The Joyful Programmer and The QB64 Edition by visiting our online store provided by Amazon.com. We hand-picked books related to computer programming from Amazon.com and added them to our store. When you make a purchase from our store, we do receive a small commission from the sale. Visit our store at: http://www.thejoyfulprogrammer.com/qb64/...azon-store
Find all posts by this user
Like Post
08-16-2014, 04:57 AM
Post: #3
 (Print Post)
RE: TRIANGLE COLORS
Quote:
While chatting with a few QB64 programmers on the QB64 chat room, someone had asked if anyone could draw a tri-colored triangle in QB64. They shared a link to a picture of such triangle. I told them that it would be easy to do so, so I sat out to create a demo for it.

Several people suggested that the easiest and most efficient way to do so is with OPEN-GL (or Direct X), which is true since it would hardware accelerated and drawn by the hardware. But, I took the question as if they wanted to know if someone could do it as a software rendering.

Below are some screenshots of the attached demo.




Please note, this demo demonstrates how to draw a colored triangle and is not optimized in any way. The triangle drawing parts are not in FUNCTIONs or SUBs.



Thanks,
Walter Whitman
The Joyful Programmer

How about a 3D Triangle ? Walter Wink


Anthony.
Find all posts by this user
Like Post
08-16-2014, 05:06 AM
Post: #4
 (Print Post)
RE: TRIANGLE COLORS
Anthony,

This demo only demonstrates software rendering of the colored triangles, not hardware rending like you would make with _MAPTRIANGLE, OPEN-GL, or DirectX.

This demo is only to demonstrate the math behind the rendering.

I guess I will need to post some actual hardware rendered 3D triangles I guess.



Walter Whitman
The Joyful Programmer

Please help support The Joyful Programmer and The QB64 Edition by visiting our online store provided by Amazon.com. We hand-picked books related to computer programming from Amazon.com and added them to our store. When you make a purchase from our store, we do receive a small commission from the sale. Visit our store at: http://www.thejoyfulprogrammer.com/qb64/...azon-store
Find all posts by this user
Like Post
08-16-2014, 06:24 AM
Post: #5
 (Print Post)
RE: TRIANGLE COLORS
Sounds Great Walter...

I imagine 3D Triangles are Quite hard to Produce ? Squares, Oblongs, Circles, I can kind of understand!

And I would also imagine a 3D Pentagon would be a Nightmare! no wonder Devil Worshippers use it! Smile

As for a Dodecahedron...I don't even go there! Big Grin


Anthony.
Find all posts by this user
Like Post
08-19-2014, 10:57 AM
Post: #6
 (Print Post)
RE: TRIANGLE COLORS
Anthony,

The triangle was a fairly simple shape to do without a ton of extra stuff. The other shapes would have to be treated like polygons, and the edges scan-converted to get the parts to draw. Though it isn't difficult, it is a little more involved than the triangle.

I plan on creating a polygon demo sometime, but I have been working on one of my games lately, "Medieval Yahtzee".


Thanks,
Walter Whitman
The Joyful Programmer

Please help support The Joyful Programmer and The QB64 Edition by visiting our online store provided by Amazon.com. We hand-picked books related to computer programming from Amazon.com and added them to our store. When you make a purchase from our store, we do receive a small commission from the sale. Visit our store at: http://www.thejoyfulprogrammer.com/qb64/...azon-store
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Martin Fractals version four
QB64 Member Project - OpenGL Triangles
QB64 Member Project - 9 Board
QB64 Member Project - Rotating Background
QB64 Member Project - Bowditch curve
QB64 Member Project - Algeria Weather
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Dreamy Clock
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Color Triangles
QB64 Member Project - Touche
QB64 Member Project - Othello
QB64 Member Project - Quarto
QB64 Member Project - Qubic
QB64 Member Project - Exit
QB64 Member Project - Splatter
QB64 Member Project - Isolation
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Amazon
QB64 Member Project - Score 4
QB64 Member Project - Connect Four
QB64 Member Project - Point Blank
QB64 Member Project - Full Color LED Sign
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - ARB Checkers
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Swirl
QB64 Member Project - Overboard
QB64 Member Project - Foursight
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Spiro Roses
QB64 Member Project - Input
QB64 Member Project - Pivet version one
QB64 Member Project - Sabotage
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Inside Moves
QB64 Member Project - Basic Dithering
QB64 Member Project - Dakapo
QB64 Member Project - Color Rotating Text
QB64 Member Project - Line Thickness
QB64 Member Project - Rubix's Magic
QB64 Member Project - Pivot version two
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Blokus
QB64 Member Project - Kings Court
QB64 Member Project - Domain