added huey module, still a copy of skembo
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
BIN := $(shell basename $$(pwd))
 | 
			
		||||
PLUGINS := rects skembo
 | 
			
		||||
PLUGINS := rects skembo huey
 | 
			
		||||
 | 
			
		||||
MAKE += --no-print-directory
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										59
									
								
								huey/Huey.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								huey/Huey.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
//
 | 
			
		||||
// Huey.cpp
 | 
			
		||||
// screensaver
 | 
			
		||||
//
 | 
			
		||||
// Created by Bob Polis at 2020-10-26
 | 
			
		||||
// Copyright (c) 2020 SwiftCoder. All rights reserved.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "Huey.hpp"
 | 
			
		||||
#include <libscscreensaver.hpp>
 | 
			
		||||
 | 
			
		||||
class Huey : public ScreensaverPlugin {
 | 
			
		||||
    public:
 | 
			
		||||
        Huey() = default;
 | 
			
		||||
        ~Huey() = default;
 | 
			
		||||
 | 
			
		||||
        void setup(cairo_t* context, const cairo_rectangle_t& rect) override;
 | 
			
		||||
        void draw_frame() override;
 | 
			
		||||
        int fps() const override;
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        double _hue {0};
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ScreensaverPlugin* create_instance() {
 | 
			
		||||
    return new Huey;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Huey::setup(cairo_t* context, const cairo_rectangle_t& rect) {
 | 
			
		||||
    ScreensaverPlugin::setup(context, rect);
 | 
			
		||||
    make_black();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int Huey::fps() const {
 | 
			
		||||
    return 40;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void Huey::draw_frame() {
 | 
			
		||||
    // next color
 | 
			
		||||
    HSB hsb;
 | 
			
		||||
    hsb.h = _hue;
 | 
			
		||||
    hsb.s = 1.0;
 | 
			
		||||
    hsb.b = 0.4;
 | 
			
		||||
 | 
			
		||||
    // convert to rgb
 | 
			
		||||
    Color color {hsb};
 | 
			
		||||
    RGB rgb {RGB(color)};
 | 
			
		||||
 | 
			
		||||
    // setup color, fill whole window
 | 
			
		||||
    cairo_set_source_rgb(_c, rgb.r, rgb.g, rgb.b);
 | 
			
		||||
    cairo_rectangle(_c, _r.x, _r.y, _r.width, _r.height);
 | 
			
		||||
    cairo_fill(_c);
 | 
			
		||||
 | 
			
		||||
    // update for next frame
 | 
			
		||||
    _hue += 0.5;
 | 
			
		||||
    if (_hue > 360.0) {
 | 
			
		||||
        _hue -= 360.0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								huey/Huey.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								huey/Huey.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
//
 | 
			
		||||
// Skembo.hpp
 | 
			
		||||
// screensaver
 | 
			
		||||
//
 | 
			
		||||
// Created by Bob Polis at 2020-10-26
 | 
			
		||||
// Copyright (c) 2020 SwiftCoder. All rights reserved.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#ifndef _Huey_H_
 | 
			
		||||
#define _Huey_H_
 | 
			
		||||
 | 
			
		||||
class ScreensaverPlugin;
 | 
			
		||||
 | 
			
		||||
extern "C" {
 | 
			
		||||
    ScreensaverPlugin* create_instance();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif // _Huey_H_
 | 
			
		||||
							
								
								
									
										62
									
								
								huey/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								huey/Makefile
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,62 @@
 | 
			
		||||
LIBNAME := $(shell basename $$(pwd))
 | 
			
		||||
MAJOR := 1
 | 
			
		||||
MINOR := 0.0
 | 
			
		||||
 | 
			
		||||
UNAME_S := $(shell uname -s)
 | 
			
		||||
 | 
			
		||||
ifeq ($(UNAME_S),Darwin)
 | 
			
		||||
	LINKERNAME := $(LIBNAME).dylib
 | 
			
		||||
	SONAME := $(LIBNAME).$(MAJOR).dylib
 | 
			
		||||
	REALNAME := $(LINKERNAME)
 | 
			
		||||
else
 | 
			
		||||
	LINKERNAME := $(LIBNAME).so
 | 
			
		||||
	SONAME := $(LINKERNAME).$(MAJOR)
 | 
			
		||||
	REALNAME := $(SONAME).$(MINOR)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
PREFIX ?= ..
 | 
			
		||||
LIBDIR ?= $(PREFIX)/plugins
 | 
			
		||||
 | 
			
		||||
SRCS := $(wildcard *.cpp)
 | 
			
		||||
OBJS := $(subst .cpp,.o,$(SRCS))
 | 
			
		||||
DEPS := $(subst .cpp,.d,$(SRCS))
 | 
			
		||||
HDRS := $(filter-out $(LIBNAME).hpp,$(wildcard *.hpp))
 | 
			
		||||
 | 
			
		||||
CXX ?= g++
 | 
			
		||||
 | 
			
		||||
CXXFLAGS := $(CXXFLAGS) -Wshadow -Wall -Wpedantic -Wextra -g -fno-strict-aliasing -std=c++17 -fPIC
 | 
			
		||||
ifeq ($(DEBUG),1)
 | 
			
		||||
	CXXFLAGS += -D DEBUG -O0
 | 
			
		||||
else
 | 
			
		||||
	CXXFLAGS += -D NDEBUG -O3
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
LDLIBS := -lcairo -lscscreensaver
 | 
			
		||||
 | 
			
		||||
RM := /bin/rm -f
 | 
			
		||||
INSTALL := /usr/bin/install -c
 | 
			
		||||
 | 
			
		||||
.PHONY: all clean install
 | 
			
		||||
 | 
			
		||||
all: $(REALNAME)
 | 
			
		||||
 | 
			
		||||
$(REALNAME): $(OBJS) $(DEPS)
 | 
			
		||||
ifeq ($(UNAME_S),Darwin)
 | 
			
		||||
	$(CXX) -dynamiclib -o $(REALNAME) -current_version $(MAJOR) -compatibility_version $(MINOR) $(LDFLAGS) $(LDLIBS) $(OBJS)
 | 
			
		||||
else
 | 
			
		||||
	$(CXX) -g -shared -Wl,-soname,$(SONAME) -o $(REALNAME) $(LDFLAGS) $(LDLIBS) $(OBJS)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
%.o: %.cpp %.d Makefile
 | 
			
		||||
	$(CXX) $(CXXFLAGS) -MMD -MP -MT $@ -MF $*.d -c $<
 | 
			
		||||
 | 
			
		||||
-include *.d
 | 
			
		||||
 | 
			
		||||
%.d: ;
 | 
			
		||||
 | 
			
		||||
clean:
 | 
			
		||||
	$(RM) $(OBJS) $(DEPS) $(REALNAME)
 | 
			
		||||
 | 
			
		||||
install: $(REALNAME)
 | 
			
		||||
	$(INSTALL) -d $(LIBDIR)
 | 
			
		||||
	$(INSTALL) -m 644 $(REALNAME) $(LIBDIR)/$(LIBNAME).saver
 | 
			
		||||
		Reference in New Issue
	
	Block a user