Skip to content

Instantly share code, notes, and snippets.

View kevinmungai's full-sized avatar

Kevin Mungai kevinmungai

View GitHub Profile
@kevinmungai
kevinmungai / checkers.cpp
Last active October 10, 2017 09:11
Checker Board Pattern using C++
/*
The Code Below is used to develop a Checker Board Pattern.
1. Start with Identifying the First Square
2. Put in the coordinates for the First Square
3. Create a for-loop to to create squares at the same time
4. Introduce a variable to help keep track of the color. Using an IF Statement.
5. Introduce an outer for-loop to cater for the y - axis.
*/
@kevinmungai
kevinmungai / CurveOpenGL.cpp
Last active October 31, 2017 09:26
Creating a Curve in OpenGL using the equation y = x ^ 2
/*
* Drawing the curve y = x ^ 2 in OpenGL
* x ranges from (-10) to 10
* It's made to fit the entire Viewport
*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h
#include <GL/gl.h>
/* Initialize OpenGL Graphics */
@kevinmungai
kevinmungai / labTask.cpp
Created November 2, 2017 09:20
f (x) = e ^ -x cos (2 . pi . x)
// lab assignment
// f (x) = e ^ -x cos (2 pi x)
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h
#include <GL/gl.h>
#include <cmath>
#include <math.h>
/* Initialize OpenGL Graphics */
GLdouble special (GLdouble x);
// lab assignment
// Triangles Pattern
// Also included is Varying Sizes.
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h
#include <GL/gl.h>
/* Initialize OpenGL Graphics */
void initGL();
@kevinmungai
kevinmungai / translationAssignment.cpp
Created November 14, 2017 08:26
Shows how to perform translation
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.hvoid
initGL() {
glMatrixMode(GL_MODELVIEW); //Set Matrices to MODELVIEW to support transformations
glLoadIdentity();
gluOrtho2D(0.0, 640.0, 0.0, 480.0);
glViewport(0,0,640,480);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
@kevinmungai
kevinmungai / transformationAssignment.cpp
Last active November 14, 2017 08:50
performing translation with OpenGL
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h/* Initialize OpenGL Graphics */
void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
glViewport(0,0,1000,1000);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black and opaque
}
@kevinmungai
kevinmungai / checkersTranslated.cpp
Last active November 16, 2017 08:38
translation leading to checkers pattern
/** GL02Primitive.cpp: Vertex, Primitive and Color* Draw Simple 2D colored Shapes: quad, triangle and polygon.*/
#include <windows.h> // for MS Windows
#include <GL/glut.h> // GLUT, include glu.h and gl.h/* Initialize OpenGL Graphics */
void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 1000.0, 0.0, 1000.0);
glViewport(0,0,1000,1000);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black and opaque
@kevinmungai
kevinmungai / animationOpenGL.cpp
Created November 21, 2017 09:51
Animation in OpenGL
// We will be doing animation in OpenGL
// key concepts are:
// 1. the idle function - idle() will post a replaint and this will lead to activation of the display() function
// 2. Also we will be doing double buffering like this: glutInitDisplayMode(GLUT_DOUBLE);
// In addition we will be introducing other functions such as glPushMatrix, glPopMatrix and glSwapBuffers
#include <windows.h>
#include <GL/glut.h>
#include <GL/gl.h>
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package areacalculator;
import javax.swing.*;
/**
*
@kevinmungai
kevinmungai / Curry.md
Created December 19, 2017 14:01
Understanding of how the curry function works in Haskell

Curry in Haskell

So today I am going to go through the function curry in Haskell. I am finding a hard time trying to understand it and this is my way of trying to understanding it.

First the type signature

This is what I get when I type in :t curry

curry :: ((a, b) -> c) -> a -> b -> c